agroptima-design-system 0.27.7 → 0.27.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "0.27.7",
3
+ "version": "0.27.8",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -183,6 +183,10 @@
183
183
  justify-content: flex-start;
184
184
  align-items: center;
185
185
  flex: 2;
186
+
187
+ .checkbox-group {
188
+ margin-right: config.$space-1x;
189
+ }
186
190
  }
187
191
 
188
192
  td {
@@ -198,10 +202,6 @@
198
202
  justify-content: center;
199
203
  }
200
204
 
201
- td:has(.badge) {
202
- gap: config.$space-2x;
203
- }
204
-
205
205
  .alignment-right {
206
206
  justify-content: flex-end !important;
207
207
  }
@@ -44,5 +44,12 @@
44
44
  no-repeat;
45
45
  }
46
46
  }
47
+
48
+ &.indeterminate {
49
+ .checkbox:checked {
50
+ background: url('../icons/checkbox-indeterminate-active.svg') left top
51
+ no-repeat;
52
+ }
53
+ }
47
54
  }
48
55
  }
@@ -9,6 +9,7 @@ export interface CheckboxProps extends React.ComponentPropsWithoutRef<'input'> {
9
9
  hideLabel?: boolean
10
10
  variant?: Variant
11
11
  id?: string
12
+ indeterminate?: boolean
12
13
  }
13
14
 
14
15
  export function Checkbox({
@@ -18,6 +19,7 @@ export function Checkbox({
18
19
  disabled,
19
20
  variant = 'primary',
20
21
  id,
22
+ indeterminate = false,
21
23
  name,
22
24
  className,
23
25
  ...props
@@ -28,6 +30,7 @@ export function Checkbox({
28
30
  <div
29
31
  className={classNames('checkbox-group', variant, className, {
30
32
  disabled: disabled,
33
+ indeterminate: indeterminate,
31
34
  })}
32
35
  >
33
36
  <input
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M0 2a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2Z" fill="#eb004dff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18 1H2a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1ZM2 0a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2Z" fill="#eb004dff"/><path d="M18 10.8H2V8.4h16v2.4Z" fill="#fff"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M0 2a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2Z" fill="#161C26"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18 1H2a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1ZM2 0a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2Z" fill="#161C26"/><path d="M18 10.8H2V8.4h16v2.4Z" fill="#fff"/></svg>
@@ -9,6 +9,7 @@ import Calendar from './calendar.svg'
9
9
  import Check from './check.svg'
10
10
  import CheckboxActive from './checkbox-active.svg'
11
11
  import CheckboxInactive from './checkbox-inactive.svg'
12
+ import CheckboxIndeterminate from './checkbox-indeterminate.svg'
12
13
  import ChangePassword from './change-password.svg'
13
14
  import Client from './client.svg'
14
15
  import Close from './close.svg'
@@ -58,6 +59,7 @@ export {
58
59
  Check,
59
60
  CheckboxActive,
60
61
  CheckboxInactive,
62
+ CheckboxIndeterminate,
61
63
  Client,
62
64
  Close,
63
65
  Comment,
@@ -10,6 +10,7 @@ import {
10
10
  } from '../atoms/CardsTable'
11
11
  import { IconButton } from '../atoms/Button'
12
12
  import { Badge } from '../atoms/Badge'
13
+ import { Checkbox } from '@/atoms/Checkbox'
13
14
 
14
15
  const figmaPrimaryDesign = {
15
16
  design: {
@@ -40,7 +41,17 @@ export const Primary = {
40
41
  <CardsTable withTitle {...args}>
41
42
  <CardsTableHead>
42
43
  <CardsTableRow>
43
- <CardsTableHeader>Game title</CardsTableHeader>
44
+ <CardsTableHeader>
45
+ <Checkbox
46
+ label="Select all table rows"
47
+ hideLabel
48
+ id="checkbox-select-all"
49
+ indeterminate
50
+ checked
51
+ variant="primary"
52
+ />
53
+ <span>Game title</span>
54
+ </CardsTableHeader>
44
55
  <CardsTableHeader>Company address</CardsTableHeader>
45
56
  <CardsTableHeader>Customer service email</CardsTableHeader>
46
57
  <CardsTableHeader>Price</CardsTableHeader>
@@ -50,6 +61,11 @@ export const Primary = {
50
61
  <CardsTableBody>
51
62
  <CardsTableRow>
52
63
  <CardsTableCell titleWithActions={3}>
64
+ <Checkbox
65
+ accessibilityLabel="Select all table rows"
66
+ id="checkbox-select-all"
67
+ variant="primary"
68
+ />
53
69
  <span>Zone of the Enders: The 2nd Runner</span>
54
70
  <Badge
55
71
  accessibilityLabel="Game is bought"
@@ -83,7 +99,14 @@ export const Primary = {
83
99
  </CardsTableRow>
84
100
 
85
101
  <CardsTableRow isDisabled>
86
- <CardsTableCell titleWithActions={2}>The Witcher 3</CardsTableCell>
102
+ <CardsTableCell titleWithActions={2}>
103
+ <Checkbox
104
+ accessibilityLabel="Select all table rows"
105
+ id="checkbox-select-all"
106
+ variant="primary"
107
+ />
108
+ <span>The Witcher 3</span>
109
+ </CardsTableCell>
87
110
  <CardsTableCell>
88
111
  CD PROJEKT S.A. ul. Jagiellońska 74 03-301 Warszawa Poland
89
112
  </CardsTableCell>
@@ -104,7 +127,14 @@ export const Primary = {
104
127
  </CardsTableRow>
105
128
 
106
129
  <CardsTableRow isActive onClick={() => alert('Click')}>
107
- <CardsTableCell titleWithActions={1}>Tekken 8</CardsTableCell>
130
+ <CardsTableCell titleWithActions={1}>
131
+ <Checkbox
132
+ accessibilityLabel="Select all table rows"
133
+ id="checkbox-select-all"
134
+ variant="primary"
135
+ />
136
+ <span>Tekken 8</span>
137
+ </CardsTableCell>
108
138
  <CardsTableCell>
109
139
  Bandai Namco Studios Inc. ; Address: 2-37-25 Eitai, Koto-ku, Tokyo
110
140
  135-0034, Japan
@@ -121,6 +151,11 @@ export const Primary = {
121
151
  </CardsTableRow>
122
152
  <CardsTableRow>
123
153
  <CardsTableCell titleWithActions={4}>
154
+ <Checkbox
155
+ accessibilityLabel="Select all table rows"
156
+ id="checkbox-select-all"
157
+ variant="primary"
158
+ />
124
159
  <span>Metal Gear Solid 5: The Phantom Pain</span>
125
160
  <Badge
126
161
  accessibilityLabel="Game is bought"
@@ -159,6 +194,11 @@ export const Primary = {
159
194
  </CardsTableRow>
160
195
  <CardsTableRow>
161
196
  <CardsTableCell titleWithActions={5}>
197
+ <Checkbox
198
+ accessibilityLabel="Select all table rows"
199
+ id="checkbox-select-all"
200
+ variant="primary"
201
+ />
162
202
  <span>Silent Hill</span>
163
203
  </CardsTableCell>
164
204
  <CardsTableCell>
@@ -4,6 +4,10 @@ import { Meta } from "@storybook/blocks";
4
4
 
5
5
  # Changelog
6
6
 
7
+ # 0.27.8
8
+
9
+ * Add indeterminate property and related styles to Checkbox component
10
+
7
11
  # 0.27.6
8
12
 
9
13
  * Add AlertContiner component
@@ -56,3 +56,15 @@ export const PrimaryWithoutLabel: Story = {
56
56
  },
57
57
  parameters: figmaPrimaryDesign,
58
58
  }
59
+
60
+ export const Indeterminate: Story = {
61
+ args: {
62
+ accessibilityLabel: 'Marks if the user likes videogames',
63
+ variant: 'primary',
64
+ disabled: false,
65
+ label: 'Do you like videogames?',
66
+ id: 'checkbox-videogames-preference',
67
+ indeterminate: true,
68
+ },
69
+ parameters: figmaPrimaryDesign,
70
+ }
@@ -18,4 +18,24 @@ describe('Checkbox', () => {
18
18
  expect(getByRole('checkbox')).toHaveClass('checkbox')
19
19
  expect(getByText(/Do you like videogames/i)).toBeInTheDocument()
20
20
  })
21
+
22
+ it.each(variants)(
23
+ 'renders indeterminate variant with label and expected styles',
24
+ (variant) => {
25
+ const { getByRole, getAllByRole, getByText } = render(
26
+ <Checkbox
27
+ accessibilityLabel="Marks if the user likes videogames"
28
+ id="checkbox-videogames-preference"
29
+ label="Do you like videogames?"
30
+ variant="primary"
31
+ indeterminate
32
+ />,
33
+ )
34
+ expect(getAllByRole('generic')[1]).toHaveClass(
35
+ `checkbox-group ${variant} indeterminate`,
36
+ )
37
+ expect(getByRole('checkbox')).toHaveClass('checkbox')
38
+ expect(getByText(/Do you like videogames/i)).toBeInTheDocument()
39
+ },
40
+ )
21
41
  })