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,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "1.0.7",
3
+ "version": "1.0.8-beta.1",
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,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
- type LinkProps = NextLinkProps & React.AnchorHTMLAttributes<HTMLAnchorElement>
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
- <Link
38
+ <BaseButton
45
39
  role="menuitem"
46
40
  className={cssClasses}
47
- href={disabled ? '#' : href}
48
- aria-disabled={disabled}
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
- </Link>
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
@@ -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
  })