agroptima-design-system 0.26.0-beta.8 → 0.26.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.26.0-beta.8",
3
+ "version": "0.26.0",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -17,7 +17,6 @@
17
17
  "dependencies": {
18
18
  "@storybook/addon-designs": "^8.0.3",
19
19
  "@storybook/addon-viewport": "^8.3.2",
20
- "agroptima-design-system": "^0.26.0-beta.3",
21
20
  "next": "^14.0.3",
22
21
  "react": "^18.2.0",
23
22
  "react-dom": "^18.2.0",
@@ -2,6 +2,7 @@ import NextLink from 'next/link'
2
2
 
3
3
  interface CommonProps {
4
4
  disabled?: boolean
5
+ visible?: boolean
5
6
  }
6
7
 
7
8
  type HtmlButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>
@@ -15,7 +16,12 @@ export type BaseButtonProps =
15
16
  const hasHref = (props: HtmlButtonProps | AnchorProps): props is AnchorProps =>
16
17
  'href' in props
17
18
 
18
- export function BaseButton({ children, ...props }: BaseButtonProps) {
19
+ export function BaseButton({
20
+ children,
21
+ visible = true,
22
+ ...props
23
+ }: BaseButtonProps) {
24
+ if (!visible) return null
19
25
  if (hasHref(props)) {
20
26
  return (
21
27
  <NextLink href={props.href || ''} {...props}>
@@ -11,7 +11,6 @@ interface CustomProps {
11
11
  icon: IconType
12
12
  variant?: Variant
13
13
  disabled?: boolean
14
- visible?: boolean
15
14
  accessibilityLabel: string
16
15
  }
17
16
 
@@ -21,12 +20,9 @@ export function IconButton({
21
20
  accessibilityLabel,
22
21
  icon,
23
22
  disabled,
24
- visible = true,
25
23
  variant = 'primary',
26
24
  ...props
27
25
  }: IconButtonProps) {
28
- if (!visible) return null
29
-
30
26
  return (
31
27
  <BaseButton
32
28
  disabled={disabled}
@@ -3,19 +3,17 @@ import './CheckableTag.scss'
3
3
 
4
4
  export type Variant = 'primary'
5
5
 
6
- type CheckableTagPropsWithoutOnChangeOnSelect = Omit<
6
+ type CheckableTagPropsWithoutOnSelect = Omit<
7
7
  React.ComponentPropsWithoutRef<'span'>,
8
- 'onChange' | 'onSelect'
8
+ 'onSelect'
9
9
  >
10
10
 
11
- export interface CheckableTagProps
12
- extends CheckableTagPropsWithoutOnChangeOnSelect {
11
+ export interface CheckableTagProps extends CheckableTagPropsWithoutOnSelect {
13
12
  variant?: Variant
14
13
  isDisabled?: boolean
15
14
  isChecked?: boolean
16
15
  label: string
17
16
  onSelect: (label: string) => void
18
- onChange: (checked: boolean) => void
19
17
  }
20
18
 
21
19
  export function CheckableTag({
@@ -25,7 +23,6 @@ export function CheckableTag({
25
23
  label,
26
24
  isChecked = false,
27
25
  onSelect,
28
- onChange,
29
26
  ...props
30
27
  }: CheckableTagProps): React.JSX.Element {
31
28
  const cssClasses = classNames('checkable-tag', variant, className, {
@@ -33,11 +30,6 @@ export function CheckableTag({
33
30
  checked: isChecked,
34
31
  })
35
32
 
36
- function handleClick() {
37
- onChange(!isChecked)
38
- onSelect(label)
39
- }
40
-
41
33
  return (
42
34
  <span
43
35
  className={cssClasses}
@@ -45,7 +37,7 @@ export function CheckableTag({
45
37
  aria-checked={false}
46
38
  tabIndex={0}
47
39
  aria-label={props['aria-label']}
48
- onClick={handleClick}
40
+ onClick={() => onSelect(label)}
49
41
  {...props}
50
42
  >
51
43
  {label}
@@ -1,4 +1,4 @@
1
- import { CheckableTag } from './CheckableTag'
1
+ import { CheckableTag, type Variant } from './CheckableTag'
2
2
  import { CheckableTagGroup } from './CheckableTagGroup'
3
3
 
4
- export { CheckableTag, CheckableTagGroup }
4
+ export { CheckableTag, CheckableTagGroup, type Variant }
@@ -11,7 +11,7 @@ export interface DrawerProps extends React.ComponentPropsWithoutRef<'div'> {
11
11
  variant?: Variant
12
12
  title: string
13
13
  buttons: ButtonProps[]
14
- onCloseDrawer: () => void
14
+ onClose: () => void
15
15
  }
16
16
 
17
17
  export function Drawer({
@@ -21,7 +21,7 @@ export function Drawer({
21
21
  title,
22
22
  buttons,
23
23
  children,
24
- onCloseDrawer,
24
+ onClose,
25
25
  ...props
26
26
  }: DrawerProps): React.JSX.Element {
27
27
  const cssClasses = classNames('drawer', variant, className)
@@ -40,7 +40,7 @@ export function Drawer({
40
40
  <IconButton
41
41
  icon="Close"
42
42
  accessibilityLabel="Close"
43
- onClick={onCloseDrawer}
43
+ onClick={onClose}
44
44
  />
45
45
  </div>
46
46
  <div className="scroll-area">
@@ -127,7 +127,10 @@
127
127
  }
128
128
  &.file .input-container {
129
129
  padding: 0;
130
- border: none;
130
+ border: transparent;
131
+ &:has(input:focus) {
132
+ border: transparent;
133
+ }
131
134
  input {
132
135
  color: color_alias.$neutral-color-600;
133
136
  &::before {
@@ -48,6 +48,7 @@
48
48
  display: flex;
49
49
  gap: config.$space-2x;
50
50
  align-items: flex-start;
51
+ padding-bottom: config.$space-2x;
51
52
 
52
53
  .icon {
53
54
  margin-top: 4px;
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M18 6.706h-4.571V0H6.57v6.706H2l8 7.823 8-7.823ZM8.857 8.94V2.235h2.286v6.706h1.337L10 11.366 7.52 8.942h1.337ZM2 16.765h16V19H2v-2.235Z" fill="#161C26"/></svg>
@@ -17,6 +17,7 @@ import Delete from './delete.svg'
17
17
  import Done from './done.svg'
18
18
  import DoubleArrowLeft from './double-arrow-left.svg'
19
19
  import DoubleArrowRight from './double-arrow-right.svg'
20
+ import Download from './download.svg'
20
21
  import Edit from './edit.svg'
21
22
  import EditColumns from './edit-columns.svg'
22
23
  import EmptyState from './empty-customize.svg'
@@ -37,6 +38,7 @@ import Settings from './settings.svg'
37
38
  import Show from './show.svg'
38
39
  import ShowOff from './show-off.svg'
39
40
  import Sorter from './sorter.svg'
41
+ import Upload from './upload.svg'
40
42
  import UserMenu from './user-menu.svg'
41
43
  import Warning from './warning.svg'
42
44
  import DeliveryNote from './delivery-note.svg'
@@ -63,6 +65,7 @@ export {
63
65
  Done,
64
66
  DoubleArrowLeft,
65
67
  DoubleArrowRight,
68
+ Download,
66
69
  Edit,
67
70
  EditColumns,
68
71
  EmptyState,
@@ -84,6 +87,7 @@ export {
84
87
  Show,
85
88
  ShowOff,
86
89
  Sorter,
90
+ Upload,
87
91
  UserMenu,
88
92
  Warning,
89
93
  }
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.571 14.53h6.858V7.823H18L10 0 2 7.824h4.571v6.705ZM10 3.162l2.48 2.425h-1.337v6.706H8.857V5.588H7.52L10 3.163ZM2 16.765h16V19H2v-2.235Z" fill="#161C26"/></svg>
@@ -37,6 +37,10 @@ const meta = {
37
37
  description:
38
38
  'If a link is provided, the component will be rendered as NextLink, otherwise as button',
39
39
  },
40
+ visible: {
41
+ description: 'Is the button visible?',
42
+ control: { type: 'boolean', default: true },
43
+ },
40
44
  },
41
45
  }
42
46
 
@@ -11,6 +11,12 @@ import { Meta } from "@storybook/blocks";
11
11
  * Add Dot option to Badge component.
12
12
  * Add Drawer component.
13
13
 
14
+ # 0.25.8
15
+
16
+ * Remove focus style for file Input component
17
+ * Download and Upload icons
18
+ * Add visible prop to buttons
19
+
14
20
  # 0.25.7
15
21
 
16
22
  * Add styles for file Input component
@@ -24,6 +24,9 @@ const meta = {
24
24
  isChecked: {
25
25
  description: 'Is the component checked?',
26
26
  },
27
+ onSelect: {
28
+ description: 'Callback triggered when clicking on an option'
29
+ }
27
30
  },
28
31
  parameters: figmaPrimaryDesign,
29
32
  }
@@ -37,24 +40,21 @@ export const TagGroup = {
37
40
  variant="primary"
38
41
  label="RPG"
39
42
  aria-label="RPG games"
40
- onSelect={() => {}}
41
- onChange={() => {}}
43
+ onSelect={() => alert('click')}
42
44
  isChecked={false}
43
45
  />
44
46
  <CheckableTag
45
47
  variant="primary"
46
48
  label="Sports"
47
49
  aria-label="Sport games"
48
- onSelect={() => {}}
49
- onChange={() => {}}
50
+ onSelect={() => alert('click')}
50
51
  isChecked={false}
51
52
  />
52
53
  <CheckableTag
53
54
  variant="primary"
54
55
  label="Party"
55
56
  aria-label="Party games"
56
- onSelect={() => {}}
57
- onChange={() => {}}
57
+ onSelect={() => alert('click')}
58
58
  isChecked={false}
59
59
  isDisabled={true}
60
60
  />
@@ -62,40 +62,35 @@ export const TagGroup = {
62
62
  variant="primary"
63
63
  label="Survival horror"
64
64
  aria-label="Survival horror games"
65
- onSelect={() => {}}
66
- onChange={() => {}}
65
+ onSelect={() => alert('click')}
67
66
  isChecked={true}
68
67
  />
69
68
  <CheckableTag
70
69
  variant="primary"
71
70
  label="Action"
72
71
  aria-label="Action games"
73
- onSelect={() => {}}
74
- onChange={() => {}}
72
+ onSelect={() => alert('click')}
75
73
  isChecked={false}
76
74
  />
77
75
  <CheckableTag
78
76
  variant="primary"
79
77
  label="Platform"
80
78
  aria-label="Platform games"
81
- onSelect={() => {}}
82
- onChange={() => {}}
79
+ onSelect={() => alert('click')}
83
80
  isChecked={false}
84
81
  />
85
82
  <CheckableTag
86
83
  variant="primary"
87
84
  label="Graphic adventure"
88
85
  aria-label="Graphic adventure games"
89
- onSelect={() => {}}
90
- onChange={() => {}}
86
+ onSelect={() => alert('click')}
91
87
  isChecked={false}
92
88
  />
93
89
  <CheckableTag
94
90
  variant="primary"
95
91
  label="FPS"
96
92
  aria-label="First Person Shooter games"
97
- onSelect={() => {}}
98
- onChange={() => {}}
93
+ onSelect={() => alert('click')}
99
94
  isChecked={false}
100
95
  />
101
96
  </CheckableTagGroup>
@@ -41,7 +41,7 @@ export const Filters = {
41
41
  title="Filters"
42
42
  buttons={[
43
43
  {
44
- label: 'Clean',
44
+ label: 'Clear',
45
45
  variant: 'primary-outlined',
46
46
  onClick: () => alert('click'),
47
47
  },
@@ -1,63 +1,49 @@
1
1
  import React from 'react'
2
- import { screen, render, queryByRole } from '@testing-library/react'
3
- import { Modal } from '@/atoms/Modal'
2
+ import { render } from '@testing-library/react'
3
+ import { Drawer } from '@/atoms/Drawer'
4
+ import { Collapsible } from '@/atoms/Collapsible'
5
+ import { CheckableTag, CheckableTagGroup } from '@/atoms/CheckableTag'
4
6
 
5
- describe('Modal', () => {
6
- const variants = ['info', 'success', 'warning', 'error']
7
- it.each(variants)(
8
- 'renders the %s variant with title and the expected icon and button',
9
- (variant) => {
10
- const title = `${variant} modal`
11
- const content = `${variant} modal content`
12
- const { getByRole, getByText } = render(
13
- <Modal
14
- id={`${variant}-modal`}
15
- title={title}
16
- buttons={[
17
- {
18
- label: 'Done',
19
- },
20
- ]}
21
- >
22
- {content}
23
- </Modal>,
24
- )
25
- expect(getByRole('img')).toHaveClass('info')
26
- expect(getByText(title)).toBeInTheDocument()
27
- expect(getByText(content)).toBeInTheDocument()
28
- expect(getByRole('button')).toHaveTextContent('Done')
29
- expect(getByRole('button')).toHaveClass('primary')
30
- },
31
- )
32
-
33
- it('renders the Delete/Discard variant with title and the expected icon and buttons', () => {
34
- const title = 'Delete modal'
35
- const content = 'Delete modal content'
36
- const { getByRole, getByText } = render(
37
- <Modal
38
- id="discard-modal"
39
- title={title}
40
- variant="discard"
7
+ describe('Drawer', () => {
8
+ it('renders with expected title, content and buttons', () => {
9
+ const { getByLabelText, getByText, getAllByRole } = render(
10
+ <Drawer
11
+ id="videogames-filters"
12
+ title="Filters"
13
+ onClose={jest.fn()}
41
14
  buttons={[
42
15
  {
43
- label: 'Cancel',
44
- variant: 'neutral',
16
+ label: 'Clear',
17
+ variant: 'primary-outlined',
18
+ onClick: () => alert('click'),
45
19
  },
46
20
  {
47
- label: 'Delete',
48
- variant: 'error',
21
+ label: 'Apply',
22
+ onClick: () => alert('click'),
49
23
  },
50
24
  ]}
51
25
  >
52
- {content}
53
- </Modal>,
26
+ <Collapsible noHorizontalPadding open title="Genres">
27
+ <CheckableTagGroup>
28
+ <CheckableTag
29
+ variant="primary"
30
+ label="RPG"
31
+ aria-label="RPG games"
32
+ onSelect={() => {}}
33
+ onChange={() => {}}
34
+ isChecked={false}
35
+ />
36
+ </CheckableTagGroup>
37
+ </Collapsible>
38
+ </Drawer>,
54
39
  )
55
- expect(getByRole('img')).toHaveClass('discard')
56
- expect(getByText(title)).toBeInTheDocument()
57
- expect(getByText(content)).toBeInTheDocument()
58
- expect(screen.getAllByRole('button')[0]).toHaveTextContent('Cancel')
59
- expect(screen.getAllByRole('button')[0]).toHaveClass('neutral')
60
- expect(screen.getAllByRole('button')[1]).toHaveTextContent('Delete')
61
- expect(screen.getAllByRole('button')[1]).toHaveClass('error')
40
+ expect(getByText('Filters')).toBeInTheDocument()
41
+ expect(getByText('RPG')).toBeInTheDocument()
42
+ expect(getByLabelText('Close')).toBeInTheDocument()
43
+ expect(getAllByRole('button')[0]).toHaveClass('icon-button primary')
44
+ expect(getAllByRole('button')[1]).toHaveTextContent('Clear')
45
+ expect(getAllByRole('button')[1]).toHaveClass('primary-outlined')
46
+ expect(getAllByRole('button')[2]).toHaveTextContent('Apply')
47
+ expect(getAllByRole('button')[2]).toHaveClass('primary')
62
48
  })
63
49
  })
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { screen, render, queryByRole } from '@testing-library/react'
2
+ import { screen, render } from '@testing-library/react'
3
3
  import { Modal } from '@/atoms/Modal'
4
4
 
5
5
  describe('Modal', () => {