agroptima-design-system 0.5.0 → 0.6.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.5.0",
3
+ "version": "0.6.0",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -0,0 +1,71 @@
1
+ @use '../settings/color_alias';
2
+ @use '../settings/typography';
3
+ @use '../settings/config';
4
+
5
+ .checkbox-group {
6
+ .checkbox-label-container {
7
+ display: flex;
8
+ justify-content: flex-start;
9
+ align-items: center;
10
+ gap: config.$space-1x;
11
+
12
+ .background-icon {
13
+ width: config.$icon-size-4x;
14
+ height: config.$icon-size-4x;
15
+ }
16
+
17
+ .label {
18
+ @include typography.checkbox-label;
19
+ }
20
+ }
21
+
22
+ &.primary {
23
+ input[type='checkbox'] {
24
+ display: none;
25
+ }
26
+
27
+ input[type='checkbox'] + .checkbox-label-container .background-icon {
28
+ background: url('../icons/checkbox-primary-inactive.svg') left top
29
+ no-repeat;
30
+ }
31
+
32
+ input[type='checkbox']:checked
33
+ + .checkbox-label-container
34
+ .background-icon {
35
+ background: url('../icons/checkbox-primary-active.svg') left top no-repeat;
36
+ }
37
+
38
+ // Disabled
39
+ input[type='checkbox']
40
+ + .checkbox-label-container.disabled
41
+ .background-icon {
42
+ background: url('../icons/checkbox-disabled-inactive.svg') left top
43
+ no-repeat;
44
+ }
45
+
46
+ input[type='checkbox']:checked
47
+ + .checkbox-label-container.disabled
48
+ .background-icon {
49
+ background: url('../icons/checkbox-disabled-active.svg') left top
50
+ no-repeat;
51
+ }
52
+
53
+ .checkbox-label-container {
54
+ &.disabled {
55
+ .label {
56
+ @include typography.checkbox-disabled-label;
57
+ }
58
+ }
59
+ }
60
+
61
+ // Hover
62
+ &:hover {
63
+ input[type='checkbox']:not(:checked)
64
+ + .checkbox-label-container:not(.disabled)
65
+ .background-icon {
66
+ background: url('../icons/checkbox-primary-hover-inactive.svg') left top
67
+ no-repeat;
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,45 @@
1
+ import './Checkbox.scss'
2
+
3
+ export type Variant = 'primary'
4
+
5
+ export interface CheckboxProps extends React.ComponentPropsWithoutRef<'input'> {
6
+ label?: string
7
+ hideLabel?: boolean
8
+ variant?: Variant
9
+ id: string
10
+ accessibilityLabel: string
11
+ }
12
+
13
+ export function Checkbox({
14
+ accessibilityLabel,
15
+ label,
16
+ hideLabel,
17
+ disabled,
18
+ variant = 'primary',
19
+ id,
20
+ ...props
21
+ }: CheckboxProps) {
22
+ const disabledClass = disabled ? 'disabled' : ''
23
+ const cssClasses = ['checkbox', variant].join(' ')
24
+
25
+ return (
26
+ <div className={`checkbox-group ${variant}`}>
27
+ <input
28
+ id={id}
29
+ type="checkbox"
30
+ className={cssClasses}
31
+ disabled={disabled}
32
+ aria-label={accessibilityLabel}
33
+ {...props}
34
+ />
35
+
36
+ <label
37
+ className={`checkbox-label-container ${disabledClass}`}
38
+ htmlFor={id}
39
+ >
40
+ <span className="background-icon"></span>
41
+ {!hideLabel && <span className="label">{label}</span>}
42
+ </label>
43
+ </div>
44
+ )
45
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path class="border" 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="#F3F3F3"/><path class="background" 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="#9B9B9B"/><path class="check" d="m7.085 13.699-3.793-3.98L2 11.063 7.085 16.4 18 4.946 16.718 3.6 7.085 13.699Z" fill="#9B9B9B"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path class="background" 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="#F3F3F3"/><path class="border" 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="#9B9B9B"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path class="border" 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="#A95782"/><path class="background" 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="#A95782"/><path class="check" d="m7.085 13.699-3.793-3.98L2 11.063 7.085 16.4 18 4.946 16.718 3.6 7.085 13.699Z" fill="#fff"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path class="background" 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="#fff"/><path class="border" 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="#A95782"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path class="background" 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="#fff"/><path class="border" 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="#727272"/></svg>
@@ -68,6 +68,24 @@ $font-primary: $font-base-stretch $text-base-style $font-base-weight #{$text-bas
68
68
  line-height: 0.775rem;
69
69
  }
70
70
 
71
+ @mixin checkbox-label {
72
+ font-style: $text-base-style;
73
+ font-variant: $text-base-style;
74
+ font-weight: 400;
75
+ font-family: $font-base-family;
76
+ font-size: 1rem;
77
+ color: color_alias.$neutral-color-1000;
78
+ }
79
+
80
+ @mixin checkbox-disabled-label {
81
+ font-style: $text-base-style;
82
+ font-variant: $text-base-style;
83
+ font-weight: 400;
84
+ font-family: $font-base-family;
85
+ font-size: 1rem;
86
+ color: color_alias.$neutral-color-400;
87
+ }
88
+
71
89
  @mixin cards-table-list-header {
72
90
  font-style: $text-base-style;
73
91
  font-variant: $text-base-style;
@@ -3,6 +3,10 @@ import { Meta } from "@storybook/addon-docs";
3
3
  <Meta title="Changelog" />
4
4
  # Changelog
5
5
 
6
+ ## 0.6.0
7
+
8
+ Checkbox component is added to Storybook.
9
+
6
10
  ## 0.5.0
7
11
 
8
12
  - IconButton component is added to Storybook.
@@ -0,0 +1,58 @@
1
+ import { StoryObj } from '@storybook/react'
2
+ import { Checkbox } from '../atoms/Checkbox'
3
+
4
+ const meta = {
5
+ title: 'Design System/Atoms/Checkbox',
6
+ component: Checkbox,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ accessibilityLabel: {
10
+ description: 'Accessible name & description of the element',
11
+ },
12
+ variant: {
13
+ description: 'Variant used from a list of values',
14
+ },
15
+ disabled: {
16
+ description: 'Is the component in disabled state?',
17
+ },
18
+ label: {
19
+ description: 'Label for the component',
20
+ },
21
+ id: {
22
+ description: 'Value needed for the label relation',
23
+ },
24
+ },
25
+ }
26
+
27
+ const figmaPrimaryDesign = {
28
+ design: {
29
+ type: 'figma',
30
+ url: 'https://www.figma.com/file/DN2ova21vWqCRvPspBXgI1/Design-System?type=design&node-id=521-104&mode=dev',
31
+ },
32
+ }
33
+
34
+ export default meta
35
+ type Story = StoryObj<typeof meta>
36
+
37
+ export const Primary: Story = {
38
+ args: {
39
+ accessibilityLabel: 'Marks if the user likes videogames',
40
+ variant: 'primary',
41
+ disabled: false,
42
+ label: 'Do you like videogames?',
43
+ id: 'checkbox-videogames-preference',
44
+ },
45
+ parameters: figmaPrimaryDesign,
46
+ }
47
+
48
+ export const PrimaryWithoutLabel: Story = {
49
+ args: {
50
+ accessibilityLabel: 'Marks if the user likes videogames',
51
+ variant: 'primary',
52
+ disabled: false,
53
+ label: 'Do you like videogames?',
54
+ id: 'checkbox-videogames-preference',
55
+ hideLabel: true,
56
+ },
57
+ parameters: figmaPrimaryDesign,
58
+ }