diff --git a/src/components/Surface.tsx b/src/components/Surface.tsx index 1dd31fc..b6e2494 100644 --- a/src/components/Surface.tsx +++ b/src/components/Surface.tsx @@ -2,29 +2,19 @@ import React, { FC } from 'react' /** @jsx jsx */ import { jsx, css } from '@emotion/core' -import { getColor, getMeasure } from '../helpers' import { useTheme } from '../hooks' import { Flexible } from './Flexible' +import { useLifting } from '../hooks/useLifting' interface Props extends FlexibleType, Liftable {} -const getZIndex = (lifting?: Measure) => - lifting ? getMeasure(lifting!, [1, 2, 3, 4]) : 0 - -const getAlpha = (lifting?: Measure) => - lifting ? getMeasure(lifting!, [0.05, 0.1, 0.15, 0.2]) : 0 - /** * TODO: Separate margin and padding into constants. */ const Surface: FC = ({ lifting, children, ...rest }) => { - const { colors, elements } = useTheme() + const { elements } = useTheme() + const { zIndex, bgColor, color } = useLifting(lifting) - const zIndex = getZIndex(lifting) - const bgColor = lifting - ? getColor(colors.contrast, getAlpha(lifting)) - : getColor(colors.substratum) - const color = getColor(colors.contrast) const borderRadius = elements.roundness return ( diff --git a/src/components/TextInput.tsx b/src/components/TextInput.tsx new file mode 100644 index 0000000..99ec04d --- /dev/null +++ b/src/components/TextInput.tsx @@ -0,0 +1,46 @@ +import React from 'react' +/** @jsx jsx */ +import { jsx, css } from '@emotion/core' + +import { useLifting } from '../hooks/useLifting' +import { useTheme } from '../hooks' + +interface Props extends NativeInputType { + type: + | 'text' + | 'email' + | 'url' + | 'search' + | 'tel' + | 'password' + | 'number' + | 'date' + | 'color' + | 'file' +} + +const TextInput: React.FC = ({ type, size, ...rest }) => { + const { zIndex, bgColor, color } = useLifting('xl') + const { elements } = useTheme() + + const borderRadius = elements.roundness + return ( + + ) +} + +export { TextInput } diff --git a/src/components/index.ts b/src/components/index.ts index 08f8260..f0b83c9 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -12,6 +12,7 @@ import { Paragraph } from './Paragraph' import { DarksideTheme } from './DarksideTheme' import { GlobalStyles } from './GobalStyles' import { Icon } from './Icon' +import { TextInput } from './TextInput' export { Icon, @@ -28,4 +29,5 @@ export { Paragraph, DarksideTheme, GlobalStyles, + TextInput, } diff --git a/src/docs/Forms.mdx b/src/docs/Forms.mdx new file mode 100644 index 0000000..fa2559b --- /dev/null +++ b/src/docs/Forms.mdx @@ -0,0 +1,25 @@ +--- +## name: Forms +--- + +import { Playground } from 'docz' + +import { TextInput, Surface } from '../index' + +# Forms + +## Text + + + + + + + + + + + + + + diff --git a/src/hooks/useLifting.ts b/src/hooks/useLifting.ts new file mode 100644 index 0000000..11ad2b9 --- /dev/null +++ b/src/hooks/useLifting.ts @@ -0,0 +1,27 @@ +import React from 'react' +import { useTheme } from './useTheme' +import { getMeasure, getColor } from '../helpers' + +const useLifting = (lifting?: Measure) => { + const { colors } = useTheme() + + const getZIndex = (lifting?: Measure) => + lifting ? getMeasure(lifting!, [1, 2, 3, 4]) : 0 + + const getAlpha = (lifting?: Measure) => + lifting ? getMeasure(lifting!, [0.05, 0.1, 0.15, 0.2]) : 0 + + const zIndex = getZIndex(lifting) + const bgColor = lifting + ? getColor(colors.contrast, getAlpha(lifting)) + : getColor(colors.substratum) + const color = getColor(colors.contrast) + + return { + zIndex, + color, + bgColor, + } +} + +export { useLifting } diff --git a/src/typings.d.ts b/src/typings.d.ts index c613c07..4fe394d 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -21,6 +21,11 @@ type NativeImgType = React.DetailedHTMLProps< HTMLImageElement > +type NativeInputType = React.DetailedHTMLProps< + React.InputHTMLAttributes, + HTMLInputElement +> + /** * Represent a color on RGB system */