react-restyle-components 0.2.24 → 0.2.25
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/lib/package.json +4 -4
- package/lib/src/App.js +2 -2
- package/lib/src/core-components/atoms/button/Button.stories.d.ts +2 -17
- package/lib/src/core-components/atoms/button/Button.stories.js +2 -39
- package/lib/src/core-components/atoms/button/Button.types.d.ts +1 -12
- package/lib/src/core-components/atoms/button/button.component.d.ts +1 -0
- package/lib/src/core-components/atoms/button/button.component.js +7 -6
- package/lib/src/core-components/atoms/button/buttonGroup/ButtonGroup.stories.d.ts +0 -17
- package/lib/src/core-components/atoms/button/buttonGroup/ButtonGroup.stories.js +4 -232
- package/lib/src/core-components/atoms/button/buttonGroup/buttonGroup.component.d.ts +1 -0
- package/lib/src/core-components/atoms/button/buttonGroup/buttonGroup.component.js +2 -3
- package/lib/src/core-components/atoms/tooltip/Tooltip.stories.d.ts +1 -2
- package/lib/src/core-components/atoms/tooltip/Tooltip.stories.js +5 -5
- package/lib/src/core-components/atoms/tooltip/Tooltip.types.d.ts +0 -2
- package/lib/src/core-components/atoms/tooltip/tooltip.component.d.ts +1 -2
- package/lib/src/core-components/atoms/tooltip/tooltip.component.js +11 -11
- package/lib/src/core-components/index.d.ts +0 -2
- package/lib/src/core-components/index.js +0 -2
- package/lib/tc.css +1 -1
- package/package.json +5 -5
- package/lib/src/core-components/atoms/button/LinkButton.stories.d.ts +0 -302
- package/lib/src/core-components/atoms/button/LinkButton.stories.js +0 -52
- package/lib/src/core-components/atoms/button/ToggleButton.stories.d.ts +0 -337
- package/lib/src/core-components/atoms/button/ToggleButton.stories.js +0 -62
- package/lib/src/core-components/atoms/button/button.module.css +0 -477
- package/lib/src/core-components/atoms/button/linkButton.component.d.ts +0 -9
- package/lib/src/core-components/atoms/button/linkButton.component.js +0 -20
- package/lib/src/core-components/atoms/button/toggleButton.component.d.ts +0 -10
- package/lib/src/core-components/atoms/button/toggleButton.component.js +0 -21
- package/lib/src/core-components/atoms/tooltip/Tooltip.module.css +0 -44
package/lib/package.json
CHANGED
|
@@ -78,6 +78,8 @@
|
|
|
78
78
|
"@svgr/webpack": "^8.1.0",
|
|
79
79
|
"@tailwindcss/forms": "^0.5.9",
|
|
80
80
|
"@testing-library/react": "^16.0.1",
|
|
81
|
+
"@vitest/coverage-c8": "^0.31.4",
|
|
82
|
+
"@vitest/ui": "^0.31.4",
|
|
81
83
|
"autoprefixer": "^10.4.19",
|
|
82
84
|
"copyfiles": "^2.4.1",
|
|
83
85
|
"craco-alias": "^3.0.1",
|
|
@@ -87,8 +89,6 @@
|
|
|
87
89
|
"gh-pages": "^3.2.3",
|
|
88
90
|
"husky": "^7.0.4",
|
|
89
91
|
"jest": "^29.7.0",
|
|
90
|
-
"@vitest/coverage-c8": "^0.31.4",
|
|
91
|
-
"@vitest/ui": "^0.31.4",
|
|
92
92
|
"lint-staged": "^12.4.0",
|
|
93
93
|
"postcss-loader": "^8.1.1",
|
|
94
94
|
"prettier": "^3.3.3",
|
|
@@ -100,9 +100,9 @@
|
|
|
100
100
|
"style-loader": "^4.0.0",
|
|
101
101
|
"tailwindcss": "^3.4.14",
|
|
102
102
|
"ts-jest": "^29.2.5",
|
|
103
|
-
"webpack": "^5.72.0",
|
|
104
103
|
"vitest": "^0.31.4",
|
|
105
|
-
"vitest-dom": "^0.1.0"
|
|
104
|
+
"vitest-dom": "^0.1.0",
|
|
105
|
+
"webpack": "^5.72.0"
|
|
106
106
|
},
|
|
107
107
|
"eslintConfig": {
|
|
108
108
|
"extends": [
|
package/lib/src/App.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import './App.css';
|
|
3
|
-
import { ColorPickerModal, PdfMedium, Tab, Tabs, } from './core-components';
|
|
3
|
+
import { ColorPickerModal, PdfMedium, Tab, Tabs, Button, } from './core-components';
|
|
4
4
|
function App() {
|
|
5
5
|
const [color, setColor] = useState('#aabbcc');
|
|
6
6
|
return (React.createElement("div", { className: "flex flex-col gap-4 p-4" },
|
|
7
|
-
React.createElement(
|
|
7
|
+
React.createElement(Button, null, "Title"),
|
|
8
8
|
React.createElement(Tabs, { options: [
|
|
9
9
|
{ title: 'Work History', icon: 'FaHistory' },
|
|
10
10
|
{ title: 'Book Order', icon: 'FaBook' },
|
|
@@ -13,13 +13,8 @@ declare const meta: {
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
decorators: ((Story: import("@storybook/csf").PartialStoryFn<import("@storybook/react/dist/types-a5624094").R, {
|
|
16
|
+
variant?: "solid" | "outline" | undefined;
|
|
16
17
|
tooltip?: string | undefined;
|
|
17
|
-
level?: "primary" | "secondary" | undefined;
|
|
18
|
-
variant?: "brand" | "danger" | "accent" | "neutral" | undefined;
|
|
19
|
-
scale?: "s" | "xl" | "l" | "m" | "xs" | "xxs" | undefined;
|
|
20
|
-
iconOnly?: boolean | undefined;
|
|
21
|
-
focus?: "none" | "visible" | "focus" | undefined;
|
|
22
|
-
loading?: boolean | undefined;
|
|
23
18
|
className?: string | undefined;
|
|
24
19
|
disabled?: boolean | undefined;
|
|
25
20
|
form?: string | undefined;
|
|
@@ -307,14 +302,4 @@ type Story = StoryObj<typeof meta>;
|
|
|
307
302
|
* However the Design System uses a different size for icons if they are the _only_ thing in the button.
|
|
308
303
|
* To handle this we add the prop `iconOnly`.
|
|
309
304
|
*/
|
|
310
|
-
export declare const
|
|
311
|
-
export declare const TextOnly: Story;
|
|
312
|
-
/**
|
|
313
|
-
* The Button doesn't technically have any controls to position the icon. The Button can accept any content as its children, so if you want to add an icon at the end of text, you simply add both as children in that order:
|
|
314
|
-
*/
|
|
315
|
-
export declare const TextWithIconAtEnd: Story;
|
|
316
|
-
/**
|
|
317
|
-
* Or to put it at the start you just... put it at the start:
|
|
318
|
-
*/
|
|
319
|
-
export declare const TextWithIconAtStart: Story;
|
|
320
|
-
export declare const Loading: Story;
|
|
305
|
+
export declare const Basic: Story;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Attach from '../../../assets/icons/attach.svg';
|
|
3
2
|
import { TooltipProvider } from '../tooltip/tooltip.component';
|
|
4
3
|
import { Button } from './button.component';
|
|
5
|
-
import { useState } from 'react';
|
|
6
4
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
7
5
|
const meta = {
|
|
8
6
|
title: 'Design System/Atoms/Button',
|
|
@@ -24,43 +22,8 @@ export default meta;
|
|
|
24
22
|
* However the Design System uses a different size for icons if they are the _only_ thing in the button.
|
|
25
23
|
* To handle this we add the prop `iconOnly`.
|
|
26
24
|
*/
|
|
27
|
-
export const
|
|
28
|
-
render: (args) => (React.createElement(Button, { ...args },
|
|
29
|
-
React.createElement(Attach, null))),
|
|
30
|
-
args: {
|
|
31
|
-
iconOnly: true,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
export const TextOnly = {
|
|
35
|
-
args: {
|
|
36
|
-
children: 'Button',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* The Button doesn't technically have any controls to position the icon. The Button can accept any content as its children, so if you want to add an icon at the end of text, you simply add both as children in that order:
|
|
41
|
-
*/
|
|
42
|
-
export const TextWithIconAtEnd = {
|
|
43
|
-
render: (args) => (React.createElement(Button, { ...args },
|
|
44
|
-
"Attach ",
|
|
45
|
-
React.createElement(Attach, null))),
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Or to put it at the start you just... put it at the start:
|
|
49
|
-
*/
|
|
50
|
-
export const TextWithIconAtStart = {
|
|
51
|
-
render: (args) => (React.createElement(Button, { ...args },
|
|
52
|
-
React.createElement(Attach, null),
|
|
53
|
-
" Attach")),
|
|
54
|
-
};
|
|
55
|
-
export const Loading = {
|
|
25
|
+
export const Basic = {
|
|
56
26
|
render: function Render(args) {
|
|
57
|
-
|
|
58
|
-
const handleClick = () => {
|
|
59
|
-
setLoading(true);
|
|
60
|
-
setTimeout(() => {
|
|
61
|
-
setLoading(false);
|
|
62
|
-
}, 2000);
|
|
63
|
-
};
|
|
64
|
-
return (React.createElement(Button, { ...args, loading: loading, onClick: handleClick }, args.children || 'Slow loading button'));
|
|
27
|
+
return React.createElement(Button, { ...args }, "Submit");
|
|
65
28
|
},
|
|
66
29
|
};
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
import { LinkProps } from 'react-router-dom';
|
|
3
3
|
export type ButtonProps = {
|
|
4
|
+
variant?: 'solid' | 'outline';
|
|
4
5
|
/** Optional tooltip content */
|
|
5
6
|
tooltip?: string;
|
|
6
|
-
/** What level of button? Defaults to 'primary' */
|
|
7
|
-
level?: 'primary' | 'secondary';
|
|
8
|
-
/** What variant of button? Defaults to 'brand' */
|
|
9
|
-
variant?: 'brand' | 'danger' | 'accent' | 'neutral';
|
|
10
|
-
/** What size of button? Defaults to 'm' */
|
|
11
|
-
scale?: 'xl' | 'l' | 'm' | 's' | 'xs' | 'xxs';
|
|
12
|
-
/** Does the button only include a single SVG? If so we will tweak styles. Defaults to false. */
|
|
13
|
-
iconOnly?: boolean;
|
|
14
|
-
/** What kind of focus of button? Defaults to 'visible' */
|
|
15
|
-
focus?: 'visible' | 'focus' | 'none';
|
|
16
|
-
/** should we replace content with a loading indicator */
|
|
17
|
-
loading?: boolean;
|
|
18
7
|
/** ClassName to add so you can add additional styling */
|
|
19
8
|
className?: string;
|
|
20
9
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import s from './button.module.css';
|
|
5
3
|
import { Tooltip } from '../tooltip/tooltip.component';
|
|
4
|
+
import '../../../tc.css';
|
|
6
5
|
/**
|
|
7
6
|
* It's a `<button>button</button>`. Pass in regular button props such as onClick as well as any of the props defined here.
|
|
8
7
|
*/
|
|
9
|
-
export const Button = forwardRef(({
|
|
10
|
-
const
|
|
11
|
-
|
|
8
|
+
export const Button = forwardRef(({ variant = 'solid', tooltip, disabled = false, type = 'button', className, children, ...args }, ref) => {
|
|
9
|
+
const buttonColorClass = variant === 'solid'
|
|
10
|
+
? 'text-white bg-[#007BFF] hover:bg-[#007BFF] hover:shadow-lg text-white'
|
|
11
|
+
: 'dark:text-white text-black border border-gray-400 hover:shadow-lg';
|
|
12
|
+
const button = (React.createElement("button", { ref: ref, ...args, className: `${className} rounded-100px px-3 py-1 text-md ${buttonColorClass} pt-2 pb-2 font-nunitoSansRegular ${disabled ? 'opacity-50' : 'opacity-100'}`, type: type, disabled: disabled }, children));
|
|
12
13
|
if (tooltip) {
|
|
13
|
-
return
|
|
14
|
+
return React.createElement(Tooltip, { content: tooltip }, button);
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
16
17
|
return button;
|
|
@@ -34,20 +34,3 @@ export declare const Basic: Story;
|
|
|
34
34
|
* If only a single `Button` is passed in, it will be visually the same as not wrapping in a `ButtonGroup`.
|
|
35
35
|
*/
|
|
36
36
|
export declare const BasicOneButton: Story;
|
|
37
|
-
/**
|
|
38
|
-
* To creat a split button you would add a `DropdownMenu` as the last child. Its trigger should be a `Button`.
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* ButtonGroups can be passed `orientation="vertical"` to stack buttons vertically.
|
|
42
|
-
*/
|
|
43
|
-
export declare const Vertical: Story;
|
|
44
|
-
/**
|
|
45
|
-
* Vertical ButtonGroups can also contain a `DropdownMenu`.
|
|
46
|
-
*/
|
|
47
|
-
/**
|
|
48
|
-
* ButtonGroups also work with LinkButtons and ToggleButtons.
|
|
49
|
-
*
|
|
50
|
-
* However ToggleButton styling is not currently ideal as the divider is hard to see.
|
|
51
|
-
* 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.
|
|
52
|
-
*/
|
|
53
|
-
export declare const FillModes: Story;
|
|
@@ -27,9 +27,9 @@ export default meta;
|
|
|
27
27
|
export const Basic = {
|
|
28
28
|
args: {
|
|
29
29
|
children: (React.createElement(React.Fragment, null,
|
|
30
|
-
React.createElement(Button,
|
|
31
|
-
React.createElement(Button,
|
|
32
|
-
React.createElement(Button,
|
|
30
|
+
React.createElement(Button, null, "Button 1"),
|
|
31
|
+
React.createElement(Button, null, "Button 2"),
|
|
32
|
+
React.createElement(Button, null, "Button 3"))),
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
@@ -38,234 +38,6 @@ export const Basic = {
|
|
|
38
38
|
export const BasicOneButton = {
|
|
39
39
|
args: {
|
|
40
40
|
children: (React.createElement(React.Fragment, null,
|
|
41
|
-
React.createElement(Button,
|
|
41
|
+
React.createElement(Button, null, "Button 1"))),
|
|
42
42
|
},
|
|
43
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
|
-
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import '../../../tc.css';
|
|
3
4
|
export declare const ButtonGroup: ({ children, orientation, horizontalSizing, verticalSizing, className, }: {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
orientation?: "horizontal" | "vertical" | undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
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));
|
|
2
|
+
import '../../../tc.css';
|
|
3
|
+
export const ButtonGroup = ({ children, orientation = 'horizontal', horizontalSizing = 'hug', verticalSizing = 'hug', className, }) => React.createElement("div", { className: `flex gap-2 ${className}` }, children);
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { StoryObj } from '@storybook/react';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ align, side, children, content, avoidCollisions, alignOffset, sideOffset, disabled, delay,
|
|
5
|
+
component: ({ align, side, children, content, avoidCollisions, alignOffset, sideOffset, disabled, delay, className, }: React.PropsWithChildren<import("./Tooltip.types").TooltipProps>) => React.JSX.Element;
|
|
6
6
|
tags: string[];
|
|
7
7
|
parameters: {
|
|
8
8
|
docs: {
|
|
@@ -11,7 +11,6 @@ declare const meta: {
|
|
|
11
11
|
};
|
|
12
12
|
decorators: ((Story: import("@storybook/csf").PartialStoryFn<import("@storybook/react/dist/types-a5624094").R, {
|
|
13
13
|
className?: string | undefined;
|
|
14
|
-
padding?: "s" | "xl" | "l" | "m" | "custom" | undefined;
|
|
15
14
|
delay?: number | undefined;
|
|
16
15
|
side?: "top" | "right" | "bottom" | "left" | undefined;
|
|
17
16
|
sideOffset?: number | undefined;
|
|
@@ -56,9 +56,9 @@ export const JSXContent = {
|
|
|
56
56
|
},
|
|
57
57
|
render: () => (React.createElement("div", { style: { padding: '100px', display: 'flex', gap: '12px' } },
|
|
58
58
|
React.createElement(Tooltip, { side: "top", content: React.createElement(React.Fragment, null,
|
|
59
|
-
React.createElement(Button, { variant: "
|
|
59
|
+
React.createElement(Button, { variant: "solid" }, "\u2728\u2728\u2728"),
|
|
60
60
|
' ',
|
|
61
|
-
React.createElement(Button, { variant: "
|
|
61
|
+
React.createElement(Button, { variant: "solid" }, "\u2728\u2728\u2728")) },
|
|
62
62
|
React.createElement("span", null, "Fancy Tooltip")))),
|
|
63
63
|
};
|
|
64
64
|
export const JSXContentDifferentAlignments = {
|
|
@@ -72,11 +72,11 @@ export const JSXContentDifferentAlignments = {
|
|
|
72
72
|
},
|
|
73
73
|
render: () => (React.createElement("div", { style: { padding: '100px', display: 'flex', gap: '12px' } },
|
|
74
74
|
React.createElement(Tooltip, { side: "top", align: "start", content: React.createElement("span", null, "Tooltip") },
|
|
75
|
-
React.createElement(Button, { variant: "
|
|
75
|
+
React.createElement(Button, { variant: "solid" }, "Align Start")),
|
|
76
76
|
React.createElement(Tooltip, { side: "top", align: "center", content: React.createElement("span", null, "Tooltip") },
|
|
77
|
-
React.createElement(Button, { variant: "
|
|
77
|
+
React.createElement(Button, { variant: "solid" }, "Align Center")),
|
|
78
78
|
React.createElement(Tooltip, { side: "top", align: "end", content: React.createElement("span", null, "Tooltip") },
|
|
79
|
-
React.createElement(Button, { variant: "
|
|
79
|
+
React.createElement(Button, { variant: "solid" }, "Align End")))),
|
|
80
80
|
};
|
|
81
81
|
// export const JsxAsTrigger: Story = {
|
|
82
82
|
// parameters: {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
export type TooltipProps = {
|
|
3
3
|
/** custom classname to pass to the tooltip element */
|
|
4
4
|
className?: string;
|
|
5
|
-
/** padding within the tooltip element*/
|
|
6
|
-
padding?: 's' | 'm' | 'l' | 'xl' | 'custom';
|
|
7
5
|
/** The delay (in ms) before showing the tooltip */
|
|
8
6
|
delay?: number;
|
|
9
7
|
/** Sets the preferred position relative to the trigger */
|
|
@@ -5,7 +5,7 @@ import { TooltipProps } from './Tooltip.types';
|
|
|
5
5
|
/**
|
|
6
6
|
* The `Tooltip` must be nested somewhere inside the `TooltipProvider` in the component tree.
|
|
7
7
|
*/
|
|
8
|
-
export declare const Tooltip: ({ align, side, children, content, avoidCollisions, alignOffset, sideOffset, disabled, delay,
|
|
8
|
+
export declare const Tooltip: ({ align, side, children, content, avoidCollisions, alignOffset, sideOffset, disabled, delay, className, }: PropsWithChildren<TooltipProps>) => React.JSX.Element;
|
|
9
9
|
/**
|
|
10
10
|
* Wrap a UI tooltip element with TooltipProvider to give it a tooltip.
|
|
11
11
|
*/
|
|
@@ -14,4 +14,3 @@ export declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderP
|
|
|
14
14
|
* Exports a tooltip body element to match the full tooltip component.
|
|
15
15
|
* Useful when another library needs to be used for the tooltip trigger - eg AG-grid.
|
|
16
16
|
*/
|
|
17
|
-
export declare const TooltipBody: ({ children, padding, }: PropsWithChildren<Pick<TooltipProps, 'padding'>>) => React.JSX.Element;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import s from './Tooltip.module.css';
|
|
5
3
|
/**
|
|
6
4
|
* The `Tooltip` must be nested somewhere inside the `TooltipProvider` in the component tree.
|
|
7
5
|
*/
|
|
8
|
-
export const Tooltip = ({ align = 'center', side = 'bottom', children, content, avoidCollisions = true, alignOffset = 0, sideOffset = 5, disabled = false, delay = 400,
|
|
9
|
-
const classes = clsx(s.tooltip_content, s[`tooltip_padding_${padding}`], className);
|
|
6
|
+
export const Tooltip = ({ align = 'center', side = 'bottom', children, content, avoidCollisions = true, alignOffset = 0, sideOffset = 5, disabled = false, delay = 400, className, }) => {
|
|
10
7
|
const isChildrenString = typeof children === 'string';
|
|
11
8
|
return (React.createElement(TooltipPrimitive.Root, { delayDuration: delay },
|
|
12
|
-
React.createElement(TooltipPrimitive.Trigger, { asChild: !isChildrenString, disabled: disabled, className:
|
|
13
|
-
React.createElement(TooltipPrimitive.Portal, null, !disabled && content && (React.createElement(TooltipPrimitive.Content, { className:
|
|
9
|
+
React.createElement(TooltipPrimitive.Trigger, { asChild: !isChildrenString, disabled: disabled, className: className }, children),
|
|
10
|
+
React.createElement(TooltipPrimitive.Portal, null, !disabled && content && (React.createElement(TooltipPrimitive.Content, { className: className, avoidCollisions: avoidCollisions, side: side, align: align, alignOffset: alignOffset, sideOffset: sideOffset },
|
|
14
11
|
content,
|
|
15
|
-
React.createElement(TooltipPrimitive.Arrow, { className:
|
|
12
|
+
React.createElement(TooltipPrimitive.Arrow, { className: className }))))));
|
|
16
13
|
};
|
|
17
14
|
/**
|
|
18
15
|
* Wrap a UI tooltip element with TooltipProvider to give it a tooltip.
|
|
@@ -22,7 +19,10 @@ export const TooltipProvider = TooltipPrimitive.Provider;
|
|
|
22
19
|
* Exports a tooltip body element to match the full tooltip component.
|
|
23
20
|
* Useful when another library needs to be used for the tooltip trigger - eg AG-grid.
|
|
24
21
|
*/
|
|
25
|
-
export const TooltipBody = ({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
22
|
+
// export const TooltipBody = ({
|
|
23
|
+
// children,
|
|
24
|
+
// padding = 'l',
|
|
25
|
+
// }: PropsWithChildren<Pick<TooltipProps, 'padding'>>) => {
|
|
26
|
+
// const classes = className;
|
|
27
|
+
// return <div className={classes}>{children}</div>;
|
|
28
|
+
// };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import '../tc.css';
|
|
2
2
|
import * as Form from './atoms/form/form.component';
|
|
3
3
|
export * from './atoms/button/button.component';
|
|
4
|
-
export * from './atoms/button/linkButton.component';
|
|
5
|
-
export * from './atoms/button/toggleButton.component';
|
|
6
4
|
export * from './atoms/button/buttonGroup/buttonGroup.component';
|
|
7
5
|
export * from './atoms/check-box/checkBox.component';
|
|
8
6
|
export * from './atoms/date-picker/date-picker.component';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import '../tc.css';
|
|
2
2
|
import * as Form from './atoms/form/form.component';
|
|
3
3
|
export * from './atoms/button/button.component';
|
|
4
|
-
export * from './atoms/button/linkButton.component';
|
|
5
|
-
export * from './atoms/button/toggleButton.component';
|
|
6
4
|
export * from './atoms/button/buttonGroup/buttonGroup.component';
|
|
7
5
|
export * from './atoms/check-box/checkBox.component';
|
|
8
6
|
export * from './atoms/date-picker/date-picker.component';
|