agroptima-design-system 1.0.7 → 1.0.8-beta.1
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,37 +1,31 @@
|
|
|
1
1
|
import './CardMenu.scss'
|
|
2
|
-
import type { LinkProps as NextLinkProps } from 'next/link'
|
|
3
|
-
import Link from 'next/link'
|
|
4
2
|
import { classNames } from '../../utils/classNames'
|
|
3
|
+
import { BaseButton, type BaseButtonProps } from '../Button'
|
|
5
4
|
import type { IconType } from '../Icon'
|
|
6
5
|
import { Icon } from '../Icon'
|
|
7
6
|
|
|
8
7
|
export type Variant = 'primary'
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
export interface CardMenuOptionProps extends LinkProps {
|
|
12
|
-
id?: string
|
|
9
|
+
interface CustomProps {
|
|
13
10
|
variant?: Variant
|
|
14
11
|
icon: IconType
|
|
15
12
|
title: string
|
|
16
13
|
description?: string
|
|
17
|
-
disabled?: boolean
|
|
18
|
-
href: string
|
|
19
14
|
active?: boolean
|
|
20
15
|
error?: boolean
|
|
21
16
|
}
|
|
22
17
|
|
|
18
|
+
export type CardMenuOptionProps = CustomProps & BaseButtonProps
|
|
19
|
+
|
|
23
20
|
export function CardMenuOption({
|
|
24
|
-
id,
|
|
25
21
|
variant = 'primary',
|
|
26
22
|
className,
|
|
27
23
|
icon,
|
|
28
24
|
title,
|
|
29
25
|
description,
|
|
30
|
-
disabled,
|
|
31
|
-
href,
|
|
26
|
+
disabled = false,
|
|
32
27
|
active,
|
|
33
28
|
error,
|
|
34
|
-
prefetch = false,
|
|
35
29
|
...props
|
|
36
30
|
}: CardMenuOptionProps): React.JSX.Element {
|
|
37
31
|
const cssClasses = classNames('card-menu-option', variant, className, {
|
|
@@ -41,12 +35,11 @@ export function CardMenuOption({
|
|
|
41
35
|
})
|
|
42
36
|
|
|
43
37
|
return (
|
|
44
|
-
<
|
|
38
|
+
<BaseButton
|
|
45
39
|
role="menuitem"
|
|
46
40
|
className={cssClasses}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
prefetch={prefetch}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
type="button"
|
|
50
43
|
{...props}
|
|
51
44
|
>
|
|
52
45
|
<div className="left">
|
|
@@ -59,6 +52,6 @@ export function CardMenuOption({
|
|
|
59
52
|
<div className="right">
|
|
60
53
|
<Icon name="AngleRight" className={variant} />
|
|
61
54
|
</div>
|
|
62
|
-
</
|
|
55
|
+
</BaseButton>
|
|
63
56
|
)
|
|
64
57
|
}
|
|
@@ -142,3 +142,16 @@ export const Menu: Story = {
|
|
|
142
142
|
</CardMenu>
|
|
143
143
|
),
|
|
144
144
|
} as unknown as Story
|
|
145
|
+
|
|
146
|
+
export const asButton: Story = {
|
|
147
|
+
render: () => (
|
|
148
|
+
<CardMenuOption
|
|
149
|
+
id="first-menu-option"
|
|
150
|
+
icon="Info"
|
|
151
|
+
variant="primary"
|
|
152
|
+
title="It's dangerous to go alone!"
|
|
153
|
+
description="Take this 🗡️ and this 🛡️ and this 💣 and this 🏹 and this 🔪 and this 🐴 and this 🔫 and this 🔪"
|
|
154
|
+
onClick={() => alert('Clicked!')}
|
|
155
|
+
/>
|
|
156
|
+
),
|
|
157
|
+
} as unknown as Story
|
|
@@ -19,4 +19,16 @@ describe('CardMenuOption', () => {
|
|
|
19
19
|
expect(getByText(/this sword/i)).toBeInTheDocument()
|
|
20
20
|
expect(getAllByRole('img')[0].title).toBe('Info')
|
|
21
21
|
})
|
|
22
|
+
it('renders a button if dont have href', () => {
|
|
23
|
+
const { getByRole } = render(
|
|
24
|
+
<CardMenuOption
|
|
25
|
+
id="option-one"
|
|
26
|
+
icon="Info"
|
|
27
|
+
title="It's dangerous to go alone!"
|
|
28
|
+
description="Take this sword!"
|
|
29
|
+
/>,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
expect(getByRole('menuitem')).not.toHaveAttribute('href')
|
|
33
|
+
})
|
|
22
34
|
})
|