Skip to content

Commit e85ac1b

Browse files
committed
feat(ui-number-input): rewrite NumberInput to the new theming system
- Converted `NumberInput` from class-based to functional component - It uses the theme from TextInput, they are the same in Figma - The styling of the upper label/messages are not done, they are coming in `FormFieldLayout` Tokens are also not fully used (they are used only in `TextInput`): - `fontSizeSm`, `heightSm`, `paddingHorizontalSm`: This component has no small size - `gapContent`: This is a gap between the text and elements rendered after it, `NumberInput` does not have such To test: - Check the examples in the docs, they should function exactly as before - Compare its CSS to the ones in Figma Completes INSTUI-4814
1 parent f5ef5ee commit e85ac1b

File tree

11 files changed

+469
-342
lines changed

11 files changed

+469
-342
lines changed

packages/__docs__/resolve.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const alias = {
9292
),
9393
'@instructure/ui-grid$': path.resolve(import.meta.dirname, '../ui-grid/src/'),
9494
'@instructure/ui-i18n$': path.resolve(import.meta.dirname, '../ui-i18n/src/'),
95+
'@instructure/ui-icons-lucide': path.resolve(import.meta.dirname, '../ui-icons-lucide/src/'),
9596
'@instructure/ui-img$': path.resolve(import.meta.dirname, '../ui-img/src/'),
9697
'@instructure/ui-instructure$': path.resolve(import.meta.dirname, '../ui-instructure/src/'),
9798
'@instructure/ui-link$': path.resolve(import.meta.dirname, '../ui-link/src/'),

packages/emotion/src/styleUtils/calcFocusOutlineStyles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const calcFocusOutlineStyles = (
7878
transition: 'outline-color 0.2s, outline-offset 0.25s'
7979
}),
8080
outlineOffset: '-0.8rem',
81+
outlineStyle: 'solid',
8182
outlineColor: alpha(outlineStyle.outlineColor, 0),
8283
'&:focus': {
8384
...outlineStyle,

packages/emotion/src/useStyle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ const isNewThemeObject = (obj: BaseThemeOrOverride): obj is Theme => {
6060
const useStyle = <P extends GenerateStyleParams>(useStyleParams: {
6161
generateStyle: P
6262
params?: SecondParameter<P>
63-
componentId: keyof NewComponentTypes
63+
// needs to be a string too because it might be a child component
64+
componentId: keyof NewComponentTypes | string
6465
themeOverride: ThemeOverrideValue | undefined
6566
displayName?: string
6667
//in case of a child component needed to use it's parent's tokens, provide parent's name

packages/ui-icons-lucide/src/wrapLucideIcon/styles.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,12 @@ const generateStyle = (
4949
if (color === 'inherit') {
5050
colorStyle = { color: 'inherit' }
5151
} else if (color in componentTheme) {
52-
/**
53-
* Direct theme property access
54-
*/
52+
// Direct theme property access
5553
colorStyle = {
5654
color: componentTheme[color as keyof typeof componentTheme] as string
5755
}
5856
} else {
59-
/**
60-
* Custom CSS color (e.g., "#ff0000", "rgb(255, 0, 0)")
61-
*/
57+
// Custom CSS color (e.g., "#ff0000", "rgb(255, 0, 0)")
6258
colorStyle = { color }
6359
}
6460
}

packages/ui-number-input/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@instructure/shared-types": "workspace:*",
3838
"@instructure/ui-a11y-utils": "workspace:*",
3939
"@instructure/ui-form-field": "workspace:*",
40-
"@instructure/ui-icons": "workspace:*",
40+
"@instructure/ui-icons-lucide": "workspace:*",
4141
"@instructure/ui-react-utils": "workspace:*",
4242
"@instructure/ui-utils": "workspace:*",
4343
"@instructure/uid": "workspace:*",

packages/ui-number-input/src/NumberInput/README.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ Note that this field **does not work
88
uncontrolled** - you must pass event handlers if you want it to respond to
99
user input.
1010

11-
This example handles arrow buttons, up/down arrow keys, and typing into
12-
the input. It also includes an `onBlur` handler that displays an error message
13-
if the input is invalid or missing.
11+
This example handles arrow buttons, up/down arrow keys, and typing into the input. It also includes an `onBlur` handler that displays an error message if the input is invalid or missing.
1412

1513
```js
1614
---
@@ -150,16 +148,43 @@ render(<Example />)
150148

151149
> Note: `NumberInput` accepts a string or number as its `value`. However, the value returned by the `onChange` callback is always a string and should be converted to a number before attempting to augment it.
152150
153-
NumberInput comes in 2 sizes. The default size is "medium".
151+
You can see here most of the visual states of the component.
154152

155153
```js
156154
---
157-
type: example
155+
type: example
158156
---
159-
<div>
160-
<NumberInput renderLabel="Default-size input" /><br/>
161-
<NumberInput size="large" renderLabel="Large-size input" />
162-
</div>
157+
<Flex gap='2rem' direction='column'>
158+
<NumberInput
159+
renderLabel='normal'
160+
placeholder="placeholder"
161+
/>
162+
<NumberInput
163+
interaction='disabled'
164+
renderLabel='disabled'
165+
placeholder="placeholder"
166+
/>
167+
<NumberInput
168+
interaction='readonly'
169+
renderLabel='readonly'
170+
placeholder="placeholder"
171+
/>
172+
<NumberInput
173+
renderLabel='has error'
174+
placeholder="placeholder"
175+
messages={[{ text: 'This is an error.', type: 'error' }]}
176+
/>
177+
<NumberInput
178+
renderLabel='with success message'
179+
placeholder="placeholder"
180+
messages={[{ text: 'Great success!', type: 'success' }]}
181+
/>
182+
<NumberInput
183+
renderLabel='Large size. Default is "medium"'
184+
placeholder="placeholder"
185+
size='large'
186+
/>
187+
</Flex>
163188
```
164189

165190
### Guidelines

0 commit comments

Comments
 (0)