agroptima-design-system 1.0.7 → 1.0.8-beta.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": "1.0.7",
3
+ "version": "1.0.8-beta.0",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -12,6 +12,7 @@
12
12
  padding: config.$space-3x;
13
13
  gap: config.$space-3x;
14
14
  border-radius: config.$corner-radius-xxs;
15
+ border: none;
15
16
  text-decoration: none;
16
17
  cursor: default;
17
18
  &:hover {
@@ -1,25 +1,23 @@
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
- type LinkProps = NextLinkProps & React.AnchorHTMLAttributes<HTMLAnchorElement>
11
- export interface CardMenuOptionProps extends LinkProps {
9
+ interface CustomProps {
12
10
  id?: string
13
11
  variant?: Variant
14
12
  icon: IconType
15
13
  title: string
16
14
  description?: string
17
- disabled?: boolean
18
- href: string
19
15
  active?: boolean
20
16
  error?: boolean
21
17
  }
22
18
 
19
+ export type CardMenuOptionProps = CustomProps & BaseButtonProps
20
+
23
21
  export function CardMenuOption({
24
22
  id,
25
23
  variant = 'primary',
@@ -27,11 +25,9 @@ export function CardMenuOption({
27
25
  icon,
28
26
  title,
29
27
  description,
30
- disabled,
31
- href,
28
+ disabled = false,
32
29
  active,
33
30
  error,
34
- prefetch = false,
35
31
  ...props
36
32
  }: CardMenuOptionProps): React.JSX.Element {
37
33
  const cssClasses = classNames('card-menu-option', variant, className, {
@@ -41,12 +37,10 @@ export function CardMenuOption({
41
37
  })
42
38
 
43
39
  return (
44
- <Link
40
+ <BaseButton
45
41
  role="menuitem"
46
42
  className={cssClasses}
47
- href={disabled ? '#' : href}
48
- aria-disabled={disabled}
49
- prefetch={prefetch}
43
+ disabled={disabled}
50
44
  {...props}
51
45
  >
52
46
  <div className="left">
@@ -59,6 +53,6 @@ export function CardMenuOption({
59
53
  <div className="right">
60
54
  <Icon name="AngleRight" className={variant} />
61
55
  </div>
62
- </Link>
56
+ </BaseButton>
63
57
  )
64
58
  }
@@ -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
@@ -4,6 +4,9 @@ import { Meta } from "@storybook/addon-docs/blocks";
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## 1.0.8
8
+ * CardMenuOption can be a button or a link
9
+
7
10
  ## 1.0.7
8
11
 
9
12
  * Add link styles to Alert component
@@ -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
  })