agroptima-design-system 0.12.0 → 0.13.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 +1 -1
- package/src/atoms/CardMenu/CardMenu.scss +84 -0
- package/src/atoms/CardMenu/CardMenu.tsx +12 -0
- package/src/atoms/CardMenu/CardMenuOption.tsx +50 -0
- package/src/atoms/CardMenu/index.ts +4 -0
- package/src/stories/CardMenu.stories.js +103 -0
- package/src/stories/Changelog.stories.mdx +4 -0
- package/tests/CardMenuOption.spec.tsx +21 -0
package/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
@use '../../settings/color_alias';
|
|
2
|
+
@use '../../settings/typography/content' as typography;
|
|
3
|
+
@use '../../settings/config';
|
|
4
|
+
@use '../../settings/depth';
|
|
5
|
+
|
|
6
|
+
.card-menu-option {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
align-items: flex-start;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
width: 100%;
|
|
12
|
+
padding: config.$space-3x;
|
|
13
|
+
gap: config.$space-3x;
|
|
14
|
+
border-radius: config.$corner-radius-xxs;
|
|
15
|
+
border-bottom: 1px solid color_alias.$neutral-color-200;
|
|
16
|
+
cursor: default;
|
|
17
|
+
|
|
18
|
+
@include typography.body-regular-primary;
|
|
19
|
+
|
|
20
|
+
.icon {
|
|
21
|
+
width: config.$icon-size-4x;
|
|
22
|
+
height: config.$icon-size-4x;
|
|
23
|
+
> svg {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.left {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: config.$space-2x;
|
|
33
|
+
|
|
34
|
+
.title-container {
|
|
35
|
+
display: flex;
|
|
36
|
+
width: 100%;
|
|
37
|
+
gap: config.$space-2x;
|
|
38
|
+
justify-content: flex-start;
|
|
39
|
+
align-items: center;
|
|
40
|
+
flex: 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.content {
|
|
44
|
+
margin: 0;
|
|
45
|
+
text-align: left;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.right {
|
|
50
|
+
margin-top: auto;
|
|
51
|
+
margin-bottom: auto;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.primary {
|
|
55
|
+
background: color_alias.$neutral-white;
|
|
56
|
+
|
|
57
|
+
.icon {
|
|
58
|
+
> svg {
|
|
59
|
+
fill: color_alias.$primary-color-600;
|
|
60
|
+
path {
|
|
61
|
+
fill: color_alias.$primary-color-600;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:not(.disabled):hover {
|
|
67
|
+
background: color_alias.$primary-color-50;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&.disabled {
|
|
71
|
+
background: color_alias.$neutral-color-50;
|
|
72
|
+
@include typography.body-regular-disabled;
|
|
73
|
+
|
|
74
|
+
.icon {
|
|
75
|
+
> svg {
|
|
76
|
+
fill: color_alias.$neutral-color-400;
|
|
77
|
+
path {
|
|
78
|
+
fill: color_alias.$neutral-color-400;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Icon, IconType } from '../Icon'
|
|
2
|
+
import './CardMenu.scss'
|
|
3
|
+
import { classNames } from '../../utils/classNames'
|
|
4
|
+
|
|
5
|
+
export type Variant = 'primary'
|
|
6
|
+
|
|
7
|
+
export interface CardMenuOptionProps
|
|
8
|
+
extends React.ComponentPropsWithoutRef<'div'> {
|
|
9
|
+
id?: string
|
|
10
|
+
variant?: Variant
|
|
11
|
+
icon: IconType
|
|
12
|
+
title: string
|
|
13
|
+
description?: string
|
|
14
|
+
disabled?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function CardMenuOption({
|
|
18
|
+
id,
|
|
19
|
+
variant = 'primary',
|
|
20
|
+
className,
|
|
21
|
+
icon,
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
disabled,
|
|
25
|
+
...props
|
|
26
|
+
}: CardMenuOptionProps): React.JSX.Element {
|
|
27
|
+
const cssClasses = classNames('card-menu-option', variant, className, {
|
|
28
|
+
disabled: disabled,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
role="menuitem"
|
|
34
|
+
className={cssClasses}
|
|
35
|
+
{...props}
|
|
36
|
+
aria-disabled={disabled}
|
|
37
|
+
>
|
|
38
|
+
<div className="left">
|
|
39
|
+
<div className="title-container">
|
|
40
|
+
<Icon name={icon} className={variant} />
|
|
41
|
+
<span className="title">{title}</span>
|
|
42
|
+
</div>
|
|
43
|
+
<p className="content">{description}</p>
|
|
44
|
+
</div>
|
|
45
|
+
<div className="right">
|
|
46
|
+
<Icon name="AngleRight" className={variant} />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { CardMenu, CardMenuOption } from '../atoms/CardMenu'
|
|
4
|
+
|
|
5
|
+
const figmaPrimaryDesign = {
|
|
6
|
+
design: {
|
|
7
|
+
type: 'figma',
|
|
8
|
+
url: 'https://www.figma.com/design/DN2ova21vWqCRvPspBXgI1/Design-System?node-id=2285-1811&m=dev',
|
|
9
|
+
},
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const meta = {
|
|
13
|
+
title: 'Design System/Atoms/CardMenu',
|
|
14
|
+
component: CardMenuOption,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
argTypes: {
|
|
17
|
+
id: {
|
|
18
|
+
description: 'Id for aria purposes',
|
|
19
|
+
},
|
|
20
|
+
icon: {
|
|
21
|
+
description: 'Component icon used',
|
|
22
|
+
},
|
|
23
|
+
variant: {
|
|
24
|
+
description: 'Component variant used',
|
|
25
|
+
},
|
|
26
|
+
title: {
|
|
27
|
+
description: 'Component title text',
|
|
28
|
+
},
|
|
29
|
+
description: {
|
|
30
|
+
description: 'Component description text',
|
|
31
|
+
},
|
|
32
|
+
isDisabled: {
|
|
33
|
+
description: 'Is the component disabled?',
|
|
34
|
+
},
|
|
35
|
+
onClick: {
|
|
36
|
+
description: 'Event triggered when the component is clicked',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
parameters: figmaPrimaryDesign,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default meta
|
|
43
|
+
|
|
44
|
+
export const Option = {
|
|
45
|
+
render: () => (
|
|
46
|
+
<CardMenuOption
|
|
47
|
+
id="first-menu-option"
|
|
48
|
+
icon="Info"
|
|
49
|
+
variant="primary"
|
|
50
|
+
title="It's dangerous to go alone!"
|
|
51
|
+
description="Take this 🗡️ and this 🛡️ and this 💣 and this 🏹 and this 🔪 and this 🐴 and this 🔫 and this 🔪"
|
|
52
|
+
isDisabled={false}
|
|
53
|
+
onClick={() => alert('click')}
|
|
54
|
+
/>
|
|
55
|
+
),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const DisabledOption = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<CardMenuOption
|
|
61
|
+
id="first-menu-option"
|
|
62
|
+
icon="Info"
|
|
63
|
+
variant="primary"
|
|
64
|
+
title="It's dangerous to go alone!"
|
|
65
|
+
description="Take this 🗡️"
|
|
66
|
+
disabled
|
|
67
|
+
/>
|
|
68
|
+
),
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const Menu = {
|
|
72
|
+
render: () => (
|
|
73
|
+
<CardMenu>
|
|
74
|
+
<CardMenuOption
|
|
75
|
+
id="first-menu-option"
|
|
76
|
+
icon="AddCircle"
|
|
77
|
+
variant="primary"
|
|
78
|
+
title="Title"
|
|
79
|
+
description="Name of the videogame"
|
|
80
|
+
isDisabled={false}
|
|
81
|
+
onClick={() => alert('click title')}
|
|
82
|
+
/>
|
|
83
|
+
<CardMenuOption
|
|
84
|
+
id="second-menu-option"
|
|
85
|
+
icon="Edit"
|
|
86
|
+
variant="primary"
|
|
87
|
+
title="Address"
|
|
88
|
+
description="Videogame company address"
|
|
89
|
+
isDisabled={false}
|
|
90
|
+
onClick={() => alert('click address')}
|
|
91
|
+
/>
|
|
92
|
+
<CardMenuOption
|
|
93
|
+
id="third-menu-option"
|
|
94
|
+
icon="Info"
|
|
95
|
+
variant="primary"
|
|
96
|
+
title="Email"
|
|
97
|
+
description="Videogame company email"
|
|
98
|
+
isDisabled={false}
|
|
99
|
+
onClick={() => alert('click email')}
|
|
100
|
+
/>
|
|
101
|
+
</CardMenu>
|
|
102
|
+
),
|
|
103
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { screen, render } from '@testing-library/react'
|
|
3
|
+
import { CardMenuOption } from '@/atoms/CardMenu/CardMenuOption'
|
|
4
|
+
|
|
5
|
+
describe('CardMenuOption', () => {
|
|
6
|
+
it('renders', () => {
|
|
7
|
+
const { getByRole, getByText, getAllByRole } = render(
|
|
8
|
+
<CardMenuOption
|
|
9
|
+
id="option-one"
|
|
10
|
+
icon="Info"
|
|
11
|
+
title="It's dangerous to go alone!"
|
|
12
|
+
description="Take this sword!"
|
|
13
|
+
/>,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
expect(getByRole('menuitem')).toHaveClass(`card-menu-option primary`)
|
|
17
|
+
expect(getByText(/dangerous to go alone/i)).toBeInTheDocument()
|
|
18
|
+
expect(getByText(/this sword/i)).toBeInTheDocument()
|
|
19
|
+
expect(getAllByRole('img')[0].title).toBe('Info')
|
|
20
|
+
})
|
|
21
|
+
})
|