From a330c7ffdd2d527b274220a8873be6902cf2091a Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Sun, 15 Aug 2021 14:49:19 +0800 Subject: [PATCH] Add more stories for text inputs Add stories for components inside fieldsets. --- .../MultilineTextInput.stories.tsx | 16 ++++++ ...t.test.tsx => MultilineTextInput.test.tsx} | 0 .../components/MultilineTextInput/index.tsx | 53 +++++-------------- .../TextInput/TextInput.stories.tsx | 16 ++++++ 4 files changed, 46 insertions(+), 39 deletions(-) rename packages/react-common/src/components/MultilineTextInput/{TextInput.test.tsx => MultilineTextInput.test.tsx} (100%) diff --git a/packages/react-common/src/components/MultilineTextInput/MultilineTextInput.stories.tsx b/packages/react-common/src/components/MultilineTextInput/MultilineTextInput.stories.tsx index 71061b4..faaa78b 100644 --- a/packages/react-common/src/components/MultilineTextInput/MultilineTextInput.stories.tsx +++ b/packages/react-common/src/components/MultilineTextInput/MultilineTextInput.stories.tsx @@ -123,3 +123,19 @@ WithLabelHintAndIndicatorLarge.args = { indicator: 'A', size: MultilineTextInputSize.LARGE, } + +export const DisabledWithinFieldset: Story = ({ ref, disabled, ...args }) => ( +
+ +
+) +DisabledWithinFieldset.args = { + border: true, + label: 'Foo', + hint: '(example value)', + disabled: true, +} diff --git a/packages/react-common/src/components/MultilineTextInput/TextInput.test.tsx b/packages/react-common/src/components/MultilineTextInput/MultilineTextInput.test.tsx similarity index 100% rename from packages/react-common/src/components/MultilineTextInput/TextInput.test.tsx rename to packages/react-common/src/components/MultilineTextInput/MultilineTextInput.test.tsx diff --git a/packages/react-common/src/components/MultilineTextInput/index.tsx b/packages/react-common/src/components/MultilineTextInput/index.tsx index 386924f..8cb3601 100644 --- a/packages/react-common/src/components/MultilineTextInput/index.tsx +++ b/packages/react-common/src/components/MultilineTextInput/index.tsx @@ -48,6 +48,9 @@ const ComponentBase = styled('div')({ ':focus-within': { '--color-accent': 'var(--color-active, Highlight)', }, + 'fieldset[disabled] &': { + opacity: 0.5, + }, }) 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')({ display: 'block', verticalAlign: 'top', @@ -164,10 +135,16 @@ const TextArea = styled('textarea')({ zIndex: 1, transitionProperty: 'background-color, color', resize: 'none', + lineHeight: 'normal', ':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)', }, }) @@ -259,19 +236,16 @@ export const MultilineTextInput = React.forwardRef( { label = '', hint = '', - indicator = null, size = MultilineTextInputSize.MEDIUM, - disabled = false, - rows = 3, + indicator = null, border = false, - onChange, - onFocus, - onBlur, alternate = false, + block = false, + disabled = false, + rows = 3, defaultValue, value, name, - block = false, ...etcProps }, ref, @@ -320,6 +294,7 @@ export const MultilineTextInput = React.forwardRef( defaultValue={defaultValue} value={value} name={name} + rows={rows} /> {hint && ( diff --git a/packages/react-common/src/components/TextInput/TextInput.stories.tsx b/packages/react-common/src/components/TextInput/TextInput.stories.tsx index e62045c..c342fb4 100644 --- a/packages/react-common/src/components/TextInput/TextInput.stories.tsx +++ b/packages/react-common/src/components/TextInput/TextInput.stories.tsx @@ -123,3 +123,19 @@ WithLabelHintAndIndicatorLarge.args = { indicator: 'A', size: TextInputSize.LARGE, } + +export const DisabledWithinFieldset: Story = ({ ref, disabled, ...args }) => ( +
+ +
+) +DisabledWithinFieldset.args = { + border: true, + label: 'Foo', + hint: '(example value)', + disabled: true, +}