Browse Source

Add more stories for text inputs

Add stories for components inside fieldsets.
refactor/pridepack-storybook
TheoryOfNekomata 3 years ago
parent
commit
a330c7ffdd
4 changed files with 46 additions and 39 deletions
  1. +16
    -0
      packages/react-common/src/components/MultilineTextInput/MultilineTextInput.stories.tsx
  2. +0
    -0
      packages/react-common/src/components/MultilineTextInput/MultilineTextInput.test.tsx
  3. +14
    -39
      packages/react-common/src/components/MultilineTextInput/index.tsx
  4. +16
    -0
      packages/react-common/src/components/TextInput/TextInput.stories.tsx

+ 16
- 0
packages/react-common/src/components/MultilineTextInput/MultilineTextInput.stories.tsx View File

@@ -123,3 +123,19 @@ WithLabelHintAndIndicatorLarge.args = {
indicator: 'A', indicator: 'A',
size: MultilineTextInputSize.LARGE, size: MultilineTextInputSize.LARGE,
} }

export const DisabledWithinFieldset: Story<Props> = ({ ref, disabled, ...args }) => (
<fieldset
disabled={disabled}
>
<MultilineTextInput
{...args}
/>
</fieldset>
)
DisabledWithinFieldset.args = {
border: true,
label: 'Foo',
hint: '(example value)',
disabled: true,
}

packages/react-common/src/components/MultilineTextInput/TextInput.test.tsx → packages/react-common/src/components/MultilineTextInput/MultilineTextInput.test.tsx View File


+ 14
- 39
packages/react-common/src/components/MultilineTextInput/index.tsx View File

@@ -48,6 +48,9 @@ const ComponentBase = styled('div')({
':focus-within': { ':focus-within': {
'--color-accent': 'var(--color-active, Highlight)', '--color-accent': 'var(--color-active, Highlight)',
}, },
'fieldset[disabled] &': {
opacity: 0.5,
},
}) })


ComponentBase.displayName = 'div' ComponentBase.displayName = 'div'
@@ -114,38 +117,6 @@ const Border = styled('span')({
}, },
}) })


const Input = styled('input')({
display: 'block',
verticalAlign: 'top',
paddingTop: 0,
paddingBottom: 0,
boxSizing: 'border-box',
position: 'relative',
border: 0,
borderRadius: 'inherit',
margin: 0,
font: 'inherit',
minHeight: '4rem',
minWidth: '8rem',
maxWidth: '100%',
width: '100%',
zIndex: 1,
transitionProperty: 'background-color, color',
':focus': {
outline: 0,
color: 'var(--color-fg, black)',
},
':disabled': {
cursor: 'not-allowed',
},
'@media only screen': {
backgroundColor: 'var(--color-bg, white)',
color: 'var(--color-fg, black)',
},
})

Input.displayName = 'input'

const TextArea = styled('textarea')({ const TextArea = styled('textarea')({
display: 'block', display: 'block',
verticalAlign: 'top', verticalAlign: 'top',
@@ -164,10 +135,16 @@ const TextArea = styled('textarea')({
zIndex: 1, zIndex: 1,
transitionProperty: 'background-color, color', transitionProperty: 'background-color, color',
resize: 'none', resize: 'none',
lineHeight: 'normal',
':focus': { ':focus': {
outline: 0, outline: 0,
color: 'var(--color-fg, black)',
},
':disabled': {
cursor: 'not-allowed',
}, },
'@media only screen': { '@media only screen': {
backgroundColor: 'var(--color-bg, white)',
color: 'var(--color-fg, black)', color: 'var(--color-fg, black)',
}, },
}) })
@@ -259,19 +236,16 @@ export const MultilineTextInput = React.forwardRef<HTMLTextAreaElement, Props>(
{ {
label = '', label = '',
hint = '', hint = '',
indicator = null,
size = MultilineTextInputSize.MEDIUM, size = MultilineTextInputSize.MEDIUM,
disabled = false,
rows = 3,
indicator = null,
border = false, border = false,
onChange,
onFocus,
onBlur,
alternate = false, alternate = false,
block = false,
disabled = false,
rows = 3,
defaultValue, defaultValue,
value, value,
name, name,
block = false,
...etcProps ...etcProps
}, },
ref, ref,
@@ -320,6 +294,7 @@ export const MultilineTextInput = React.forwardRef<HTMLTextAreaElement, Props>(
defaultValue={defaultValue} defaultValue={defaultValue}
value={value} value={value}
name={name} name={name}
rows={rows}
/> />
</CaptureArea> </CaptureArea>
{hint && ( {hint && (


+ 16
- 0
packages/react-common/src/components/TextInput/TextInput.stories.tsx View File

@@ -123,3 +123,19 @@ WithLabelHintAndIndicatorLarge.args = {
indicator: 'A', indicator: 'A',
size: TextInputSize.LARGE, size: TextInputSize.LARGE,
} }

export const DisabledWithinFieldset: Story<Props> = ({ ref, disabled, ...args }) => (
<fieldset
disabled={disabled}
>
<TextInput
{...args}
/>
</fieldset>
)
DisabledWithinFieldset.args = {
border: true,
label: 'Foo',
hint: '(example value)',
disabled: true,
}

Loading…
Cancel
Save