@conveyorhq/arrow-ds 2.0.0-beta.7 → 2.0.0-beta.9
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 +15 -14
- package/public/components/Accordion/Accordion.js +8 -10
- package/public/components/Avatar/Avatar.js +20 -19
- package/public/components/Button/Button.js +2 -2
- package/public/components/ConveyorLogo/ConveyorLogo.js +6 -6
- package/public/components/Drawer/Drawer.js +7 -7
- package/public/components/Frame/Frame.d.ts +1 -1
- package/public/components/Icon/Icon.d.ts +1 -0
- package/public/components/Icon/Icon.js +3 -1
- package/public/components/MenuRenderer/MenuRenderer.js +4 -7
- package/public/components/Modal/Modal.js +1 -1
- package/public/components/OptionButton/OptionButton.js +18 -13
- package/public/components/Select/Select.js +4 -4
- package/public/components/Select/SelectPopover.js +6 -6
- package/public/components/Select/index.d.ts +2 -0
- package/public/components/Select/index.js +3 -0
- package/public/components/Select/theme.js +22 -22
- package/public/components/Svg/Svg.d.ts +3 -3
- package/public/components/Svg/Svg.js +1 -2
- package/public/components/Tooltip/Tooltip.js +11 -19
- package/public/components/VisuallyHidden/VisuallyHidden.d.ts +2 -1
- package/public/components/VisuallyHidden/VisuallyHidden.js +3 -5
- package/public/css/styles.css +139 -59
- package/public/css/styles.min.css +1 -1
- package/public/css/styles.min.css.map +1 -1
- package/public/hooks/index.d.ts +3 -0
- package/public/hooks/index.js +7 -1
- package/public/hooks/useMatchMedia.d.ts +1 -0
- package/public/hooks/useMatchMedia.js +27 -0
- package/public/hooks/usePrefersReducedMotion.d.ts +1 -0
- package/public/hooks/usePrefersReducedMotion.js +9 -0
- package/public/hooks/useScreenOrientation.d.ts +1 -0
- package/public/hooks/useScreenOrientation.js +24 -0
- package/public/{style-dictionary → src/style-dictionary}/dist/tokens.css +1 -0
- package/public/src/style-dictionary/dist/tokens.d.ts +428 -0
- package/public/src/style-dictionary/dist/tokens.js +428 -0
- package/public/src/style-dictionary/dist/tokens.module.js +428 -0
- package/public/src/style-dictionary/tailwind.config.js +87 -0
- package/public/storybook-components/EnumTable.js +2 -1
- package/public/storybook-components/Story.d.ts +2 -1
- package/public/storybook-components/Story.js +4 -1
- package/public/style-dictionary/dist/tokens.d.ts +428 -422
- package/public/style-dictionary/dist/tokens.js +415 -416
- package/public/style-dictionary/dist/tokens.module.d.ts +431 -0
- package/public/style-dictionary/dist/tokens.module.js +412 -415
- package/public/style-dictionary/src/border-radius.d.ts +31 -0
- package/public/style-dictionary/src/border-radius.js +10 -9
- package/public/style-dictionary/src/border-width.d.ts +21 -0
- package/public/style-dictionary/src/border-width.js +9 -8
- package/public/style-dictionary/src/color.d.ts +249 -0
- package/public/style-dictionary/src/color.js +97 -95
- package/public/style-dictionary/src/font-size.d.ts +45 -0
- package/public/style-dictionary/src/font-size.js +14 -13
- package/public/style-dictionary/src/font-weight.d.ts +13 -0
- package/public/style-dictionary/src/font-weight.js +6 -5
- package/public/style-dictionary/src/height.d.ts +215 -0
- package/public/style-dictionary/src/height.js +10 -10
- package/public/style-dictionary/src/leading.d.ts +17 -0
- package/public/style-dictionary/src/leading.js +7 -6
- package/public/style-dictionary/src/screen-width.d.ts +17 -0
- package/public/style-dictionary/src/screen-width.js +7 -6
- package/public/style-dictionary/src/shadow.d.ts +63 -0
- package/public/style-dictionary/src/shadow.js +19 -18
- package/public/style-dictionary/src/spacing.d.ts +197 -0
- package/public/style-dictionary/src/spacing.js +68 -67
- package/public/style-dictionary/src/tracking.d.ts +13 -0
- package/public/style-dictionary/src/tracking.js +6 -5
- package/public/style-dictionary/src/type.d.ts +13 -0
- package/public/style-dictionary/src/type.js +32 -31
- package/public/style-dictionary/src/width.d.ts +287 -0
- package/public/style-dictionary/src/width.js +29 -29
- package/public/style-dictionary/src/z-index.d.ts +53 -0
- package/public/style-dictionary/src/z-index.js +20 -19
- package/public/style-dictionary/tailwind.config.d.ts +392 -0
- package/public/style-dictionary/tailwind.config.js +51 -72
- package/src/components/Accordion/Accordion.tsx +39 -27
- package/src/components/Avatar/Avatar.tsx +20 -19
- package/src/components/Button/Button.tsx +3 -3
- package/src/components/Button/index.css +12 -1
- package/src/components/Card/Card.story.mdx +45 -37
- package/src/components/ConveyorLogo/ConveyorLogo.tsx +6 -6
- package/src/components/Drawer/Drawer.tsx +1 -1
- package/src/components/Frame/Frame.story.mdx +140 -5
- package/src/components/Frame/Frame.tsx +1 -1
- package/src/components/Frame/index.css +8 -13
- package/src/components/Icon/Icon.tsx +3 -0
- package/src/components/MenuRenderer/MenuRenderer.tsx +7 -9
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/components/Modal/index.css +8 -3
- package/src/components/OptionButton/OptionButton.story.mdx +91 -36
- package/src/components/OptionButton/OptionButton.tsx +19 -18
- package/src/components/OptionButton/index.css +13 -0
- package/src/components/Overlay/Overlay.story.mdx +26 -0
- package/src/components/Select/Select.tsx +4 -4
- package/src/components/Select/SelectPopover.tsx +6 -6
- package/src/components/Select/index.ts +14 -0
- package/src/components/Select/theme.ts +22 -22
- package/src/components/Svg/Svg.story.mdx +36 -0
- package/src/components/Svg/Svg.tsx +6 -4
- package/src/components/Text/Text.story.mdx +34 -0
- package/src/components/Tooltip/Tooltip.story.mdx +21 -0
- package/src/components/Tooltip/Tooltip.tsx +23 -27
- package/src/components/Tooltip/index.css +31 -0
- package/src/components/VisuallyHidden/VisuallyHidden.story.mdx +54 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +10 -5
- package/src/components/VisuallyHidden/index.css +3 -0
- package/src/css/components.css +2 -0
- package/src/docs/Colors.story.mdx +13 -13
- package/src/docs/Spacing.story.mdx +4 -20
- package/src/docs/Tokens.story.mdx +230 -0
- package/src/docs/Typography.story.mdx +17 -94
- package/src/docs/hooks/useDisclosureHook.story.mdx +58 -0
- package/src/docs/hooks/useKeyPressHook.story.mdx +54 -0
- package/src/docs/hooks/useMatchMediaHook.story.mdx +42 -0
- package/src/docs/hooks/useOutsideClickHook.story.mdx +56 -0
- package/src/docs/hooks/usePrefersReducedMotion.story.mdx +61 -0
- package/src/docs/hooks/useScreenOrientationHook.story.mdx +56 -0
- package/src/docs/hooks/useStepHook.story.mdx +102 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useMatchMedia.ts +40 -0
- package/src/hooks/usePrefersReducedMotion.ts +9 -0
- package/src/hooks/useScreenOrientation.ts +27 -0
- package/src/storybook-components/EnumTable.tsx +3 -2
- package/src/storybook-components/Story.tsx +13 -1
- package/src/style-dictionary/dist/tokens.css +378 -0
- package/src/style-dictionary/dist/tokens.d.ts +428 -0
- package/src/style-dictionary/dist/tokens.js +428 -0
- package/src/style-dictionary/dist/tokens.module.js +428 -0
- package/src/style-dictionary/src/border-radius.js +11 -0
- package/src/style-dictionary/src/border-width.js +10 -0
- package/src/style-dictionary/src/color.js +98 -0
- package/src/style-dictionary/src/font-size.js +15 -0
- package/src/style-dictionary/src/font-weight.js +7 -0
- package/src/style-dictionary/src/height.js +13 -0
- package/src/style-dictionary/src/leading.js +8 -0
- package/src/style-dictionary/src/screen-width.js +8 -0
- package/src/style-dictionary/src/shadow.js +19 -0
- package/src/style-dictionary/src/spacing.js +69 -0
- package/src/style-dictionary/src/tracking.js +7 -0
- package/src/style-dictionary/src/type.js +34 -0
- package/src/style-dictionary/src/width.js +32 -0
- package/src/style-dictionary/src/z-index.js +21 -0
- package/src/style-dictionary/tailwind.config.js +87 -0
- package/src/tokens/borders.ts +6 -0
- package/src/tokens/box-shadow.ts +3 -0
- package/src/tokens/colors.ts +6 -0
- package/src/tokens/font-family.ts +3 -0
- package/src/tokens/font-size.ts +3 -0
- package/src/tokens/font-weight.ts +3 -0
- package/src/tokens/height.ts +3 -0
- package/src/tokens/index.ts +3 -2
- package/src/tokens/letter-spacing.ts +3 -0
- package/src/tokens/line-height.ts +3 -0
- package/src/tokens/margin.ts +3 -0
- package/src/tokens/padding.ts +3 -0
- package/src/tokens/screens.ts +3 -0
- package/src/tokens/sizing-scale.ts +6 -0
- package/src/tokens/width.ts +9 -0
- package/src/tokens/will-change.ts +3 -0
- package/src/tokens/z-index.ts +3 -0
- package/src/types/index.ts +3 -0
- package/public/components/Overlay/Overlay.story.d.ts +0 -1
- package/public/components/Overlay/Overlay.story.js +0 -12
- package/public/components/Svg/Svg.story.d.ts +0 -1
- package/public/components/Svg/Svg.story.js +0 -14
- package/public/components/Text/Text.story.d.ts +0 -1
- package/public/components/Text/Text.story.js +0 -31
- package/public/components/VisuallyHidden/VisuallyHidden.story.d.ts +0 -1
- package/public/components/VisuallyHidden/VisuallyHidden.story.js +0 -36
- package/public/components/useStep/ExampleSetupWizard.d.ts +0 -4
- package/public/components/useStep/ExampleSetupWizard.js +0 -33
- package/src/components/Overlay/Overlay.md +0 -14
- package/src/components/Overlay/Overlay.story.tsx +0 -12
- package/src/components/Svg/Svg.md +0 -14
- package/src/components/Svg/Svg.story.tsx +0 -15
- package/src/components/Text/Text.md +0 -14
- package/src/components/Text/Text.story.tsx +0 -12
- package/src/components/VisuallyHidden/VisuallyHidden.md +0 -23
- package/src/components/VisuallyHidden/VisuallyHidden.story.tsx +0 -19
- package/src/components/useStep/ExampleSetupWizard.tsx +0 -63
- package/src/components/useStep/useStep.story.mdx +0 -76
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
2
|
import Overlay from "react-overlays/Overlay";
|
|
4
3
|
import { useId } from "@reach/auto-id";
|
|
5
4
|
|
|
6
5
|
import { KEY_CODE, PopperPlacement } from "../../types";
|
|
7
6
|
import { useDisclosure, useKeyPress } from "../../hooks";
|
|
8
|
-
import { mergeEventHandlers } from "../../utilities";
|
|
7
|
+
import { bemHOF, mergeEventHandlers } from "../../utilities";
|
|
8
|
+
import { tokens } from "../../style-dictionary/dist/tokens";
|
|
9
9
|
|
|
10
10
|
import { Box } from "../Box";
|
|
11
11
|
|
|
12
|
+
const cn = bemHOF("Tooltip");
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Tooltip.Arrow
|
|
14
16
|
* =============================================================================
|
|
@@ -23,19 +25,19 @@ const TooltipArrow = React.forwardRef<HTMLDivElement, TooltipArrowProps>(
|
|
|
23
25
|
({ placement, style }, forwaredRef) => {
|
|
24
26
|
const generatePositionStyles = () => {
|
|
25
27
|
if (placement.startsWith("top")) {
|
|
26
|
-
return { bottom:
|
|
28
|
+
return { bottom: `-${tokens.spacing[1]}`, left: 0 };
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
if (placement.startsWith("right")) {
|
|
30
|
-
return { left:
|
|
32
|
+
return { left: `-${tokens.spacing[1]}`, top: 0 };
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
if (placement.startsWith("bottom")) {
|
|
34
|
-
return { top:
|
|
36
|
+
return { top: `-${tokens.spacing[1]}`, left: 0 };
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
if (placement.startsWith("left")) {
|
|
38
|
-
return { right:
|
|
40
|
+
return { right: `-${tokens.spacing[1]}`, top: 0 };
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
return {};
|
|
@@ -46,18 +48,13 @@ const TooltipArrow = React.forwardRef<HTMLDivElement, TooltipArrowProps>(
|
|
|
46
48
|
return (
|
|
47
49
|
<Box
|
|
48
50
|
ref={forwaredRef}
|
|
49
|
-
className=
|
|
51
|
+
className={cn({ e: "arrow" })}
|
|
50
52
|
style={{
|
|
51
53
|
...style,
|
|
52
54
|
...positionStyles,
|
|
53
55
|
}}
|
|
54
56
|
>
|
|
55
|
-
<Box
|
|
56
|
-
className="absolute w-2 h-2 top-0 left-0 bg-gray-900"
|
|
57
|
-
style={{
|
|
58
|
-
transform: "rotate(45deg)",
|
|
59
|
-
}}
|
|
60
|
-
/>
|
|
57
|
+
<Box />
|
|
61
58
|
</Box>
|
|
62
59
|
);
|
|
63
60
|
},
|
|
@@ -171,11 +168,14 @@ export const Tooltip = ({
|
|
|
171
168
|
onMouseDown: mergeEventHandlers(onMouseDown, onHideDelay),
|
|
172
169
|
onFocus: mergeEventHandlers(onFocus, onShow),
|
|
173
170
|
onBlur: mergeEventHandlers(onBlur, onHide),
|
|
174
|
-
onKeyDown: mergeEventHandlers(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
onKeyDown: mergeEventHandlers(
|
|
172
|
+
onKeyDown,
|
|
173
|
+
(event: React.KeyboardEvent<HTMLElement>) => {
|
|
174
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
175
|
+
onHide();
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
),
|
|
179
179
|
...rest,
|
|
180
180
|
});
|
|
181
181
|
|
|
@@ -194,7 +194,7 @@ export const Tooltip = ({
|
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
-
return (
|
|
197
|
+
return content ? (
|
|
198
198
|
<Box ref={rootRef}>
|
|
199
199
|
{React.cloneElement(React.Children.only(children), {
|
|
200
200
|
...triggerProps(children.props),
|
|
@@ -219,14 +219,8 @@ export const Tooltip = ({
|
|
|
219
219
|
return (
|
|
220
220
|
<Box
|
|
221
221
|
id={id}
|
|
222
|
-
className={
|
|
223
|
-
|
|
224
|
-
"text-bodySm leading-normal",
|
|
225
|
-
"inline-flex items-center",
|
|
226
|
-
"rounded shadow-popover",
|
|
227
|
-
"px-3 py-2",
|
|
228
|
-
"relative z-popup",
|
|
229
|
-
])}
|
|
222
|
+
className={cn()}
|
|
223
|
+
data-component="tooltip"
|
|
230
224
|
onMouseEnter={handlePopoverMouseEnter}
|
|
231
225
|
onMouseLeave={handlePopoverMouseLeave}
|
|
232
226
|
{...contentProps}
|
|
@@ -243,5 +237,7 @@ export const Tooltip = ({
|
|
|
243
237
|
</Overlay>
|
|
244
238
|
)}
|
|
245
239
|
</Box>
|
|
240
|
+
) : (
|
|
241
|
+
children
|
|
246
242
|
);
|
|
247
243
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.ads-Tooltip {
|
|
2
|
+
@apply bg-gray-900
|
|
3
|
+
text-white
|
|
4
|
+
text-bodySm
|
|
5
|
+
leading-normal
|
|
6
|
+
inline-flex
|
|
7
|
+
items-center
|
|
8
|
+
rounded
|
|
9
|
+
shadow-popover
|
|
10
|
+
px-3
|
|
11
|
+
py-2
|
|
12
|
+
z-popup
|
|
13
|
+
max-w-64;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ads-Tooltip-arrow {
|
|
17
|
+
@apply w-2
|
|
18
|
+
h-2
|
|
19
|
+
z-below;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.ads-Tooltip-arrow > div {
|
|
23
|
+
@apply absolute
|
|
24
|
+
w-2
|
|
25
|
+
h-2
|
|
26
|
+
top-0
|
|
27
|
+
left-0
|
|
28
|
+
bg-gray-900;
|
|
29
|
+
|
|
30
|
+
transform: rotate(45deg);
|
|
31
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Story,
|
|
3
|
+
Preview,
|
|
4
|
+
Props,
|
|
5
|
+
Meta,
|
|
6
|
+
SourceState,
|
|
7
|
+
} from "@storybook/addon-docs/blocks";
|
|
8
|
+
import { Box } from "../Box";
|
|
9
|
+
import { Icon, ICON_TYPE } from "../Icon";
|
|
10
|
+
import { VisuallyHidden } from "./VisuallyHidden";
|
|
11
|
+
|
|
12
|
+
<Meta
|
|
13
|
+
title="Components/Disclosure/Visually Hidden"
|
|
14
|
+
component={VisuallyHidden}
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
# VisuallyHidden
|
|
18
|
+
|
|
19
|
+
`VisuallyHidden` is a way to show content to screen readers but hide it from the
|
|
20
|
+
screen.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
import { VisuallyHidden } from "@conveyorhq/arrow-ds";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Basic usage
|
|
29
|
+
|
|
30
|
+
<Preview withSource={SourceState.OPEN}>
|
|
31
|
+
<Story name="VisuallyHidden">
|
|
32
|
+
<Box>Visible content</Box>
|
|
33
|
+
<VisuallyHidden>Hidden content</VisuallyHidden>
|
|
34
|
+
</Story>
|
|
35
|
+
</Preview>
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
Extends `BoxProps`
|
|
40
|
+
|
|
41
|
+
<Props of={VisuallyHidden} />
|
|
42
|
+
|
|
43
|
+
## Demos
|
|
44
|
+
|
|
45
|
+
Providing more context to an icon.
|
|
46
|
+
|
|
47
|
+
<Preview withSource={SourceState.OPEN}>
|
|
48
|
+
<Story name="VisuallyHidden icon">
|
|
49
|
+
<Box>
|
|
50
|
+
<Icon icon={ICON_TYPE.COG} />
|
|
51
|
+
<VisuallyHidden>Settings</VisuallyHidden>
|
|
52
|
+
</Box>
|
|
53
|
+
</Story>
|
|
54
|
+
</Preview>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import classNames from "classnames";
|
|
3
3
|
import { Box, BoxProps } from "../Box";
|
|
4
|
+
import { bemHOF } from "../../utilities";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const cn = bemHOF("VisuallyHidden");
|
|
7
|
+
|
|
8
|
+
export const VisuallyHidden: React.FunctionComponent<BoxProps> = React.forwardRef<
|
|
9
|
+
HTMLDivElement,
|
|
10
|
+
BoxProps
|
|
11
|
+
>(({ className, ...rest }, forwardedRef) => (
|
|
12
|
+
<Box ref={forwardedRef} className={classNames(cn(), className)} {...rest} />
|
|
13
|
+
));
|
package/src/css/components.css
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Meta, ColorPalette, ColorItem } from "@storybook/addon-docs/blocks";
|
|
2
2
|
import { CustomColorPalette } from "../storybook-components/CustomColorPalette";
|
|
3
|
-
import {
|
|
3
|
+
import { tokens } from "../style-dictionary/dist/tokens";
|
|
4
4
|
|
|
5
|
-
<Meta title="
|
|
5
|
+
<Meta title="Styles/Colors" />
|
|
6
6
|
|
|
7
7
|
export const palette = (color, range = [200, 600]) => {
|
|
8
8
|
const offset = (range[0] - 100) / 100;
|
|
@@ -12,15 +12,15 @@ export const palette = (color, range = [200, 600]) => {
|
|
|
12
12
|
const object = {};
|
|
13
13
|
array.forEach((n) => {
|
|
14
14
|
Object.assign(object, {
|
|
15
|
-
[n * 100]:
|
|
15
|
+
[n * 100]: tokens.color[color][n * 100],
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
return object;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export const bw = {
|
|
22
|
-
black:
|
|
23
|
-
white:
|
|
22
|
+
black: tokens.color.black,
|
|
23
|
+
white: tokens.color.white,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export const grays = palette("gray", [100, 900]);
|
|
@@ -35,26 +35,26 @@ export const cyan = palette("cyan");
|
|
|
35
35
|
export const purple = palette("purple");
|
|
36
36
|
|
|
37
37
|
export const lighten = {
|
|
38
|
-
100:
|
|
39
|
-
200:
|
|
40
|
-
300:
|
|
38
|
+
100: tokens.color.lighten["100"],
|
|
39
|
+
200: tokens.color.lighten["200"],
|
|
40
|
+
300: tokens.color.lighten["300"],
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export const functional = {
|
|
44
44
|
border: {
|
|
45
|
-
border:
|
|
45
|
+
border: tokens.color.border,
|
|
46
46
|
},
|
|
47
47
|
link: {
|
|
48
|
-
link:
|
|
48
|
+
link: tokens.color.link,
|
|
49
49
|
},
|
|
50
50
|
success: {
|
|
51
|
-
success:
|
|
51
|
+
success: tokens.color.success,
|
|
52
52
|
},
|
|
53
53
|
failure: {
|
|
54
|
-
failure:
|
|
54
|
+
failure: tokens.color.failure,
|
|
55
55
|
},
|
|
56
56
|
caution: {
|
|
57
|
-
caution:
|
|
57
|
+
caution: tokens.color.caution,
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { padding } from "../tokens/padding";
|
|
3
2
|
import { SimpleTable } from "../components/SimpleTable";
|
|
4
3
|
|
|
5
|
-
<Meta title="
|
|
4
|
+
<Meta title="Styles/Spacing" />
|
|
6
5
|
|
|
7
6
|
export const Table = ({ children, columns }) => (
|
|
8
7
|
<SimpleTable className="w-1/2">
|
|
@@ -35,22 +34,7 @@ The follow values can be used for `margin`, `padding` and `gap`.
|
|
|
35
34
|
|
|
36
35
|
`margin` also includes a negative scale and the `auto` keyword.
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
{Object.keys(padding).map((key) => (
|
|
40
|
-
<Row key={key}>
|
|
41
|
-
<Cell>
|
|
42
|
-
<code>{key}</code>
|
|
43
|
-
</Cell>
|
|
44
|
-
<Cell>
|
|
45
|
-
<code>{padding[key]}</code>
|
|
46
|
-
</Cell>
|
|
47
|
-
</Row>
|
|
48
|
-
))}
|
|
49
|
-
</Table>
|
|
50
|
-
|
|
51
|
-
## Using spacing tokens
|
|
52
|
-
|
|
53
|
-
### Margin
|
|
37
|
+
## Margin
|
|
54
38
|
|
|
55
39
|
Margin controls the spacing on the outside of an element.
|
|
56
40
|
|
|
@@ -99,7 +83,7 @@ Margin controls the spacing on the outside of an element.
|
|
|
99
83
|
</Row>
|
|
100
84
|
</Table>
|
|
101
85
|
|
|
102
|
-
|
|
86
|
+
## Padding
|
|
103
87
|
|
|
104
88
|
Padding controls the spacing on the inside of an element.
|
|
105
89
|
|
|
@@ -148,7 +132,7 @@ Padding controls the spacing on the inside of an element.
|
|
|
148
132
|
</Row>
|
|
149
133
|
</Table>
|
|
150
134
|
|
|
151
|
-
|
|
135
|
+
## Gap
|
|
152
136
|
|
|
153
137
|
Gap is used to space items within grid and flexbox layouts.
|
|
154
138
|
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import { tokens } from "../style-dictionary/dist/tokens";
|
|
3
|
+
import { Button, SimpleTable, Tooltip, BUTTON_VARIANT, ICON_TYPE } from "../..";
|
|
4
|
+
|
|
5
|
+
<Meta title="Documentation/Tokens" />
|
|
6
|
+
|
|
7
|
+
export const categories = Object.keys(tokens);
|
|
8
|
+
|
|
9
|
+
export const copyToClipboard = (text) => {
|
|
10
|
+
navigator.clipboard.writeText(text);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ClickToCopy = ({ text }) => {
|
|
14
|
+
const [copied, setCopied] = React.useState(false);
|
|
15
|
+
const renderProps = {
|
|
16
|
+
onMouseOut: () => setCopied(false),
|
|
17
|
+
onBlur: () => setCopied(false),
|
|
18
|
+
onClick: () => {
|
|
19
|
+
copyToClipboard(text);
|
|
20
|
+
setCopied(true);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return (
|
|
24
|
+
<Tooltip
|
|
25
|
+
placement="top"
|
|
26
|
+
referenceElement={
|
|
27
|
+
<Button
|
|
28
|
+
variant={BUTTON_VARIANT.MINIMAL}
|
|
29
|
+
icon={ICON_TYPE.CLIPBOARD}
|
|
30
|
+
{...renderProps}
|
|
31
|
+
/>
|
|
32
|
+
}
|
|
33
|
+
>
|
|
34
|
+
{copied ? "Copied!" : "Copy token path"}
|
|
35
|
+
</Tooltip>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Swatch = ({ color }) => (
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
width: "21px",
|
|
43
|
+
height: "21px",
|
|
44
|
+
borderRadius: "3px",
|
|
45
|
+
backgroundColor: color,
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const Table = ({ children, columns }) => (
|
|
51
|
+
<SimpleTable style={{ width: "100%" }}>
|
|
52
|
+
{columns && (
|
|
53
|
+
<SimpleTable.Row>
|
|
54
|
+
{columns.map((column, i) => (
|
|
55
|
+
<SimpleTable.HeaderCell
|
|
56
|
+
key={column}
|
|
57
|
+
style={{
|
|
58
|
+
width: i === columns.length - 1 ? "auto" : "50%",
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
{column}
|
|
62
|
+
</SimpleTable.HeaderCell>
|
|
63
|
+
))}
|
|
64
|
+
</SimpleTable.Row>
|
|
65
|
+
)}
|
|
66
|
+
{children}
|
|
67
|
+
</SimpleTable>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
export const Row = ({ children, style }) => (
|
|
71
|
+
<SimpleTable.Row
|
|
72
|
+
style={{
|
|
73
|
+
borderBottom: `1px solid ${tokens.color.gray[300]}`,
|
|
74
|
+
verticalAlign: "top",
|
|
75
|
+
...style,
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</SimpleTable.Row>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
export const Cell = ({ children, ...rest }) => (
|
|
83
|
+
<SimpleTable.Cell {...rest}>{children}</SimpleTable.Cell>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
# Tokens
|
|
87
|
+
|
|
88
|
+
These tokens are normally used in JavaScript. In almost all cases, you’ll
|
|
89
|
+
want to use the Tailwind CSS utility classnames instead.
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
import { tokens } from "@conveyorhq/design-tokens";
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
export const titleize = (string) => {
|
|
98
|
+
const title = string.replace(/([A-Z])/g, " $1").toLowerCase();
|
|
99
|
+
return `${title.charAt(0).toUpperCase()}${title.slice(1)}`;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
<ul
|
|
103
|
+
style={{
|
|
104
|
+
listStyle: "none",
|
|
105
|
+
padding: 0,
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{categories.map((category) => (
|
|
109
|
+
<li key={category}>
|
|
110
|
+
<a href={`#${category}`}>
|
|
111
|
+
{titleize(category)}
|
|
112
|
+
{category === "leading" && " (line height)"}
|
|
113
|
+
{category === "screenWidth" && " (breakpoints)"}
|
|
114
|
+
{category === "tracking" && " (letter spacing)"}
|
|
115
|
+
{category === "type" && " (font family)"}
|
|
116
|
+
</a>
|
|
117
|
+
</li>
|
|
118
|
+
))}
|
|
119
|
+
</ul>
|
|
120
|
+
|
|
121
|
+
<div>
|
|
122
|
+
<br />
|
|
123
|
+
<br />
|
|
124
|
+
{categories.map((category) => (
|
|
125
|
+
<div key={category} id={category}>
|
|
126
|
+
<h2>
|
|
127
|
+
{titleize(category)}
|
|
128
|
+
{category === "leading" && " (line height)"}
|
|
129
|
+
{category === "screenWidth" && " (breakpoints)"}
|
|
130
|
+
{category === "tracking" && " (letter spacing)"}
|
|
131
|
+
{category === "type" && " (font family)"}
|
|
132
|
+
</h2>
|
|
133
|
+
<p>
|
|
134
|
+
{category === "color" ? (
|
|
135
|
+
<>
|
|
136
|
+
<code>tokens.{category}[key]</code> or{" "}
|
|
137
|
+
<code>tokens.{category}[key][key]</code>
|
|
138
|
+
</>
|
|
139
|
+
) : (
|
|
140
|
+
<code>tokens.{category}[key]</code>
|
|
141
|
+
)}
|
|
142
|
+
</p>
|
|
143
|
+
{category === "fontWeight" && (
|
|
144
|
+
<p>Weight can only be applied to Neue Montreal.</p>
|
|
145
|
+
)}
|
|
146
|
+
<Table columns={["Key", "Value", ""]}>
|
|
147
|
+
{Object.keys(tokens[category]).map((key) => (
|
|
148
|
+
<Row key={key}>
|
|
149
|
+
<Cell>
|
|
150
|
+
<code>{key}</code>
|
|
151
|
+
</Cell>
|
|
152
|
+
<Cell
|
|
153
|
+
colspan={typeof tokens[category][key] === "object" ? 2 : null}
|
|
154
|
+
>
|
|
155
|
+
{typeof tokens[category][key] === "object" ? (
|
|
156
|
+
<Table>
|
|
157
|
+
{Object.keys(tokens[category][key]).map((k, i) => (
|
|
158
|
+
<Row
|
|
159
|
+
key={k}
|
|
160
|
+
style={
|
|
161
|
+
i === Object.keys(tokens[category][key]).length - 1
|
|
162
|
+
? {
|
|
163
|
+
borderBottom: 0,
|
|
164
|
+
}
|
|
165
|
+
: {}
|
|
166
|
+
}
|
|
167
|
+
>
|
|
168
|
+
<Cell style={{ width: "50%" }}>
|
|
169
|
+
<code>{k}</code>
|
|
170
|
+
</Cell>
|
|
171
|
+
<Cell style={{ width: "50%" }}>
|
|
172
|
+
<div style={{ display: "flex", gap: "4px" }}>
|
|
173
|
+
<code>{tokens[category][key][k]}</code>
|
|
174
|
+
{category === "color" && (
|
|
175
|
+
<Swatch color={tokens[category][key][k]} />
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
178
|
+
</Cell>
|
|
179
|
+
<Cell style={{ width: "auto" }}>
|
|
180
|
+
{typeof tokens[category][key][k] !== "object" && (
|
|
181
|
+
<>
|
|
182
|
+
{isNaN(parseInt(k, 10)) ? (
|
|
183
|
+
<ClickToCopy
|
|
184
|
+
text={`tokens.${category}.${key}.${k}`}
|
|
185
|
+
/>
|
|
186
|
+
) : (
|
|
187
|
+
<ClickToCopy
|
|
188
|
+
text={`tokens.${category}.${key}[${k}]`}
|
|
189
|
+
/>
|
|
190
|
+
)}
|
|
191
|
+
</>
|
|
192
|
+
)}
|
|
193
|
+
</Cell>
|
|
194
|
+
</Row>
|
|
195
|
+
))}
|
|
196
|
+
</Table>
|
|
197
|
+
) : (
|
|
198
|
+
<div style={{ display: "flex", gap: "4px" }}>
|
|
199
|
+
{category === "type" ? (
|
|
200
|
+
<code>
|
|
201
|
+
<pre style={{ fontSize: "inherit" }}>
|
|
202
|
+
{tokens[category][key].replaceAll(", ", ",\n")}
|
|
203
|
+
</pre>
|
|
204
|
+
</code>
|
|
205
|
+
) : (
|
|
206
|
+
<code>{tokens[category][key]}</code>
|
|
207
|
+
)}
|
|
208
|
+
{category === "color" && (
|
|
209
|
+
<Swatch color={tokens[category][key]} />
|
|
210
|
+
)}
|
|
211
|
+
</div>
|
|
212
|
+
)}
|
|
213
|
+
</Cell>
|
|
214
|
+
{typeof tokens[category][key] !== "object" && (
|
|
215
|
+
<Cell style={{ textAlign: "right" }}>
|
|
216
|
+
{isNaN(parseInt(key, 10)) ? (
|
|
217
|
+
<ClickToCopy text={`tokens.${category}.${key}`} />
|
|
218
|
+
) : (
|
|
219
|
+
<ClickToCopy text={`tokens.${category}[${key}]`} />
|
|
220
|
+
)}
|
|
221
|
+
</Cell>
|
|
222
|
+
)}
|
|
223
|
+
</Row>
|
|
224
|
+
))}
|
|
225
|
+
</Table>
|
|
226
|
+
<br />
|
|
227
|
+
<br />
|
|
228
|
+
</div>
|
|
229
|
+
))}
|
|
230
|
+
</div>
|