Skip to content

Commit

Permalink
fix(TextField): underlined variant
Browse files Browse the repository at this point in the history
  • Loading branch information
LexSwed committed Oct 8, 2020
1 parent 9f2dcef commit 08027c2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/lib/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { styled } from '../stitches.config';
import { HiOutlineCalendar, HiCheck, HiOutlineExclamationCircle } from 'react-icons/hi';
import Icon from '../Icon';
import { StylesObject } from '../types/helpers';
import { attribute } from '../FocusRing/focus-visible';

const iconStyles: StylesObject = {
position: 'absolute',
Expand All @@ -21,25 +22,16 @@ const Input = styled('input', {
'display': 'inline-flex',
'height': '$base',
'transition': '0.2s ease-in-out',
'border': '1px solid $borderStill',
'bc': '$surfaceStill',
'br': '$md',
'outline': 'none',
'::placeholder': {
color: '$borderStill',
},
':hover': {
borderColor: '$borderHover',
},
':disabled': {
color: '$textDisabled',
borderColor: '$surfaceDisabled',
bc: '$surfaceDisabled',
},
':focus': {
borderColor: '$borderActive',
boxShadow: '0 0 0 1px $borderActive inset',
},

'&[type="number"]::-webkit-inner-spin-button, &[type="number"]::-webkit-outer-spin-button': {
'-webkit-appearance': 'inner-spin-button !important',
Expand All @@ -57,6 +49,30 @@ const Input = styled('input', {
},

'variants': {
variant: {
boxed: {
'border': '1px solid $borderStill',
'br': '$md',
':hover': {
borderColor: '$borderHover',
},
':focus': {
borderColor: '$borderActive',
boxShadow: '0 0 0 1px $borderActive inset',
},
},
underlined: {
'borderBottom': '1px solid $borderStill',
'borderRadius': '$md $md 0 0',
':hover': {
borderColor: '$borderHover',
},
':focus': {
borderColor: '$primaryActive',
backgroundImage: 'linear-gradient(0deg, $primaryActive 0%, $primaryActive 2%, $surfaceStill 3%)',
},
},
},
hasIcon: {
true: {
pr: '$8',
Expand Down Expand Up @@ -124,6 +140,7 @@ const TextField: React.FC<Props> = ({
validity,
value,
disabled,
variant = 'boxed',
...props
}) => {
const handleChange = useMemo(() => {
Expand Down Expand Up @@ -165,6 +182,7 @@ const TextField: React.FC<Props> = ({
onChange={handleChange}
hasIcon={Boolean(iconRight)}
type={type}
variant={variant}
/>
{iconRight && (
<IconWrapper>
Expand Down
15 changes: 15 additions & 0 deletions src/pages/components/TextField.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ import { Box, Flex, TextField } from '@fxtrot/ui';
</Box>
</Playground>

## Variants

<Playground>
<Flex space="lg" css={{ p: '$6', bc: '$gray050' }}>
<Flex flow="row" space="md">
<TextField label="Enter your name" placeholder="John Doe" />
<TextField label="Enter your name" placeholder="John Doe" disabled />
</Flex>
<Flex flow="row" space="md">
<TextField variant="underlined" label="Enter your name" placeholder="John Doe" />
<TextField variant="underlined" label="Enter your name" placeholder="John Doe" disabled />
</Flex>
</Flex>
</Playground>

## Validity

<Playground>
Expand Down

1 comment on commit 08027c2

@vercel
Copy link

@vercel vercel bot commented on 08027c2 Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.