Skip to content

Commit 51c7fbf

Browse files
committed
Update documentation and css layout
1 parent 66c13fb commit 51c7fbf

File tree

7 files changed

+293
-700
lines changed

7 files changed

+293
-700
lines changed

docs/content/TextInput.mdx

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TextInput is a form component to add default styling to the native text input.
1414
<TextInput aria-label="Zipcode" name="zipcode" placeholder="Zipcode" autoComplete="postal-code" />
1515
```
1616

17-
## Text Input with Icons
17+
## Text Input with icons
1818

1919
```jsx live
2020
<>
@@ -27,7 +27,6 @@ TextInput is a form component to add default styling to the native text input.
2727
/>
2828

2929
<TextInput
30-
sx={{mt: 3}}
3130
trailingVisual={SearchIcon}
3231
aria-label="Zipcode"
3332
name="zipcode"
@@ -37,23 +36,17 @@ TextInput is a form component to add default styling to the native text input.
3736
</>
3837
```
3938

40-
## Text Input with Text visuals
39+
## Text Input with text visuals
4140

4241
```jsx live
4342
<>
4443
<TextInput leadingVisual="$" aria-label="Cost of the thing" name="cost" placeholder="23.45" />
4544

46-
<TextInput
47-
sx={{mt: 3, width: '150px'}}
48-
trailingVisual="minutes"
49-
aria-label="Time in minutes"
50-
name="time"
51-
placeholder="25"
52-
/>
45+
<TextInput sx={{width: '150px'}} trailingVisual="minutes" aria-label="Time in minutes" name="time" placeholder="25" />
5346
</>
5447
```
5548

56-
## Text Input with Error and warning states
49+
## Text Input with error and warning states
5750

5851
```jsx live
5952
<>
@@ -66,7 +59,6 @@ TextInput is a form component to add default styling to the native text input.
6659
/>
6760

6861
<TextInput
69-
sx={{mt: 3}}
7062
validationStatus="warning"
7163
aria-label="Zipcode"
7264
name="zipcode"
@@ -86,6 +78,7 @@ TextInput is a form component to add default styling to the native text input.
8678

8779
```jsx live
8880
<TextInput contrast aria-label="Zipcode" name="zipcode" placeholder="Find user" autoComplete="postal-code" />
81+
```
8982

9083
## Props
9184

@@ -99,7 +92,7 @@ TextInput is a form component to add default styling to the native text input.
9992
defaultValue="false"
10093
description={
10194
<>
102-
Adds <InlineCode>display: block</InlineCode> to element
95+
Creates a full width input element
10396
</>
10497
}
10598
/>
@@ -109,19 +102,36 @@ TextInput is a form component to add default styling to the native text input.
109102
defaultValue="false"
110103
description="Changes background color to a higher contrast color"
111104
/>
112-
<PropsTableRow
113-
name="variant"
114-
type="'small' | 'large'"
115-
description="Creates a smaller or larger input than the default."
116-
/>
105+
<PropsTableRow name='size' type="'small' | 'medium' | 'large'" description="Creates a smaller or larger input than the default." />
106+
107+
<PropsTableRow
108+
name="leadingVisual"
109+
type={<>string | React.ComponentType</>}
110+
description="Visual positioned on the left edge inside the input"
111+
/>
112+
<PropsTableRow
113+
name="trailingVisual"
114+
type={<>string | React.ComponentType</>}
115+
description="Visual positioned on the right edge inside the input"
116+
/>
117+
<PropsTableRow name="validationStatus" type="'warning' | 'error'" description="Style the input to match the status" />
118+
119+
<PropsTableRow
120+
name="variant"
121+
type="'small' | 'medium' | 'large'"
122+
description="(Use size) Creates a smaller or larger input than the default."
123+
deprecated
124+
/>
125+
117126
<PropsTableRow
118127
name="width"
119128
type={
120129
<>
121130
string | number | <Link href="https://styled-system.com/guides/array-props">Array&lt;string | number&gt;</Link>
122131
</>
123132
}
124-
description="Set the width of the input"
133+
description="(Use sx prop) Set the width of the input"
134+
deprecated
125135
/>
126136
<PropsTableRow
127137
name="maxWidth"
@@ -130,7 +140,8 @@ TextInput is a form component to add default styling to the native text input.
130140
string | number | <Link href="https://styled-system.com/guides/array-props">Array&lt;string | number&gt;</Link>
131141
</>
132142
}
133-
description="Set the maximum width of the input"
143+
description="(Use sx prop) Set the maximum width of the input"
144+
deprecated
134145
/>
135146
<PropsTableRow
136147
name="minWidth"
@@ -139,12 +150,14 @@ TextInput is a form component to add default styling to the native text input.
139150
string | number | <Link href="https://styled-system.com/guides/array-props">Array&lt;string | number&gt;</Link>
140151
</>
141152
}
142-
description="Set the minimum width of the input"
153+
description="(Use sx prop) Set the minimum width of the input"
154+
deprecated
143155
/>
144156
<PropsTableRow
145157
name="icon"
146158
type="React.ComponentType"
147-
description="An Octicon React component. To be used inside of input. Positioned on the left edge."
159+
description="(Use leadingVisual or trailingVisual) An Octicon React component. To be used inside of input. Positioned on the left edge."
160+
deprecated
148161
/>
149162
<PropsTableSxRow />
150163
<PropsTableRefRow
@@ -170,8 +183,8 @@ TextInput is a form component to add default styling to the native text input.
170183
adaptsToScreenSizes: true,
171184
fullTestCoverage: false,
172185
usedInProduction: true,
173-
usageExamplesDocumented: false,
174-
hasStorybookStories: false,
186+
usageExamplesDocumented: true,
187+
hasStorybookStories: true,
175188
designReviewed: false,
176189
a11yReviewed: false,
177190
stableApi: false,
@@ -180,4 +193,3 @@ TextInput is a form component to add default styling to the native text input.
180193
hasFigmaComponent: false
181194
}}
182195
/>
183-
```

src/TextInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputInternalProps>(
6161
>
6262
{IconComponent && <IconComponent className="TextInput-icon" />}
6363
{LeadingVisual && (
64-
<span data-component="leadingVisual">
64+
<span className="TextInput-icon">
6565
{typeof LeadingVisual === 'function' ? <LeadingVisual /> : LeadingVisual}
6666
</span>
6767
)}
6868
<UnstyledTextInput ref={ref} disabled={disabled} {...inputProps} data-component="input" />
6969
{TrailingVisual && (
70-
<span data-component="leadingVisual">
70+
<span className="TextInput-icon">
7171
{typeof TrailingVisual === 'function' ? <TrailingVisual /> : TrailingVisual}
7272
</span>
7373
)}

src/_TextInputWrapper.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ type StyledWrapperProps = {
5353
SxProp
5454

5555
const TextInputWrapper = styled.span<StyledWrapperProps>`
56-
width: max-content;
5756
min-height: 34px;
5857
font-size: ${get('fontSizes.1')};
5958
line-height: 20px;
@@ -68,27 +67,15 @@ const TextInputWrapper = styled.span<StyledWrapperProps>`
6867
box-shadow: ${get('shadows.primer.shadow.inset')};
6968
cursor: text;
7069
padding: 6px 12px;
71-
display: grid;
72-
grid-template-columns: auto 1fr auto;
73-
justify-items: end;
70+
display: inline-flex;
71+
align-items: stretch;
7472
& > :not(:last-child) {
7573
margin-right: ${get('space.2')};
7674
}
7775
78-
[data-component=' leadingVisual '] {
79-
align-self: center;
80-
color: ${get('colors.fg.muted')};
81-
}
82-
83-
[data-component=' trailingVisual '] {
84-
align-self: center;
85-
color: ${get('colors.fg.muted')};
86-
}
87-
8876
.TextInput-icon {
8977
align-self: center;
9078
color: ${get('colors.fg.muted')};
91-
margin: 0 ${get('space.2')};
9279
flex-shrink: 0;
9380
}
9481

0 commit comments

Comments
 (0)