agroptima-design-system 0.28.5 → 0.28.7

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.28.5",
3
+ "version": "0.28.7",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -0,0 +1,31 @@
1
+ @use '../settings/color_alias';
2
+ @use '../settings/typography/content' as typography;
3
+ @use '../settings/config';
4
+ @use '../settings/mixins';
5
+
6
+ $border-line: 1px solid color_alias.$neutral-color-200;
7
+
8
+ .divider {
9
+ @include mixins.icon-color(color_alias.$primary-color-600);
10
+ @include typography.body_bold;
11
+ display: flex;
12
+ align-items: center;
13
+
14
+ .line {
15
+ border: $border-line;
16
+ }
17
+
18
+ .long {
19
+ flex: 1;
20
+ margin-left: config.$space-3x;
21
+ }
22
+
23
+ .short {
24
+ width: config.$space-6x;
25
+ margin-right: config.$space-3x;
26
+ }
27
+
28
+ .icon {
29
+ margin-right: config.$space-2x;
30
+ }
31
+ }
@@ -0,0 +1,31 @@
1
+ import './Divider.scss'
2
+ import { classNames } from '../utils/classNames'
3
+ import type { IconType } from './Icon'
4
+ import { Icon } from './Icon'
5
+
6
+ export interface DividerProps extends React.ComponentPropsWithoutRef<'div'> {
7
+ title: string
8
+ variant?: string
9
+ icon?: IconType
10
+ }
11
+
12
+ export function Divider({
13
+ title,
14
+ variant = 'primary',
15
+ icon,
16
+ className,
17
+ }: DividerProps) {
18
+ const cssClasses = classNames('divider', variant, className)
19
+
20
+ return (
21
+ <div role="separator" className={cssClasses}>
22
+ {icon ? (
23
+ <Icon className="icon" name={icon} size="3" />
24
+ ) : (
25
+ <div className="short line"></div>
26
+ )}
27
+ <span>{title}</span>
28
+ <div className="long line"></div>
29
+ </div>
30
+ )
31
+ }
@@ -4,7 +4,6 @@
4
4
  html {
5
5
  scroll-behavior: smooth;
6
6
  max-width: 100%;
7
- overflow-x: hidden;
8
7
  }
9
8
 
10
9
  body {
@@ -4,11 +4,18 @@ import { Meta } from "@storybook/blocks";
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## 0.28.7
8
+
9
+ * Add Divider component
10
+
11
+ ## 0.28.6
12
+
13
+ * Remove overflow-x from html element for Modal component.
14
+
7
15
  ## 0.28.5
8
16
 
9
17
  * Remove closeButton property to Modal component.
10
18
 
11
-
12
19
  ## 0.28.4
13
20
 
14
21
  * Update Modal component to adapt to the content height.
@@ -0,0 +1,44 @@
1
+ import type { StoryObj } from '@storybook/react'
2
+ import { Divider } from '../atoms/Divider'
3
+
4
+ const meta = {
5
+ title: 'Design System/Atoms/Divider',
6
+ component: Divider,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ title: {
10
+ description: 'A title for divider',
11
+ },
12
+ icon: {
13
+ description: 'Optional icon that is added next to the title divider ',
14
+ },
15
+ variant: 'primary',
16
+ },
17
+ }
18
+
19
+ const figmaPrimaryDesign = {
20
+ design: {
21
+ type: 'figma',
22
+ url: 'https://www.figma.com/design/DN2ova21vWqCRvPspBXgI1/Design-System?node-id=3760-1578&p=f&t=C1SvMqG638Ei5ASv-0',
23
+ },
24
+ }
25
+
26
+ export default meta
27
+ type Story = StoryObj<typeof meta>
28
+
29
+ export const Primary: Story = {
30
+ args: {
31
+ title: '19/01/2025 - Delivery Note',
32
+ variant: 'primary',
33
+ },
34
+ parameters: figmaPrimaryDesign,
35
+ }
36
+
37
+ export const WithIcon: Story = {
38
+ args: {
39
+ title: '19/01/2025 - Delivery Note',
40
+ icon: 'DeliveryNote',
41
+ variant: 'primary',
42
+ },
43
+ parameters: figmaPrimaryDesign,
44
+ }
@@ -0,0 +1,23 @@
1
+ import { render } from '@testing-library/react'
2
+ import { Divider } from '../src/atoms/Divider'
3
+
4
+ describe('Divider', () => {
5
+ it('renders', () => {
6
+ const { getByRole, getAllByRole, getByText } = render(
7
+ <Divider title="A title divider" />,
8
+ )
9
+ expect(getByRole('separator')).toHaveClass('divider primary')
10
+ expect(getAllByRole('generic')[1]).toHaveClass('short line')
11
+ expect(getAllByRole('generic')[3]).toHaveClass('long line')
12
+ expect(getByText('A title divider')).toBeInTheDocument()
13
+ })
14
+
15
+ it('renders with icon', () => {
16
+ const { getByRole, getAllByRole, getByText } = render(
17
+ <Divider title="A title divider with icon" icon="DeliveryNote" />,
18
+ )
19
+ expect(getByRole('img')).toHaveClass(/icon/i)
20
+ expect(getAllByRole('generic')[2]).toHaveClass('long line')
21
+ expect(getByText('A title divider with icon')).toBeInTheDocument()
22
+ })
23
+ })