This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e0a1a6
commit c40dec3
Showing
8 changed files
with
128 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/lib/components/buttons/IconButton/IconButton.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Transition, transitionToCss } from '../../../theme' | ||
import styled from 'styled-components' | ||
import { IconButtonSize } from './IconButton' | ||
|
||
export type StyledIconButtonProps = { | ||
borderRadius?: string | ||
backgroundColor?: string | ||
foregroundColor?: string | ||
transition?: Transition | ||
shadow?: string | ||
hoverShadow?: string | ||
borderColor?: string | ||
glow?: string | ||
size?: IconButtonSize | ||
} | ||
|
||
export const StyledIconButton = styled.button<StyledIconButtonProps>` | ||
border-radius: ${(props) => props.borderRadius}; | ||
background-color: ${(props) => props.backgroundColor}; | ||
color: ${(props) => props.foregroundColor}; | ||
box-shadow: ${(props) => props.shadow}; | ||
border: none; | ||
outline: none; | ||
transition: ${(props) => transitionToCss(props.transition)}; | ||
&:hover { | ||
filter: brightness(110%); | ||
box-shadow: ${(props) => props.hoverShadow}; | ||
svg { | ||
filter: brightness(110%); | ||
} | ||
} | ||
&:active { | ||
filter: brightness(75%); | ||
svg { | ||
transform: scale(0.95); | ||
} | ||
} | ||
&:focus { | ||
box-shadow: 0 0 0 1px ${(props) => props.borderColor}, ${(props) => props.glow}, | ||
${(props) => props.shadow}; | ||
} | ||
&:disabled { | ||
filter: saturate(65%); | ||
svg, | ||
p { | ||
opacity: 50%; | ||
font-size: ${(props) => (props.size === 'large' ? '18px' : '16px')}; | ||
color: ${(props) => props.foregroundColor}; | ||
} | ||
} | ||
min-width: ${(props) => (props.size === 'large' ? '42px' : '30px')}; | ||
min-height: ${(props) => (props.size === 'large' ? '42px' : '30px')}; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { IconProp } from '@fortawesome/fontawesome-svg-core' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import React from 'react' | ||
import { useTheme } from '../../../hooks' | ||
import { Theme } from '../../../theme' | ||
import { StyledIconButton, StyledIconButtonProps } from './IconButton.styles' | ||
|
||
export type IconButtonSize = 'small' | 'large' | ||
|
||
export type IconButtonProps = StyledIconButtonProps & { | ||
icon?: IconProp | ||
label?: string | ||
onClick?: () => void | ||
size?: IconButtonSize | ||
} | ||
|
||
const getIconButtonStyles = (props: IconButtonProps, theme: Theme): IconButtonProps => { | ||
return { | ||
...props, | ||
borderRadius: theme.shapes.borders.small, | ||
backgroundColor: theme.colors.iconButton, | ||
foregroundColor: theme.colors.onIconButton, | ||
transition: theme.transitions.short, | ||
shadow: theme.shadows.xsmall, | ||
hoverShadow: theme.shadows.small, | ||
borderColor: theme.colors.buttonBorder, | ||
glow: theme.shadows.glow | ||
} | ||
} | ||
|
||
export const IconButton = (props: IconButtonProps) => { | ||
const theme = useTheme() | ||
props = getIconButtonStyles(props, theme) | ||
|
||
return ( | ||
<StyledIconButton {...props} onClick={props.onClick}> | ||
<FontAwesomeIcon icon={props.icon} /> | ||
</StyledIconButton> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
import React from 'react' | ||
import { ButtonProps } from '../Button' | ||
import { StyledIconButton } from './styles' | ||
|
||
export const IconButton = (props: ButtonProps) => { | ||
return <StyledIconButton {...props}></StyledIconButton> | ||
} | ||
export * from './IconButton' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
export * from './Button' | ||
export * from './IconButton' | ||
|
||
export type ButtonSize = 'large' | 'medium' | 'small' |