agroptima-design-system 1.2.32-beta.1 → 1.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +2 -1
- package/package.json +1 -1
- package/src/atoms/Input.scss +2 -2
- package/src/atoms/InputWithSelect/InputWithSelect.scss +7 -1
- package/src/settings/breakpoints.ts +5 -0
- package/src/stories/Changelog.mdx +4 -0
- package/src/stories/InputWithSelect.stories.tsx +10 -9
- package/tests/InputWithSelect.spec.tsx +3 -3
- package/tests/breakpoints.spec.ts +22 -0
package/CLAUDE.md
CHANGED
|
@@ -91,7 +91,8 @@ ComponentName/
|
|
|
91
91
|
- `_form.scss` - Form-specific typography
|
|
92
92
|
- `_cards_table.scss` - Table typography
|
|
93
93
|
- **_config.scss** - Spacing scale, border radius, responsive breakpoints
|
|
94
|
-
- **_breakpoints.scss** - Breakpoints: 375px (
|
|
94
|
+
- **_breakpoints.scss** - Breakpoints: 375px (`$small`), 768px (`$medium`), 1200px (`$large`)
|
|
95
|
+
- **breakpoints.ts** - Same values for TypeScript/`matchMedia` consumers; `tests/breakpoints.spec.ts` fails if they drift apart
|
|
95
96
|
- **_depth.scss** - Z-index scale
|
|
96
97
|
- **_mixins.scss** - Reusable SCSS utilities
|
|
97
98
|
|
package/package.json
CHANGED
package/src/atoms/Input.scss
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
-webkit-appearance: none;
|
|
29
29
|
-moz-appearance: none;
|
|
30
30
|
appearance: none;
|
|
31
|
-
@include mixins.icon-color(var(--primary-color-600));
|
|
32
31
|
|
|
33
32
|
&:focus-visible {
|
|
34
33
|
outline: none;
|
|
@@ -38,6 +37,13 @@
|
|
|
38
37
|
border-left: 1px solid var(--neutral-color-400);
|
|
39
38
|
color: var(--neutral-color-400);
|
|
40
39
|
cursor: default;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.input-with-select .input-container .input-suffix .select-suffix-trigger {
|
|
44
|
+
@include mixins.icon-color(var(--primary-color-600));
|
|
45
|
+
|
|
46
|
+
&:disabled {
|
|
41
47
|
@include mixins.icon-color(var(--neutral-color-400));
|
|
42
48
|
}
|
|
43
49
|
}
|
|
@@ -4,6 +4,10 @@ import { Meta } from "@storybook/addon-docs/blocks";
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
+
## 1.3.0
|
|
8
|
+
|
|
9
|
+
* Add `breakpoints` TypeScript export in `settings/breakpoints.ts`, so JS consumers can read the same values as `_breakpoints.scss` (`matchMedia`, layout logic) instead of hardcoding them. Both files are kept in sync by a test
|
|
10
|
+
|
|
7
11
|
## 1.2.32
|
|
8
12
|
|
|
9
13
|
* Add InputWithSelect component
|
|
@@ -9,7 +9,7 @@ const meta = {
|
|
|
9
9
|
description: {
|
|
10
10
|
component:
|
|
11
11
|
'<h2>Usage guidelines</h2>' +
|
|
12
|
-
'<p>The InputWithSelect component is used when the value the user types needs a unit or symbol attached to it, such as a
|
|
12
|
+
'<p>The InputWithSelect component is used when the value the user types needs a unit or symbol attached to it, such as a percentage or a measurement. It combines an input field with a compact select fused into the same field, placed as a suffix.</p>' +
|
|
13
13
|
'<ul>' +
|
|
14
14
|
' <li>Use when the unit is closely tied to the value and only a short, fixed list of symbols applies (e.g. %, kg, m²)</li>' +
|
|
15
15
|
' <li>Keep the list of options short, these are not meant to be searched</li>' +
|
|
@@ -61,24 +61,25 @@ type Story = StoryObj<typeof meta>
|
|
|
61
61
|
|
|
62
62
|
export const Primary: Story = {
|
|
63
63
|
args: {
|
|
64
|
-
label: '
|
|
65
|
-
name: '
|
|
64
|
+
label: 'Weight',
|
|
65
|
+
name: 'weight',
|
|
66
66
|
type: 'number',
|
|
67
67
|
defaultValue: 10,
|
|
68
|
-
helpText: '
|
|
69
|
-
selectAccessibilityLabel: 'Select
|
|
68
|
+
helpText: 'This text can help you',
|
|
69
|
+
selectAccessibilityLabel: 'Select weight unit',
|
|
70
70
|
options: [
|
|
71
|
-
{ id: '
|
|
72
|
-
{ id: '
|
|
71
|
+
{ id: 'kg', label: 'kg' },
|
|
72
|
+
{ id: 'g', label: 'g' },
|
|
73
|
+
{ id: 'lb', label: 'lb' },
|
|
73
74
|
],
|
|
74
|
-
id: '
|
|
75
|
+
id: 'weight',
|
|
75
76
|
},
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
export const WithErrors: Story = {
|
|
79
80
|
args: {
|
|
80
81
|
...Primary.args,
|
|
81
|
-
errors: ['
|
|
82
|
+
errors: ['Weight must be greater than 0'],
|
|
82
83
|
},
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -4,8 +4,8 @@ import React from 'react'
|
|
|
4
4
|
import { InputWithSelect } from '../src/atoms/InputWithSelect'
|
|
5
5
|
|
|
6
6
|
const options = [
|
|
7
|
-
{ id: '
|
|
8
|
-
{ id: '
|
|
7
|
+
{ id: 'percentage', label: '%' },
|
|
8
|
+
{ id: 'kilogram', label: 'kg' },
|
|
9
9
|
]
|
|
10
10
|
|
|
11
11
|
describe('InputWithSelect', () => {
|
|
@@ -45,7 +45,7 @@ describe('InputWithSelect', () => {
|
|
|
45
45
|
|
|
46
46
|
await user.click(screen.getByRole('option', { name: 'kg' }))
|
|
47
47
|
|
|
48
|
-
expect(handleSelectChange).toHaveBeenCalledWith('
|
|
48
|
+
expect(handleSelectChange).toHaveBeenCalledWith('kilogram')
|
|
49
49
|
expect(
|
|
50
50
|
screen.getByRole('combobox', { name: 'Select unit: kg' }),
|
|
51
51
|
).toHaveTextContent('kg')
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import { breakpoints } from '../src/settings/breakpoints'
|
|
4
|
+
|
|
5
|
+
function parseScssBreakpoints(): Record<string, number> {
|
|
6
|
+
const scss = readFileSync(
|
|
7
|
+
join(__dirname, '../src/settings/_breakpoints.scss'),
|
|
8
|
+
'utf8',
|
|
9
|
+
)
|
|
10
|
+
return Object.fromEntries(
|
|
11
|
+
[...scss.matchAll(/^\$([\w-]+):\s*(\d+)px;/gm)].map(([, name, value]) => [
|
|
12
|
+
name,
|
|
13
|
+
Number(value),
|
|
14
|
+
]),
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('breakpoints', () => {
|
|
19
|
+
it('keeps the TypeScript and SCSS definitions in sync', () => {
|
|
20
|
+
expect({ ...breakpoints }).toEqual(parseScssBreakpoints())
|
|
21
|
+
})
|
|
22
|
+
})
|