agroptima-design-system 0.17.1-beta.13 → 0.17.1-beta.2

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.17.1-beta.13",
3
+ "version": "0.17.1-beta.2",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -116,7 +116,6 @@
116
116
  }
117
117
 
118
118
  tr {
119
- border: 1px solid transparent;
120
119
  td {
121
120
  @include typography.cards-table-list-text;
122
121
  overflow: hidden;
@@ -138,12 +137,6 @@
138
137
  @include typography.cards-table-list-disabled-text;
139
138
  }
140
139
  }
141
- tr.active {
142
- border-color: color_alias.$primary-color-1000;
143
- }
144
- tr.action {
145
- cursor: default;
146
- }
147
140
  }
148
141
 
149
142
  // Desktop
@@ -1,29 +1,19 @@
1
1
  import React from 'react'
2
2
  import './CardsTable.scss'
3
- import { classNames } from '../../utils/classNames'
4
3
 
5
4
  export interface CardsTableRowProps
6
5
  extends React.ComponentPropsWithoutRef<'tr'> {
7
6
  isDisabled?: boolean
8
- isActive?: boolean
9
7
  }
10
8
 
11
9
  export function CardsTableRow({
12
- isDisabled: disabled = false,
13
- isActive: active = false,
10
+ isDisabled = false,
14
11
  children,
15
12
  ...props
16
13
  }: CardsTableRowProps): React.JSX.Element {
14
+ const disabledClass = isDisabled ? 'disabled' : ''
17
15
  return (
18
- <tr
19
- role="row"
20
- className={classNames('row', {
21
- disabled,
22
- active,
23
- action: Boolean(props.onClick),
24
- })}
25
- {...props}
26
- >
16
+ <tr role="row" className={`row ${disabledClass}`} {...props}>
27
17
  {children}
28
18
  </tr>
29
19
  )
@@ -2,62 +2,47 @@ import React from 'react'
2
2
  import { classNames } from '../utils/classNames'
3
3
  import './QuantitySelector.scss'
4
4
  import { Input, InputProps } from './Input'
5
- import { Button, ButtonProps } from './Button'
5
+ import { IconButton } from './Button'
6
6
 
7
7
  export type Variant = 'primary'
8
8
 
9
- export interface QuantitySelectorProps extends InputProps {
9
+ export interface QuantitySelectorProps
10
+ extends React.ComponentPropsWithoutRef<'div'> {
10
11
  label: string
11
- accessibilityLabel?: string
12
12
  hideLabel?: boolean
13
- id?: string
14
13
  variant?: Variant
14
+ quantityInput: InputProps
15
15
  onDecrement: () => void
16
16
  onIncrement: () => void
17
17
  }
18
18
 
19
19
  export function QuantitySelector({
20
- id,
21
- onDecrement,
22
- onIncrement,
20
+ quantityInput,
23
21
  label,
24
- accessibilityLabel,
25
22
  className,
26
23
  hideLabel = false,
27
24
  variant = 'primary',
25
+ onDecrement,
26
+ onIncrement,
28
27
  ...props
29
28
  }: QuantitySelectorProps): React.JSX.Element {
30
- const cssClasses = classNames('quantity-selector', className)
29
+ const cssClasses = classNames('quantity-selector-group', variant, className)
31
30
 
32
31
  return (
33
- <div className={`quantity-selector-group ${variant}`} {...props}>
34
- {!hideLabel && (
35
- <label className="quantity-selector-label" htmlFor={id}>
36
- {label}
37
- </label>
38
- )}
39
- <div className={cssClasses}>
40
- <Button
41
- label=""
42
- accessibilityLabel="-"
43
- type="button"
44
- leftIcon="Minus"
32
+ <div className={cssClasses} {...props}>
33
+ {!hideLabel && <label className="quantity-selector-label">{label}</label>}
34
+ <div className="quantity-selector">
35
+ <IconButton
36
+ icon="Minus"
37
+ accessibilityLabel="decrement"
45
38
  className="decrement-button"
46
39
  onClick={onDecrement}
47
40
  />
48
- <Input
49
- id={id}
50
- label={label}
51
- accessibilityLabel={accessibilityLabel}
52
- {...props}
53
- hideLabel={true}
54
- />
55
- <Button
56
- label=""
57
- accessibilityLabel="+"
58
- leftIcon="Add"
59
- type="button"
60
- className="increment-button"
41
+ <Input {...quantityInput} label={label} />
42
+ <IconButton
43
+ icon="Add"
44
+ accessibilityLabel="decrement"
45
+ className="decrement-button"
61
46
  onClick={onIncrement}
62
47
  />
63
48
  </div>
@@ -1,13 +1,6 @@
1
1
  import React from 'react'
2
2
 
3
- import {
4
- CardsTable,
5
- CardsTableHead,
6
- CardsTableHeader,
7
- CardsTableRow,
8
- CardsTableBody,
9
- CardsTableCell,
10
- } from '../atoms/CardsTable'
3
+ import { CardsTable, CardsTableHead, CardsTableHeader, CardsTableRow, CardsTableBody, CardsTableCell } from '../atoms/CardsTable'
11
4
  import { IconButton } from '../atoms/Button'
12
5
  import { Badge } from '../atoms/Badge'
13
6
 
@@ -74,7 +67,7 @@ export const Primary = {
74
67
  </CardsTableCell>
75
68
  </CardsTableRow>
76
69
 
77
- <CardsTableRow isDisabled>
70
+ <CardsTableRow>
78
71
  <CardsTableCell titleWithActions={2}>The Witcher 3</CardsTableCell>
79
72
  <CardsTableCell>
80
73
  CD PROJEKT S.A. ul. Jagiellońska 74 03-301 Warszawa Poland
@@ -95,7 +88,7 @@ export const Primary = {
95
88
  </CardsTableCell>
96
89
  </CardsTableRow>
97
90
 
98
- <CardsTableRow isActive onClick={() => alert('Click')}>
91
+ <CardsTableRow>
99
92
  <CardsTableCell titleWithActions={1}>Tekken 8</CardsTableCell>
100
93
  <CardsTableCell>
101
94
  Bandai Namco Studios Inc. ; Address: 2-37-25 Eitai, Koto-ku, Tokyo
@@ -51,18 +51,21 @@ export const Primary: Story = {
51
51
  args: {
52
52
  label: 'Quantity',
53
53
  accessibilityLabel: 'Quantity of items to wishlist',
54
- id: 'quantity',
55
- hideLabel: true,
56
- name: 'quantity',
57
- value: 1,
58
- onChange: () => alert('onChange'),
59
- type: 'number',
60
- max: 10,
61
- step: 0.0001,
62
- min: 1,
63
- required: true,
54
+ id: 'quantity-selector',
64
55
  onDecrement: () => alert('decrement'),
65
56
  onIncrement: () => alert('increment'),
57
+ quantityInput: {
58
+ label: 'Quantity input',
59
+ hideLabel: true,
60
+ name: 'quantity',
61
+ value: 1,
62
+ onChange: () => alert('onChange'),
63
+ type: 'number',
64
+ max: 10,
65
+ step: 0.0001,
66
+ min: 1,
67
+ required: true,
68
+ },
66
69
  },
67
70
  parameters: figmaPrimaryDesign,
68
71
  }
@@ -71,18 +74,32 @@ export const Disabled: Story = {
71
74
  args: {
72
75
  label: 'Quantity',
73
76
  accessibilityLabel: 'Quantity of items to wishlist',
74
- id: 'quantity',
75
- name: 'quantity',
76
- value: 1,
77
- onChange: () => alert('onChange'),
78
- type: 'number',
79
- max: 10,
80
- step: 0.0001,
81
- min: 1,
82
- required: true,
83
- disabled: true,
84
- onDecrement: () => alert('decrement'),
85
- onIncrement: () => alert('increment'),
77
+ id: 'quantity-selector',
78
+ decrementButton: {
79
+ label: '',
80
+ leftIcon: 'Minus',
81
+ onClick: () => alert('decrement'),
82
+ disabled: true,
83
+ },
84
+ incrementButton: {
85
+ label: '',
86
+ leftIcon: 'Add',
87
+ onClick: () => alert('increment'),
88
+ disabled: true,
89
+ },
90
+ quantityInput: {
91
+ label: 'Quantity input',
92
+ hideLabel: true,
93
+ name: 'quantity',
94
+ value: 1,
95
+ onChange: () => alert('onChange'),
96
+ type: 'number',
97
+ max: 10,
98
+ step: 0.0001,
99
+ min: 1,
100
+ required: true,
101
+ disabled: true,
102
+ },
86
103
  },
87
104
  parameters: figmaPrimaryDesign,
88
105
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { render } from '@testing-library/react'
2
+ import { screen, render } from '@testing-library/react'
3
3
  import { QuantitySelector } from '@/atoms/QuantitySelector'
4
4
 
5
5
  describe('QuantitySelector', () => {
@@ -8,18 +8,27 @@ describe('QuantitySelector', () => {
8
8
  <QuantitySelector
9
9
  label="Quantity"
10
10
  accessibilityLabel="Quantity of items to wishlist"
11
- id="quantity"
12
- onDecrement={() => alert('decrement')}
13
- onIncrement={() => alert('increment')}
14
- hideLabel={true}
15
- name="quantity"
16
- value={1}
17
- onChange={() => alert('onChange')}
18
- type="number"
19
- max={10}
20
- step={0.0001}
21
- min={1}
22
- required={true}
11
+ id="quantity-selector"
12
+ decrementButton={{
13
+ label: '-',
14
+ onClick: () => alert('decrement'),
15
+ }}
16
+ incrementButton={{
17
+ label: '+',
18
+ onClick: () => alert('increment'),
19
+ }}
20
+ quantityInput={{
21
+ label: 'Quantity input',
22
+ hideLabel: true,
23
+ name: 'quantity',
24
+ value: 1,
25
+ onChange: () => alert('onChange'),
26
+ type: 'number',
27
+ max: 10,
28
+ step: 0.0001,
29
+ min: 1,
30
+ required: true,
31
+ }}
23
32
  />,
24
33
  )
25
34