Skip to content

Commit 1feff1c

Browse files
authored
feat: Expose input border colours as --reactist-inputs-* variables (#790)
1 parent 00bff7c commit 1feff1c

14 files changed

+706
-602
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it.
44

5+
# v21.2.0
6+
7+
- [Feat] `Textfield`, `PasswordField`, `SelectField`, and `TextArea` will now use two new CSS variables to define their border colors: `--reactist-inputs-focus`, `--reactist-inputs-idle`. If they were previously set using `--reactist-divider-primary` and `--reactist-divider-secondary`, they will continue to work as well.
8+
59
# v21.1.1
610

711
- [Fix] Using a menu both triggered by a button and by right-click.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"email": "henning@doist.com",
77
"url": "http://doist.com"
88
},
9-
"version": "21.1.1",
9+
"version": "21.2.0",
1010
"license": "MIT",
1111
"homepage": "https://github.com/Doist/reactist#readme",
1212
"repository": {

src/base-field/base-field.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
.container.bordered {
1111
border-radius: var(--reactist-border-radius-large);
12-
border: 1px solid var(--reactist-divider-secondary);
12+
border: 1px solid var(--reactist-inputs-idle);
1313
padding: var(--reactist-spacing-small);
1414
padding-bottom: var(--reactist-spacing-xsmall);
1515
overflow: clip;
@@ -28,7 +28,7 @@
2828
}
2929

3030
.container.bordered:focus-within {
31-
border-color: var(--reactist-divider-primary) !important;
31+
border-color: var(--reactist-inputs-focus) !important;
3232
}
3333

3434
.container.bordered.error {
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
import { Meta, Story, Canvas, ArgsTable, Description } from '@storybook/addon-docs'
2+
3+
import { Stack } from '../stack'
4+
import { Text } from '../text'
5+
import { PasswordField } from './'
6+
7+
import { selectWithNone } from '../utils/storybook-helper'
8+
9+
<Meta
10+
title="Design system/PasswordField"
11+
component={PasswordField}
12+
parameters={{
13+
badges: ['accessible'],
14+
}}
15+
/>
16+
17+
# PasswordField
18+
19+
A component used to accept password input from the user.
20+
21+
export function preventDefault(event) {
22+
event.preventDefault()
23+
}
24+
25+
export function InteractivePropsStory({ label, auxiliaryLabel, ...props }) {
26+
return (
27+
<PasswordField
28+
{...props}
29+
label={label}
30+
auxiliaryLabel={
31+
auxiliaryLabel ? (
32+
<a href="#" onClick={preventDefault}>
33+
{auxiliaryLabel}
34+
</a>
35+
) : undefined
36+
}
37+
/>
38+
)
39+
}
40+
41+
<Canvas>
42+
<Story
43+
name="Interactive props"
44+
parameters={{
45+
chromatic: { disableSnapshot: false },
46+
}}
47+
argTypes={{
48+
label: {
49+
control: { type: 'text' },
50+
defaultValue: 'Password',
51+
},
52+
secondaryLabel: {
53+
control: { type: 'text' },
54+
defaultValue: 'optional',
55+
},
56+
auxiliaryLabel: {
57+
control: { type: 'text' },
58+
defaultValue: 'Forgot your password?',
59+
},
60+
hint: {
61+
control: { type: 'text' },
62+
defaultValue:
63+
'Must be at least 100 characters long, and it should include each letter of the alphabet',
64+
},
65+
message: {
66+
control: { type: 'text' },
67+
defaultValue: '',
68+
},
69+
tone: {
70+
options: ['neutral', 'success', 'error', 'loading'],
71+
control: { type: 'inline-radio' },
72+
defaultValue: 'neutral',
73+
},
74+
variant: {
75+
options: ['default', 'bordered'],
76+
control: { type: 'inline-radio' },
77+
defaultValue: 'default',
78+
},
79+
placeholder: {
80+
control: { type: 'text' },
81+
defaultValue: 'Type your password',
82+
},
83+
maxWidth: selectWithNone(['xsmall', 'small', 'medium', 'large', 'xlarge'], 'small'),
84+
}}
85+
>
86+
{InteractivePropsStory.bind({})}
87+
</Story>
88+
</Canvas>
89+
90+
<ArgsTable of={PasswordField} />
91+
92+
## Colors
93+
94+
The following CSS custom properties are available so that the `PasswordField`'s border colors can be customized.
95+
Note that these variables are shared with other components such as `Textfield`, `SelectField`, and `TextArea`.
96+
97+
```
98+
--reactist-inputs-focus
99+
--reactist-inputs-idle
100+
```
101+
102+
<Canvas withToolbar>
103+
<Story
104+
name="Message tone"
105+
parameters={{
106+
chromatic: { disableSnapshot: false },
107+
}}
108+
>
109+
<Stack space="xxlarge" dividers="secondary">
110+
<PasswordField
111+
label="Password confirmation"
112+
message="Comparing to original password…"
113+
tone="loading"
114+
disabled
115+
maxWidth="small"
116+
/>
117+
<PasswordField
118+
label="Password confirmation"
119+
message="It does not match the original password"
120+
tone="error"
121+
maxWidth="small"
122+
/>
123+
<PasswordField
124+
label="Password confirmation"
125+
message="Matches original password!"
126+
tone="success"
127+
maxWidth="small"
128+
/>
129+
<PasswordField
130+
label="Password confirmation"
131+
message="Message with neutral tone (used as description, but still prefer the hint prop for that)"
132+
hint="This is the primary description of the field, provided by the hint prop"
133+
tone="neutral"
134+
maxWidth="small"
135+
/>
136+
</Stack>
137+
</Story>
138+
</Canvas>
139+
140+
<Canvas withToolbar>
141+
<Story name="Without label">
142+
<Stack space="xlarge" dividers="secondary" maxWidth="small">
143+
<Stack as="label" htmlFor="custom-textarea" space="small">
144+
<Text size="subtitle">Custom label is up here</Text>
145+
<Text size="caption" tone="secondary" aria-hidden>
146+
<em>(click me to focus the textarea)</em>
147+
</Text>
148+
</Stack>
149+
<PasswordField
150+
label={null}
151+
id="custom-textarea"
152+
aria-describedby="custom-description"
153+
placeholder="Password field without a built-in label"
154+
/>
155+
<Stack space="small" id="custom-description">
156+
<Text size="body">Custom description is down here</Text>
157+
<Text size="caption" tone="secondary" aria-hidden>
158+
<em>(inspect the input element accessibility properties if you are curious)</em>
159+
</Text>
160+
</Stack>
161+
</Stack>
162+
</Story>
163+
</Canvas>

src/password-field/password-field.stories.tsx

Lines changed: 0 additions & 149 deletions
This file was deleted.

src/select-field/select-field.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
color: var(--reactist-content-primary);
4444
background: none;
4545
border-radius: var(--reactist-border-radius-small);
46-
border: 1px solid var(--reactist-divider-secondary);
46+
border: 1px solid var(--reactist-inputs-idle);
4747
font-size: var(--reactist-font-size-body);
4848
line-height: calc(var(--reactist-font-size-body) + 4px);
4949
margin: 0;
@@ -58,5 +58,5 @@
5858
}
5959

6060
.selectWrapper:not(.bordered) select:focus {
61-
border-color: var(--reactist-divider-primary);
61+
border-color: var(--reactist-inputs-focus);
6262
}

0 commit comments

Comments
 (0)