agroptima-design-system 0.27.7 → 0.27.8-beta.0

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-beta.0",
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,16 @@ export const Primary = {
40
41
  <CardsTable withTitle {...args}>
41
42
  <CardsTableHead>
42
43
  <CardsTableRow>
43
- <CardsTableHeader>Game title</CardsTableHeader>
44
+ <CardsTableHeader>
45
+ <Checkbox
46
+ accessibilityLabel="Select all table rows"
47
+ id="checkbox-select-all"
48
+ indeterminate
49
+ checked
50
+ variant="primary"
51
+ />
52
+ <span>Game title</span>
53
+ </CardsTableHeader>
44
54
  <CardsTableHeader>Company address</CardsTableHeader>
45
55
  <CardsTableHeader>Customer service email</CardsTableHeader>
46
56
  <CardsTableHeader>Price</CardsTableHeader>
@@ -50,6 +60,11 @@ export const Primary = {
50
60
  <CardsTableBody>
51
61
  <CardsTableRow>
52
62
  <CardsTableCell titleWithActions={3}>
63
+ <Checkbox
64
+ accessibilityLabel="Select all table rows"
65
+ id="checkbox-select-all"
66
+ variant="primary"
67
+ />
53
68
  <span>Zone of the Enders: The 2nd Runner</span>
54
69
  <Badge
55
70
  accessibilityLabel="Game is bought"
@@ -83,7 +98,14 @@ export const Primary = {
83
98
  </CardsTableRow>
84
99
 
85
100
  <CardsTableRow isDisabled>
86
- <CardsTableCell titleWithActions={2}>The Witcher 3</CardsTableCell>
101
+ <CardsTableCell titleWithActions={2}>
102
+ <Checkbox
103
+ accessibilityLabel="Select all table rows"
104
+ id="checkbox-select-all"
105
+ variant="primary"
106
+ />
107
+ <span>The Witcher 3</span>
108
+ </CardsTableCell>
87
109
  <CardsTableCell>
88
110
  CD PROJEKT S.A. ul. Jagiellońska 74 03-301 Warszawa Poland
89
111
  </CardsTableCell>
@@ -104,7 +126,14 @@ export const Primary = {
104
126
  </CardsTableRow>
105
127
 
106
128
  <CardsTableRow isActive onClick={() => alert('Click')}>
107
- <CardsTableCell titleWithActions={1}>Tekken 8</CardsTableCell>
129
+ <CardsTableCell titleWithActions={1}>
130
+ <Checkbox
131
+ accessibilityLabel="Select all table rows"
132
+ id="checkbox-select-all"
133
+ variant="primary"
134
+ />
135
+ <span>Tekken 8</span>
136
+ </CardsTableCell>
108
137
  <CardsTableCell>
109
138
  Bandai Namco Studios Inc. ; Address: 2-37-25 Eitai, Koto-ku, Tokyo
110
139
  135-0034, Japan
@@ -121,6 +150,11 @@ export const Primary = {
121
150
  </CardsTableRow>
122
151
  <CardsTableRow>
123
152
  <CardsTableCell titleWithActions={4}>
153
+ <Checkbox
154
+ accessibilityLabel="Select all table rows"
155
+ id="checkbox-select-all"
156
+ variant="primary"
157
+ />
124
158
  <span>Metal Gear Solid 5: The Phantom Pain</span>
125
159
  <Badge
126
160
  accessibilityLabel="Game is bought"
@@ -159,6 +193,11 @@ export const Primary = {
159
193
  </CardsTableRow>
160
194
  <CardsTableRow>
161
195
  <CardsTableCell titleWithActions={5}>
196
+ <Checkbox
197
+ accessibilityLabel="Select all table rows"
198
+ id="checkbox-select-all"
199
+ variant="primary"
200
+ />
162
201
  <span>Silent Hill</span>
163
202
  </CardsTableCell>
164
203
  <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
  })