react-restyle-components 0.2.22 → 0.2.24

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.
Files changed (50) hide show
  1. package/README.md +0 -6
  2. package/lib/package.json +15 -4
  3. package/lib/src/App.js +12 -1
  4. package/lib/src/assets/styles/colors.css +217 -0
  5. package/lib/src/assets/styles/decorations.css +15 -0
  6. package/lib/src/assets/styles/fontface.css +17 -0
  7. package/lib/src/assets/styles/scrollbars.css +70 -0
  8. package/lib/src/assets/styles/typography.css +3 -0
  9. package/lib/src/core-components/atoms/button/Button.stories.d.ts +320 -0
  10. package/lib/src/core-components/atoms/button/Button.stories.js +66 -0
  11. package/lib/src/core-components/atoms/button/Button.test.d.ts +1 -0
  12. package/lib/src/core-components/atoms/button/Button.test.js +31 -0
  13. package/lib/src/core-components/atoms/button/Button.types.d.ts +36 -0
  14. package/lib/src/core-components/atoms/button/Button.types.js +1 -0
  15. package/lib/src/core-components/atoms/button/LinkButton.stories.d.ts +302 -0
  16. package/lib/src/core-components/atoms/button/LinkButton.stories.js +52 -0
  17. package/lib/src/core-components/atoms/button/ToggleButton.stories.d.ts +337 -0
  18. package/lib/src/core-components/atoms/button/ToggleButton.stories.js +62 -0
  19. package/lib/src/core-components/atoms/button/button.component.d.ts +6 -0
  20. package/lib/src/core-components/atoms/button/button.component.js +19 -0
  21. package/lib/src/core-components/atoms/button/button.module.css +477 -0
  22. package/lib/src/core-components/atoms/button/buttonGroup/ButtonGroup.stories.d.ts +53 -0
  23. package/lib/src/core-components/atoms/button/buttonGroup/ButtonGroup.stories.js +271 -0
  24. package/lib/src/core-components/atoms/button/buttonGroup/buttonGroup.component.d.ts +9 -0
  25. package/lib/src/core-components/atoms/button/buttonGroup/buttonGroup.component.js +4 -0
  26. package/lib/src/core-components/atoms/button/linkButton.component.d.ts +9 -0
  27. package/lib/src/core-components/atoms/button/linkButton.component.js +20 -0
  28. package/lib/src/core-components/atoms/button/toggleButton.component.d.ts +10 -0
  29. package/lib/src/core-components/atoms/button/toggleButton.component.js +21 -0
  30. package/lib/src/core-components/atoms/icons/icons.component.js +1 -1
  31. package/lib/src/core-components/atoms/pdf/pdf-typography.components.js +2 -2
  32. package/lib/src/core-components/atoms/tabs/tabs.component.d.ts +9 -2
  33. package/lib/src/core-components/atoms/tabs/tabs.component.js +14 -9
  34. package/lib/src/core-components/atoms/tooltip/Tooltip.module.css +44 -0
  35. package/lib/src/core-components/atoms/tooltip/Tooltip.stories.d.ts +31 -0
  36. package/lib/src/core-components/atoms/tooltip/Tooltip.stories.js +100 -0
  37. package/lib/src/core-components/atoms/tooltip/Tooltip.types.d.ts +23 -0
  38. package/lib/src/core-components/atoms/tooltip/Tooltip.types.js +1 -0
  39. package/lib/src/core-components/atoms/tooltip/tooltip.component.d.ts +16 -9
  40. package/lib/src/core-components/atoms/tooltip/tooltip.component.js +26 -24
  41. package/lib/src/core-components/index.d.ts +4 -1
  42. package/lib/src/core-components/index.js +4 -1
  43. package/lib/tc.css +1 -1
  44. package/package.json +15 -4
  45. package/lib/src/core-components/atoms/buttons/button.stories.d.ts +0 -6
  46. package/lib/src/core-components/atoms/buttons/button.stories.js +0 -36
  47. package/lib/src/core-components/atoms/buttons/buttons.component.d.ts +0 -11
  48. package/lib/src/core-components/atoms/buttons/buttons.component.js +0 -8
  49. package/lib/src/core-components/atoms/tooltip/tooltip.stories.d.ts +0 -6
  50. package/lib/src/core-components/atoms/tooltip/tooltip.stories.js +0 -13
@@ -0,0 +1,271 @@
1
+ import React from 'react';
2
+ import { TooltipProvider } from '../../tooltip/tooltip.component';
3
+ import { ButtonGroup } from './buttonGroup.component';
4
+ import { Button } from '../button.component';
5
+ import { BrowserRouter } from 'react-router-dom';
6
+ const meta = {
7
+ title: 'Design System/Atoms/Button/ButtonGroup',
8
+ parameters: {
9
+ componentSubtitle: 'A container for grouping buttons together. Used when you want no space between buttons. Can also be used to create a split button using a Button and a DropdownMenu.',
10
+ },
11
+ component: ButtonGroup,
12
+ tags: ['autodocs'],
13
+ decorators: [
14
+ (Story) => (React.createElement(React.Fragment, null,
15
+ React.createElement(BrowserRouter, null,
16
+ React.createElement(TooltipProvider, null,
17
+ React.createElement(Story, null))))),
18
+ ],
19
+ };
20
+ export default meta;
21
+ /**
22
+ * At its simplest you can just wrap any `Button` elements in a `ButtonGroup`.
23
+ *
24
+ * All props for button scale, variant, etc stay on the Button.
25
+ * You should use the same scale for all buttons in a group but could mix and match variants and levels.
26
+ */
27
+ export const Basic = {
28
+ args: {
29
+ children: (React.createElement(React.Fragment, null,
30
+ React.createElement(Button, { scale: "s" }, "Button 1"),
31
+ React.createElement(Button, { scale: "s" }, "Button 2"),
32
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
33
+ },
34
+ };
35
+ /**
36
+ * If only a single `Button` is passed in, it will be visually the same as not wrapping in a `ButtonGroup`.
37
+ */
38
+ export const BasicOneButton = {
39
+ args: {
40
+ children: (React.createElement(React.Fragment, null,
41
+ React.createElement(Button, { scale: "s" }, "Button 1"))),
42
+ },
43
+ };
44
+ /**
45
+ * To creat a split button you would add a `DropdownMenu` as the last child. Its trigger should be a `Button`.
46
+ */
47
+ // export const SplitButton: Story = {
48
+ // args: {
49
+ // children: (
50
+ // <>
51
+ // <Button level="primary" scale="xs" variant="neutral">
52
+ // Button 1
53
+ // </Button>
54
+ // <DropdownMenu
55
+ // align="end"
56
+ // sideOffset={2}
57
+ // trigger={
58
+ // <Button
59
+ // level="primary"
60
+ // iconOnly={true}
61
+ // scale="xs"
62
+ // variant="neutral"
63
+ // >
64
+ // 👇
65
+ // </Button>
66
+ // }
67
+ // >
68
+ // <DropdownMenuSection divider="none">
69
+ // <DropdownMenuButton
70
+ // onClick={() => {
71
+ // // noop
72
+ // }}
73
+ // >
74
+ // Item 1
75
+ // </DropdownMenuButton>
76
+ // <DropdownMenuButton
77
+ // onClick={() => {
78
+ // // noop
79
+ // }}
80
+ // >
81
+ // Item 2
82
+ // </DropdownMenuButton>
83
+ // <DropdownMenuButton
84
+ // onClick={() => {
85
+ // // noop
86
+ // }}
87
+ // >
88
+ // Item 3
89
+ // </DropdownMenuButton>
90
+ // </DropdownMenuSection>
91
+ // </DropdownMenu>
92
+ // </>
93
+ // ),
94
+ // },
95
+ // };
96
+ /**
97
+ * ButtonGroups can be passed `orientation="vertical"` to stack buttons vertically.
98
+ */
99
+ export const Vertical = {
100
+ args: {
101
+ children: (React.createElement(React.Fragment, null,
102
+ React.createElement(Button, { scale: "s" }, "Button 1"),
103
+ React.createElement(Button, { scale: "s" }, "Button 2"),
104
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
105
+ orientation: 'vertical',
106
+ },
107
+ };
108
+ /**
109
+ * Vertical ButtonGroups can also contain a `DropdownMenu`.
110
+ */
111
+ // export const VerticalWithDropdown: Story = {
112
+ // args: {
113
+ // children: (
114
+ // <>
115
+ // <Button scale="s">Button 1</Button>
116
+ // <DropdownMenu
117
+ // side="right"
118
+ // trigger={
119
+ // <Button scale="s" variant="accent">
120
+ // Open 👉
121
+ // </Button>
122
+ // }
123
+ // >
124
+ // <DropdownMenuSection divider="none">
125
+ // <DropdownMenuButton
126
+ // onClick={() => {
127
+ // // noop
128
+ // }}
129
+ // >
130
+ // Item 1
131
+ // </DropdownMenuButton>
132
+ // <DropdownMenuButton
133
+ // onClick={() => {
134
+ // // noop
135
+ // }}
136
+ // >
137
+ // Item 2
138
+ // </DropdownMenuButton>
139
+ // <DropdownMenuButton
140
+ // onClick={() => {
141
+ // // noop
142
+ // }}
143
+ // >
144
+ // Item 3
145
+ // </DropdownMenuButton>
146
+ // </DropdownMenuSection>
147
+ // </DropdownMenu>
148
+ // <Button scale="s">Button 2</Button>
149
+ // </>
150
+ // ),
151
+ // orientation: 'vertical',
152
+ // },
153
+ // };
154
+ /**
155
+ * ButtonGroups also work with LinkButtons and ToggleButtons.
156
+ *
157
+ * However ToggleButton styling is not currently ideal as the divider is hard to see.
158
+ * Also note that ButtonGroup with ToggleButtons is not the same as a ToggleGroup. The former will allow multiple buttons to be active at once, whereas the latter will only allow one button to be active at a time.
159
+ */
160
+ // export const PseudoButtons: Story = {
161
+ // args: {
162
+ // children: <></>,
163
+ // },
164
+ // render: () => (
165
+ // <>
166
+ // <ButtonGroup>
167
+ // <LinkButton Component={Link} to="#" scale="s">
168
+ // LinkButton 1
169
+ // </LinkButton>
170
+ // <LinkButton Component={Link} to="#" scale="s">
171
+ // LinkButton 2
172
+ // </LinkButton>
173
+ // <LinkButton Component={Link} to="#" scale="s" variant="danger">
174
+ // LinkButton 3
175
+ // </LinkButton>
176
+ // </ButtonGroup>
177
+ // <br />
178
+ // <ButtonGroup>
179
+ // <ToggleButton scale="s">ToggleButton 1</ToggleButton>
180
+ // <ToggleButton scale="s">ToggleButton 2</ToggleButton>
181
+ // <ToggleButton scale="s">ToggleButton 3</ToggleButton>
182
+ // </ButtonGroup>
183
+ // </>
184
+ // ),
185
+ // };
186
+ export const FillModes = {
187
+ args: {
188
+ children: React.createElement(React.Fragment, null),
189
+ },
190
+ render: () => (React.createElement(React.Fragment, null,
191
+ React.createElement("h1", null, "Hug"),
192
+ React.createElement("p", null, "By default the ToggleGroup will hug its contents vertically and horizontally. In most cases this is what you will want as the Design System mostly uses this approach."),
193
+ React.createElement("div", { style: {
194
+ width: '400px',
195
+ height: '200px',
196
+ display: 'grid',
197
+ background: '#eee',
198
+ } },
199
+ React.createElement(ButtonGroup, null,
200
+ React.createElement(Button, { scale: "s" }, "Button 1"),
201
+ React.createElement(Button, { scale: "s" }, "Button 2"),
202
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
203
+ React.createElement("h1", null, "Orientation: horizontal"),
204
+ React.createElement("p", null, "But you can make it fill its parent and stretch out its children. Note that only the minimum amount of styles have been added. It is likely you will need to further customize your Buttons using className to suit your use case."),
205
+ React.createElement("div", { style: {
206
+ width: '400px',
207
+ height: '200px',
208
+ display: 'grid',
209
+ background: '#eee',
210
+ } },
211
+ React.createElement(ButtonGroup, { horizontalSizing: "fill" },
212
+ React.createElement(Button, { scale: "s" }, "Button 1"),
213
+ React.createElement(Button, { scale: "s" }, "Button 2"),
214
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
215
+ React.createElement("p", null, "Or vertically"),
216
+ React.createElement("div", { style: {
217
+ width: '400px',
218
+ height: '200px',
219
+ display: 'grid',
220
+ background: '#eee',
221
+ } },
222
+ React.createElement(ButtonGroup, { verticalSizing: "fill" },
223
+ React.createElement(Button, { scale: "s" }, "Button 1"),
224
+ React.createElement(Button, { scale: "s" }, "Button 2"),
225
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
226
+ React.createElement("p", null, "Or both"),
227
+ React.createElement("div", { style: {
228
+ width: '400px',
229
+ height: '200px',
230
+ display: 'grid',
231
+ background: '#eee',
232
+ } },
233
+ React.createElement(ButtonGroup, { verticalSizing: "fill", horizontalSizing: "fill" },
234
+ React.createElement(Button, { scale: "s" }, "Button 1"),
235
+ React.createElement(Button, { scale: "s" }, "Button 2"),
236
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
237
+ React.createElement("h1", null, "Orientation: vertical"),
238
+ React.createElement("p", null, "These also work vertically. Here is horizontal fill"),
239
+ React.createElement("div", { style: {
240
+ width: '400px',
241
+ height: '200px',
242
+ display: 'grid',
243
+ background: '#eee',
244
+ } },
245
+ React.createElement(ButtonGroup, { orientation: "vertical", horizontalSizing: "fill" },
246
+ React.createElement(Button, { scale: "s" }, "Button 1"),
247
+ React.createElement(Button, { scale: "s" }, "Button 2"),
248
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
249
+ React.createElement("p", null, "vertical"),
250
+ React.createElement("div", { style: {
251
+ width: '400px',
252
+ height: '200px',
253
+ display: 'grid',
254
+ background: '#eee',
255
+ } },
256
+ React.createElement(ButtonGroup, { orientation: "vertical", verticalSizing: "fill" },
257
+ React.createElement(Button, { scale: "s" }, "Button 1"),
258
+ React.createElement(Button, { scale: "s" }, "Button 2"),
259
+ React.createElement(Button, { scale: "s" }, "Button 3"))),
260
+ React.createElement("p", null, "and both"),
261
+ React.createElement("div", { style: {
262
+ width: '400px',
263
+ height: '200px',
264
+ display: 'grid',
265
+ background: '#eee',
266
+ } },
267
+ React.createElement(ButtonGroup, { orientation: "vertical", verticalSizing: "fill", horizontalSizing: "fill" },
268
+ React.createElement(Button, { scale: "s" }, "Button 1"),
269
+ React.createElement(Button, { scale: "s" }, "Button 2"),
270
+ React.createElement(Button, { scale: "s" }, "Button 3"))))),
271
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { ReactNode } from 'react';
3
+ export declare const ButtonGroup: ({ children, orientation, horizontalSizing, verticalSizing, className, }: {
4
+ children: ReactNode;
5
+ orientation?: "horizontal" | "vertical" | undefined;
6
+ horizontalSizing?: "fill" | "hug" | undefined;
7
+ verticalSizing?: "fill" | "hug" | undefined;
8
+ className?: string | undefined;
9
+ }) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import s from '../button.module.css';
3
+ import clsx from 'clsx';
4
+ export const ButtonGroup = ({ children, orientation = 'horizontal', horizontalSizing = 'hug', verticalSizing = 'hug', className, }) => (React.createElement("div", { className: clsx(s.group, s[`is${orientation}`], s[`ishorizontal${horizontalSizing}`], s[`isvertical${verticalSizing}`], className) }, children));
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ /**
3
+ * Wraps a provided Link component in our button styles.
4
+ * Assumes your chosen Router library uses a Link component that uses a `to` prop.
5
+ */
6
+ export declare const LinkButton: React.ForwardRefExoticComponent<Omit<import("./Button.types").ButtonProps, "loading"> & {
7
+ to: string;
8
+ Component: React.ForwardRefExoticComponent<import("react-router/dist/development/fog-of-war-DU_DzpDb").s & React.RefAttributes<HTMLAnchorElement>>;
9
+ } & React.AnchorHTMLAttributes<HTMLAnchorElement> & React.RefAttributes<HTMLAnchorElement>>;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { forwardRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import s from './button.module.css';
5
+ import { Tooltip } from '../tooltip/tooltip.component';
6
+ /**
7
+ * Wraps a provided Link component in our button styles.
8
+ * Assumes your chosen Router library uses a Link component that uses a `to` prop.
9
+ */
10
+ export const LinkButton = forwardRef(({ to, tooltip, className, level = 'primary', variant = 'brand', scale = 'm', iconOnly = false, children, Component, focus = 'visible', ...args }, ref) => {
11
+ const linkClasses = clsx(s.button, s.linkButton, s[`button-level-${level}`], s[`button-theme-${variant}`], s[`button-size-${scale}`], iconOnly && s[`button-icon-only`], focus === 'focus' && [s.focus], focus === 'visible' && s[`focus-visible`], className);
12
+ const link = (React.createElement(Component, { ref: ref, className: linkClasses, ...args, to: to }, children));
13
+ if (tooltip) {
14
+ return (React.createElement(Tooltip, { content: tooltip, padding: "s" }, link));
15
+ }
16
+ else {
17
+ return link;
18
+ }
19
+ });
20
+ LinkButton.displayName = 'LinkButton';
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ /**
3
+ * A checkbox styled to look like our Button, for a toggleable state UI component.
4
+ */
5
+ export declare const ToggleButton: React.ForwardRefExoticComponent<Omit<import("./Button.types").ButtonProps, "variant"> & {
6
+ labelClassName?: string | undefined;
7
+ contentClassName?: string | undefined;
8
+ active?: boolean | undefined;
9
+ variant?: "brand" | "accent" | undefined;
10
+ } & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,21 @@
1
+ import React, { forwardRef } from 'react';
2
+ import clsx from 'clsx';
3
+ import s from './button.module.css';
4
+ import { Tooltip } from '../tooltip/tooltip.component';
5
+ /**
6
+ * A checkbox styled to look like our Button, for a toggleable state UI component.
7
+ */
8
+ export const ToggleButton = forwardRef(({ tooltip, onChange, labelClassName, contentClassName, active, disabled = false, children, level = 'primary', variant = 'brand', scale = 'm', iconOnly = false, focus = 'visible', loading = false, ...restProps }, ref) => {
9
+ const controlled = typeof active === 'undefined' ? {} : { checked: active };
10
+ const labelClassNames = clsx(disabled && s.isDisabled, s.label, contentClassName);
11
+ const childrenClassNames = clsx(s.button, s.toggleButton, s[`button-level-${level}`], s[`button-theme-${variant}`], s[`button-size-${scale}`], loading && s.loading, iconOnly && s[`button-icon-only`], labelClassName);
12
+ const checkboxClassNames = clsx(s.checkbox, s.visuallyHidden, focus === 'focus' && [s.focus], focus === 'visible' && s[`focus-visible`]);
13
+ const renderContent = (React.createElement("label", { className: labelClassNames },
14
+ React.createElement("input", { ref: ref, type: "checkbox", onChange: onChange, disabled: disabled || loading, ...controlled, ...restProps, className: checkboxClassNames }),
15
+ React.createElement("span", { className: childrenClassNames }, children)));
16
+ if (!tooltip) {
17
+ return renderContent;
18
+ }
19
+ return (React.createElement(Tooltip, { content: tooltip, padding: "s" }, renderContent));
20
+ });
21
+ ToggleButton.displayName = 'ToggleButton';
@@ -26,7 +26,7 @@ export const Icon = ({ nameIcon, propsIcon, tooltip = '', isDisable = false, onC
26
26
  return (React.createElement("div", { onClick: () => {
27
27
  if (!isDisable)
28
28
  onClick && onClick();
29
- } }, !_.isEmpty(tooltip) ? (React.createElement(Tooltip, { tooltipText: tooltip },
29
+ } }, !_.isEmpty(tooltip) ? (React.createElement(Tooltip, { content: tooltip },
30
30
  React.createElement(ElementIcon, { ...iconProps }))) : (React.createElement(Suspense, { fallback: React.createElement("div", null, "Loading...") },
31
31
  React.createElement(ElementIcon, { ...iconProps })))));
32
32
  }
@@ -4,7 +4,7 @@ Font.register({
4
4
  family: 'ArimaBold',
5
5
  fonts: [
6
6
  {
7
- src: require('/src/library/assets/fonts/arima/arima-bold.ttf'),
7
+ src: '../../../library/assets/fonts/arima/arima-bold.ttf',
8
8
  fontStyle: 'normal',
9
9
  fontWeight: 'bold',
10
10
  },
@@ -12,7 +12,7 @@ Font.register({
12
12
  });
13
13
  Font.register({
14
14
  family: 'ArimaRegular',
15
- src: require('/src/library/assets/fonts/arima/arima-regular.ttf'),
15
+ src: '../../../library/assets/fonts/arima/arima-regular.ttf',
16
16
  });
17
17
  export const PdfHeading = ({ fontWeight = 'bold', fontSize = 22, fontFamily = 'ArimaRegular', style, children, }) => {
18
18
  return (React.createElement(Text, { style: {
@@ -1,11 +1,18 @@
1
- import React from 'react';
1
+ import React, { ReactNode, ReactElement } from 'react';
2
2
  import '../../../tc.css';
3
+ interface TabProps {
4
+ label: string;
5
+ children: ReactNode;
6
+ }
7
+ export declare const Tab: ({ label, children }: TabProps) => React.JSX.Element;
3
8
  interface TabsProps {
9
+ tabsClass?: string;
4
10
  options: Array<{
5
11
  title: string;
6
12
  icon: string;
7
13
  }>;
8
14
  onSelect: (item: string) => void;
15
+ children?: ReactElement<TabProps> | ReactElement<TabProps>[];
9
16
  }
10
- export declare const Tabs: ({ options, onSelect }: TabsProps) => React.JSX.Element;
17
+ export declare const Tabs: ({ tabsClass, options, onSelect, children, }: TabsProps) => React.JSX.Element;
11
18
  export {};
@@ -1,19 +1,24 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Icon } from '../..';
3
3
  import '../../../tc.css';
4
- export const Tabs = ({ options, onSelect }) => {
4
+ export const Tab = ({ label, children }) => {
5
+ return (React.createElement("div", { className: "flex", title: label }, children));
6
+ };
7
+ export const Tabs = ({ tabsClass = 'bg-blue-700', options, onSelect, children, }) => {
5
8
  const [selected, setSelected] = useState(options[0].title);
6
- return (React.createElement("div", { className: "flex justify-center" },
7
- React.createElement("ul", { className: "flex flex-wrap items-center justify-center -mb-px text-sm font-medium text-center text-black cursor-pointer gap-2" }, options?.map((item, index) => (React.createElement("li", { key: index, className: "bg-orange1 rounded-md" },
8
- React.createElement("div", { className: `inline-flex items-center justify-center p-3 border-b-2 gap-1 ${item.title == selected
9
- ? 'text-white font-bold md:text-md border-primary active'
10
- : ' text-gray-200 md:text-md border-transparent'}`, onClick: () => {
9
+ const tabs = React.Children.toArray(children).filter((child) => React.isValidElement(child) && child.type === Tab);
10
+ return (React.createElement("div", { className: "flex flex-col" },
11
+ React.createElement("ul", { className: "flex -mb-px text-sm font-medium text-center text-black cursor-pointer gap-1" }, options?.map((item, index) => (React.createElement("li", { key: index, className: `${tabsClass} rounded-md` },
12
+ React.createElement("div", { className: `inline-flex items-center justify-center p-2 border-b-2 gap-1 ${item.title == selected
13
+ ? 'text-white font-bold border-primary active'
14
+ : ' text-gray-200 border-transparent'}`, onClick: () => {
11
15
  setSelected(item.title);
12
16
  onSelect(item.title);
13
17
  } },
14
- React.createElement(Icon, { nameIcon: item.icon, propsIcon: {
15
- color: item.title == selected ? '#ffffff' : '#000000',
18
+ React.createElement(Icon, { nameIcon: item?.icon, propsIcon: {
19
+ color: item?.title == selected ? '#ffffff' : '#000000',
16
20
  size: 24,
17
21
  } }),
18
- React.createElement("span", { className: "text-3md" }, item.title))))))));
22
+ React.createElement("span", { className: "text-md" }, item.title)))))),
23
+ React.createElement("div", { className: "flex" }, tabs[options?.findIndex((item) => item.title === selected)])));
19
24
  };
@@ -0,0 +1,44 @@
1
+ :global .theme--dark {
2
+ --tooltip_bg: var(--Gl600);
3
+ --tooltip_color: var(--N50);
4
+ }
5
+
6
+ :global .theme--light {
7
+ --tooltip_bg: var(--N0);
8
+ --tooltip_color: var(--N600);
9
+ }
10
+ :where(.tooltip_content) {
11
+ font-size: 12px;
12
+ line-height: 1.4;
13
+ color: var(--tooltip_color);
14
+ background-color: var(--tooltip_bg);
15
+ opacity: 1;
16
+ filter: drop-shadow(0px 0px 1px rgba(0, 0, 0, 0.24)) drop-shadow(0px 8px 24px rgba(0, 0, 0, 0.08));
17
+ max-width: min(500px, 90vw);
18
+ z-index: var(--tooltip-z-custom);
19
+ border-radius: 3px;
20
+ }
21
+
22
+ .tooltip_content.tooltip_padding_s {
23
+ padding: 4px;
24
+ }
25
+ .tooltip_content.tooltip_padding_m {
26
+ padding: 8px;
27
+ }
28
+ .tooltip_content.tooltip_padding_l {
29
+ padding: 12px;
30
+ }
31
+ .tooltip_content.tooltip_padding_xl {
32
+ padding: 16px;
33
+ }
34
+ .tooltip_content.tooltip_padding_custom {
35
+ padding: var(--tooltip_padding);
36
+ }
37
+
38
+ .tooltip_arrow {
39
+ fill: var(--tooltip_bg);
40
+ }
41
+
42
+ .tooltip_reset_button {
43
+ all: unset;
44
+ }
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import type { StoryObj } from '@storybook/react';
3
+ declare const meta: {
4
+ title: string;
5
+ component: ({ align, side, children, content, avoidCollisions, alignOffset, sideOffset, disabled, delay, padding, className, }: React.PropsWithChildren<import("./Tooltip.types").TooltipProps>) => React.JSX.Element;
6
+ tags: string[];
7
+ parameters: {
8
+ docs: {
9
+ page: () => React.JSX.Element;
10
+ };
11
+ };
12
+ decorators: ((Story: import("@storybook/csf").PartialStoryFn<import("@storybook/react/dist/types-a5624094").R, {
13
+ className?: string | undefined;
14
+ padding?: "s" | "xl" | "l" | "m" | "custom" | undefined;
15
+ delay?: number | undefined;
16
+ side?: "top" | "right" | "bottom" | "left" | undefined;
17
+ sideOffset?: number | undefined;
18
+ content?: React.ReactNode;
19
+ align?: "center" | "start" | "end" | undefined;
20
+ alignOffset?: number | undefined;
21
+ avoidCollisions?: boolean | undefined;
22
+ disabled?: boolean | undefined;
23
+ children?: React.ReactNode;
24
+ }>) => React.JSX.Element)[];
25
+ };
26
+ export default meta;
27
+ type Story = StoryObj<typeof meta>;
28
+ export declare const BasicExample: Story;
29
+ export declare const Positions: Story;
30
+ export declare const JSXContent: Story;
31
+ export declare const JSXContentDifferentAlignments: Story;
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+ import { Button } from '../button/button.component';
3
+ import { Tooltip, TooltipProvider } from './tooltip.component';
4
+ import { Title, Subtitle, Primary, Controls, Stories } from '@storybook/blocks';
5
+ // import {AxeIcon} from '../AxeIcon/AxeIcon';
6
+ const meta = {
7
+ title: 'Design System/Atoms/Tooltip',
8
+ component: Tooltip,
9
+ tags: ['autodocs'],
10
+ parameters: {
11
+ docs: {
12
+ page: () => (React.createElement(React.Fragment, null,
13
+ React.createElement(Title, null),
14
+ React.createElement(Subtitle, null),
15
+ React.createElement(Primary, null),
16
+ React.createElement(Controls, null),
17
+ React.createElement(Stories, null))),
18
+ },
19
+ },
20
+ decorators: [
21
+ (Story) => (React.createElement(TooltipProvider, null,
22
+ React.createElement(Story, null))),
23
+ ],
24
+ };
25
+ export default meta;
26
+ export const BasicExample = {
27
+ args: { children: '✏️', content: 'This is a tooltip' },
28
+ };
29
+ export const Positions = {
30
+ parameters: {
31
+ controls: { hideNoControlsWarning: true, exclude: ['content', 'position'] },
32
+ docs: {
33
+ description: {
34
+ story: 'Example shows the same `Tooltip` used for all 4 position.',
35
+ },
36
+ },
37
+ },
38
+ render: (args) => (React.createElement("div", { style: { padding: '100px', display: 'flex', gap: '12px' } },
39
+ React.createElement(Tooltip, { ...args, content: "top", side: "top" },
40
+ React.createElement("span", null, "\uD83D\uDC46")),
41
+ React.createElement(Tooltip, { ...args, content: "bottom", side: "bottom" },
42
+ React.createElement("span", null, "\uD83D\uDC47")),
43
+ React.createElement(Tooltip, { ...args, content: "left", side: "left" },
44
+ React.createElement("span", null, "\uD83D\uDC48")),
45
+ React.createElement(Tooltip, { ...args, content: "right", side: "right" },
46
+ React.createElement("span", null, "\uD83D\uDC49")))),
47
+ };
48
+ export const JSXContent = {
49
+ parameters: {
50
+ controls: { hideNoControlsWarning: true, include: [] },
51
+ docs: {
52
+ description: {
53
+ story: 'JSX tooltip for a button.',
54
+ },
55
+ },
56
+ },
57
+ render: () => (React.createElement("div", { style: { padding: '100px', display: 'flex', gap: '12px' } },
58
+ React.createElement(Tooltip, { side: "top", content: React.createElement(React.Fragment, null,
59
+ React.createElement(Button, { variant: "accent" }, "\u2728\u2728\u2728"),
60
+ ' ',
61
+ React.createElement(Button, { variant: "danger" }, "\u2728\u2728\u2728")) },
62
+ React.createElement("span", null, "Fancy Tooltip")))),
63
+ };
64
+ export const JSXContentDifferentAlignments = {
65
+ parameters: {
66
+ controls: { hideNoControlsWarning: true, include: [] },
67
+ docs: {
68
+ description: {
69
+ story: 'JSX tooltip for a button with all 3 alignments options and side set to top.',
70
+ },
71
+ },
72
+ },
73
+ render: () => (React.createElement("div", { style: { padding: '100px', display: 'flex', gap: '12px' } },
74
+ React.createElement(Tooltip, { side: "top", align: "start", content: React.createElement("span", null, "Tooltip") },
75
+ React.createElement(Button, { variant: "danger" }, "Align Start")),
76
+ React.createElement(Tooltip, { side: "top", align: "center", content: React.createElement("span", null, "Tooltip") },
77
+ React.createElement(Button, { variant: "danger" }, "Align Center")),
78
+ React.createElement(Tooltip, { side: "top", align: "end", content: React.createElement("span", null, "Tooltip") },
79
+ React.createElement(Button, { variant: "danger" }, "Align End")))),
80
+ };
81
+ // export const JsxAsTrigger: Story = {
82
+ // parameters: {
83
+ // controls: { exclude: ['children'] },
84
+ // docs: {
85
+ // description: {
86
+ // story:
87
+ // 'The trigger you pass needs to be able to receive a ref and pass it to whichever DOM Node you plan to use for positioning your tooltip. It also needs to pass any arbitrary/unknown props onto the same DOM node, as our library will be passing on various required custom data-attributes to it. If your component cannot do this, a solution is to just wrap it in a div, span or other html element - eg `<div><MyComponent/></div>`.'
88
+ // }
89
+ // }
90
+ // },
91
+ // render: () => (
92
+ // <div style={{ width: 'max-content' }}>
93
+ // <Tooltip content={'🪓🪓🪓🪓🪓'}>
94
+ // <span>
95
+ // <AxeIcon axeCode={4} />
96
+ // </span>
97
+ // </Tooltip>
98
+ // </div>
99
+ // )
100
+ // };
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ export type TooltipProps = {
3
+ /** custom classname to pass to the tooltip element */
4
+ className?: string;
5
+ /** padding within the tooltip element*/
6
+ padding?: 's' | 'm' | 'l' | 'xl' | 'custom';
7
+ /** The delay (in ms) before showing the tooltip */
8
+ delay?: number;
9
+ /** Sets the preferred position relative to the trigger */
10
+ side?: 'top' | 'right' | 'bottom' | 'left';
11
+ /** Space between the tooltip element and anchor element (arrow not included in calculation) */
12
+ sideOffset?: number;
13
+ /** Use this to set the content of the tooltip*/
14
+ content?: React.ReactNode;
15
+ /** Sets the preferred alignment relative to the trigger & position */
16
+ align?: 'start' | 'center' | 'end';
17
+ /**Space between alignment point and tooltip */
18
+ alignOffset?: number;
19
+ /** If set to true then in the case of collision finds the alternate ways by changing the position or aligment or both to properly display tooltip */
20
+ avoidCollisions?: boolean;
21
+ /** Set true to prevent tooltip from displaying */
22
+ disabled?: boolean;
23
+ };