Files
react/components/input/styles.ts
witt 80956b0cc8 chore: release v2.1.0-canary.3 (#450)
* docs: add link to GH discussions

* chore: upgrade deps

* chore: update code style for prettier

* chore: release v2.1.0-canary.3

* chore(deps): upgrade babel

* chore: replace enzyme adapter with community repo to fit react.17

* test: updatee snapshots for auto typesetting

* test(config): ignore unexported parts of the tools
2021-02-14 15:27:37 +08:00

73 lines
1.6 KiB
TypeScript

import { NormalSizes, NormalTypes } from '../utils/prop-types'
import { GeistUIThemesPalette } from '../themes/presets'
export type InputSize = {
heightRatio: string
fontSize: string
}
export const getSizes = (size?: NormalSizes) => {
const sizes: { [key in NormalSizes]: InputSize } = {
mini: {
heightRatio: '1.313',
fontSize: '.75rem',
},
small: {
heightRatio: '1.5',
fontSize: '.75rem',
},
medium: {
heightRatio: '1.687',
fontSize: '.875rem',
},
large: {
heightRatio: '1.875',
fontSize: '1rem',
},
}
if (!size) return sizes.medium
return sizes[size]
}
export type InputColor = {
color: string
borderColor: string
hoverBorder: string
}
export const getColors = (
palette: GeistUIThemesPalette,
status?: NormalTypes,
): InputColor => {
const colors: { [key in NormalTypes]: InputColor } = {
default: {
color: palette.foreground,
borderColor: palette.border,
hoverBorder: palette.accents_5,
},
secondary: {
color: palette.foreground,
borderColor: palette.secondary,
hoverBorder: palette.secondary,
},
success: {
color: palette.foreground,
borderColor: palette.successLight,
hoverBorder: palette.success,
},
warning: {
color: palette.foreground,
borderColor: palette.warningLight,
hoverBorder: palette.warning,
},
error: {
color: palette.error,
borderColor: palette.error,
hoverBorder: palette.errorDark,
},
}
if (!status) return colors.default
return colors[status]
}