@agregio-solutions/design-system 1.96.0 → 1.97.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.
@@ -4,7 +4,12 @@ export type Props = {
4
4
  /**
5
5
  * Specifies the tag color. The default is "default".
6
6
  */
7
- nature?: "default" | "informative" | "negative" | "positive" | "warning";
7
+ nature?: "default" | "informative" | "negative" | "positive" | "warning" | "azure" | "purple" | "pink" | "orange";
8
+ /**
9
+ * Specifies the tag color intensity: "default" (light background), "enhanced" (saturated background) or "reversed" (dark background with light text, to be used on dense backgrounds). The default is "default".
10
+ * @default default
11
+ */
12
+ mode?: "default" | "enhanced" | "reversed";
8
13
  /**
9
14
  * Icon displayed on the extreme left.
10
15
  */
@@ -13,11 +13,29 @@ Here are the Storybook Stories.
13
13
  Base stories:
14
14
 
15
15
  ```tsx
16
+ import { Fragment } from "react";
16
17
  import { Meta, StoryObj } from "@storybook/react-vite";
17
18
  import Tag from "./Tag";
18
- import { within } from "storybook/test";
19
+ import { expect, within } from "storybook/test";
19
20
  import { ICON_NAMES_ARRAY } from "@components/Icon/Icon";
20
21
 
22
+ const NATURES = [
23
+ "default",
24
+ "informative",
25
+ "negative",
26
+ "warning",
27
+ "positive",
28
+ "azure",
29
+ "purple",
30
+ "pink",
31
+ "orange",
32
+ ] as const;
33
+
34
+ const MODES = ["default", "enhanced", "reversed"] as const;
35
+
36
+ const getTag = (canvasElement: HTMLElement) =>
37
+ canvasElement.querySelector('[data-design-system-component="Tag"]');
38
+
21
39
  const meta: Meta<typeof Tag> = {
22
40
  component: Tag,
23
41
  tags: ["autodocs"],
@@ -41,6 +59,7 @@ export const Default: StoryObj<typeof Tag> = {
41
59
  play: async ({ canvasElement, args }) => {
42
60
  const canvas = within(canvasElement);
43
61
  await canvas.findByText(args.children as string);
62
+ await expect(getTag(canvasElement)).toHaveAttribute("data-mode", "default");
44
63
  },
45
64
  };
46
65
 
@@ -49,33 +68,82 @@ export const WithIcon: StoryObj<typeof Tag> = {
49
68
  ...Default.args,
50
69
  iconLeft: "help_outline",
51
70
  },
71
+ play: async ({ canvasElement }) => {
72
+ await expect(getTag(canvasElement)).toHaveAttribute(
73
+ "data-have-icon",
74
+ "true",
75
+ );
76
+ },
52
77
  };
53
78
 
54
- export const Informative: StoryObj<typeof Tag> = {
79
+ export const Enhanced: StoryObj<typeof Tag> = {
55
80
  args: {
56
81
  ...WithIcon.args,
57
- nature: "informative",
82
+ mode: "enhanced",
83
+ },
84
+ play: async ({ canvasElement }) => {
85
+ await expect(getTag(canvasElement)).toHaveAttribute(
86
+ "data-mode",
87
+ "enhanced",
88
+ );
58
89
  },
59
90
  };
60
91
 
61
- export const Negative: StoryObj<typeof Tag> = {
92
+ export const Reversed: StoryObj<typeof Tag> = {
62
93
  args: {
63
94
  ...WithIcon.args,
64
- nature: "negative",
95
+ mode: "reversed",
96
+ },
97
+ play: async ({ canvasElement }) => {
98
+ await expect(getTag(canvasElement)).toHaveAttribute(
99
+ "data-mode",
100
+ "reversed",
101
+ );
65
102
  },
66
103
  };
67
104
 
68
- export const Positive: StoryObj<typeof Tag> = {
69
- args: {
70
- ...WithIcon.args,
71
- nature: "positive",
105
+ export const AllVariants: StoryObj<typeof Tag> = {
106
+ parameters: {
107
+ layout: "padded",
72
108
  },
73
- };
109
+ render: () => (
110
+ <div
111
+ style={{
112
+ display: "inline-grid",
113
+ gridTemplateColumns: "repeat(4, max-content)",
114
+ columnGap: "var(--spacing-md)",
115
+ rowGap: "var(--spacing-sm)",
116
+ alignItems: "center",
117
+ justifyItems: "start",
118
+ }}
119
+ >
120
+ <span />
121
+ {MODES.map((mode) => (
122
+ <strong key={mode}>{mode}</strong>
123
+ ))}
74
124
 
75
- export const Warning: StoryObj<typeof Tag> = {
76
- args: {
77
- ...WithIcon.args,
78
- nature: "warning",
125
+ {NATURES.map((nature) => (
126
+ <Fragment key={nature}>
127
+ <strong>{nature}</strong>
128
+ {MODES.map((mode) => (
129
+ <Tag key={mode} nature={nature} mode={mode} iconLeft="help_outline">
130
+ [Insert tag]
131
+ </Tag>
132
+ ))}
133
+ </Fragment>
134
+ ))}
135
+ </div>
136
+ ),
137
+ play: async ({ canvasElement }) => {
138
+ for (const nature of NATURES) {
139
+ for (const mode of MODES) {
140
+ await expect(
141
+ canvasElement.querySelector(
142
+ `[data-nature="${nature}"][data-mode="${mode}"]`,
143
+ ),
144
+ ).toBeInTheDocument();
145
+ }
146
+ }
79
147
  },
80
148
  };
81
149
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agregio-solutions/design-system",
3
- "version": "1.96.0",
3
+ "version": "1.97.0",
4
4
  "description": "React Component library and Storybook that is part of the Design System for Agregio Solutions",
5
5
  "type": "module",
6
6
  "module": "dist/design-system.js",