Skip to content

Commit

Permalink
fix(select): set icons and hover state to follow the theme
Browse files Browse the repository at this point in the history
  • Loading branch information
unix committed Jun 5, 2021
1 parent fc97923 commit 1f3caf6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 9 additions & 9 deletions components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
}, [value])
const sizes = useMemo(() => getSizes(theme, size), [theme, size])

const { border, placeholderColor } = useMemo(() => getColors(theme.palette, type), [
theme.palette,
type,
])
const { border, borderHover, iconBorder, placeholderColor } = useMemo(
() => getColors(theme.palette, type),
[theme.palette, type],
)

const updateVisible = (next: boolean) => setVisible(next)
const updateValue = (next: string) => {
Expand Down Expand Up @@ -186,8 +186,8 @@ const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
max-width: 80vw;
width: ${width};
overflow: hidden;
transition: border 0.2s ease 0s, color 0.2s ease-out 0s,
box-shadow 0.2s ease 0s;
transition: border 150ms ease-in 0s, color 200ms ease-out 0s,
box-shadow 200ms ease 0s;
border: 1px solid ${border};
border-radius: ${theme.layout.radius};
padding: 0 ${theme.layout.gapQuarter} 0 ${theme.layout.gapHalf};
Expand All @@ -206,11 +206,11 @@ const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
}
.select:hover {
border-color: ${disabled ? theme.palette.border : theme.palette.foreground};
border-color: ${disabled ? theme.palette.border : borderHover};
}
.select:hover .icon {
color: ${disabled ? theme.palette.accents_5 : theme.palette.foreground};
color: ${disabled ? theme.palette.accents_5 : borderHover};
}
.value {
Expand Down Expand Up @@ -250,7 +250,7 @@ const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
transition: transform 200ms ease;
display: flex;
align-items: center;
color: ${theme.palette.accents_5};
color: ${iconBorder};
}
`}</style>
</div>
Expand Down
14 changes: 14 additions & 0 deletions components/select/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const getSizes = (theme: GeistUIThemes, size?: NormalSizes) => {

export type SelectColor = {
border: string
borderHover: string
iconBorder: string
placeholderColor: string
}

Expand All @@ -46,22 +48,34 @@ export const getColors = (
const colors: { [key in NormalTypes]: SelectColor } = {
default: {
border: palette.border,
borderHover: palette.foreground,
iconBorder: palette.accents_5,
placeholderColor: palette.accents_3,
},
secondary: {
border: palette.border,
borderHover: palette.foreground,
iconBorder: palette.accents_5,
placeholderColor: palette.accents_3,
},
success: {
border: palette.success,
borderHover: palette.successDark,
iconBorder: palette.success,
placeholderColor: palette.accents_3,
},
warning: {
border: palette.warning,
borderHover: palette.warningDark,
iconBorder: palette.warning,

placeholderColor: palette.accents_3,
},
error: {
border: palette.error,
borderHover: palette.errorDark,
iconBorder: palette.error,

placeholderColor: palette.error,
},
}
Expand Down

0 comments on commit 1f3caf6

Please sign in to comment.