@noya-app/noya-designsystem 0.1.30 → 0.1.32

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 (64) hide show
  1. package/.turbo/turbo-build.log +20 -12
  2. package/.turbo/turbo-lint.log +15 -1
  3. package/CHANGELOG.md +17 -0
  4. package/README.md +13 -1
  5. package/dist/index.css +1 -0
  6. package/dist/index.d.ts +238 -627
  7. package/dist/index.js +4259 -2862
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4159 -2764
  10. package/dist/index.mjs.map +1 -1
  11. package/package.json +17 -7
  12. package/src/components/ActivityIndicator.tsx +4 -36
  13. package/src/components/Avatar.tsx +63 -62
  14. package/src/components/Button.tsx +53 -170
  15. package/src/components/Chip.tsx +117 -150
  16. package/src/components/ContextMenu.tsx +13 -35
  17. package/src/components/Dialog.tsx +66 -54
  18. package/src/components/Divider.tsx +31 -41
  19. package/src/components/DraggableMenuButton.tsx +29 -30
  20. package/src/components/DropdownMenu.tsx +30 -40
  21. package/src/components/FillInputField.tsx +16 -26
  22. package/src/components/FillPreviewBackground.tsx +18 -22
  23. package/src/components/FloatingWindow.tsx +4 -7
  24. package/src/components/GridView.tsx +70 -200
  25. package/src/components/IconButton.tsx +1 -5
  26. package/src/components/InputField.tsx +258 -234
  27. package/src/components/InputFieldWithCompletions.tsx +20 -27
  28. package/src/components/InspectorContainer.tsx +4 -9
  29. package/src/components/InspectorPrimitives.tsx +135 -109
  30. package/src/components/Label.tsx +5 -36
  31. package/src/components/LabeledElementView.tsx +5 -26
  32. package/src/components/ListView.tsx +239 -167
  33. package/src/components/Popover.tsx +15 -39
  34. package/src/components/Progress.tsx +21 -44
  35. package/src/components/RadioGroup.tsx +6 -71
  36. package/src/components/ScrollArea.tsx +11 -39
  37. package/src/components/SelectMenu.tsx +72 -32
  38. package/src/components/Slider.tsx +7 -43
  39. package/src/components/Spacer.tsx +6 -18
  40. package/src/components/Switch.tsx +4 -42
  41. package/src/components/Text.tsx +31 -66
  42. package/src/components/TextArea.tsx +5 -31
  43. package/src/components/Toast.tsx +15 -57
  44. package/src/components/Tooltip.tsx +4 -13
  45. package/src/components/WorkspaceLayout.tsx +27 -17
  46. package/src/components/internal/Menu.tsx +37 -83
  47. package/src/contexts/DesignSystemConfiguration.tsx +1 -47
  48. package/src/contexts/DialogContext.tsx +2 -10
  49. package/src/hooks/useDarkMode.ts +14 -0
  50. package/src/index.css +108 -0
  51. package/src/index.tsx +4 -5
  52. package/src/theme/index.ts +4 -16
  53. package/src/utils/tailwind.ts +17 -0
  54. package/tailwind.config.ts +223 -0
  55. package/tailwind.d.ts +11 -0
  56. package/tsconfig.json +4 -1
  57. package/tsup.config.ts +16 -0
  58. package/dist/index.d.mts +0 -1455
  59. package/src/components/Grid.tsx +0 -54
  60. package/src/components/Select.tsx +0 -183
  61. package/src/components/Stack.tsx +0 -155
  62. package/src/theme/dark.ts +0 -45
  63. package/src/theme/light.ts +0 -226
  64. package/src/utils/breakpoints.ts +0 -45
@@ -1,54 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Colors } from '../theme';
3
-
4
- export type GridProps = {
5
- columns?: string;
6
- rows?: string;
7
- alignItems?: 'start' | 'center' | 'end';
8
- justifyItems?: 'start' | 'center' | 'end';
9
- placeItems?: 'start' | 'center' | 'end';
10
- width?: number | string;
11
- minWidth?: number | string;
12
- maxWidth?: number | string;
13
- height?: number | string;
14
- minHeight?: number | string;
15
- maxHeight?: number | string;
16
- padding?: number | string;
17
- paddingX?: number | string;
18
- paddingXStart?: number | string;
19
- paddingXEnd?: number | string;
20
- paddingY?: number | string;
21
- paddingYStart?: number | string;
22
- paddingYEnd?: number | string;
23
- gap?: number | string;
24
- gapX?: number | string;
25
- gapY?: number | string;
26
- background?: keyof Colors;
27
- };
28
-
29
- const Grid = styled.div<GridProps>((props) => ({
30
- display: 'grid',
31
- gridTemplateColumns: props.columns,
32
- gridTemplateRows: props.rows,
33
- alignItems: props.alignItems,
34
- justifyItems: props.justifyItems,
35
- width: props.width,
36
- minWidth: props.minWidth ?? 0,
37
- maxWidth: props.maxWidth,
38
- height: props.height,
39
- minHeight: props.minHeight ?? 0,
40
- maxHeight: props.maxHeight,
41
- padding: props.padding,
42
- paddingInline: props.paddingX,
43
- paddingInlineStart: props.paddingXStart,
44
- paddingInlineEnd: props.paddingXEnd,
45
- paddingBlock: props.paddingY,
46
- paddingBlockStart: props.paddingYStart,
47
- paddingBlockEnd: props.paddingYEnd,
48
- gap: props.gap,
49
- gapRow: props.gapX,
50
- gapColumn: props.gapY,
51
- background: props.background,
52
- }));
53
-
54
- export default Grid;
@@ -1,183 +0,0 @@
1
- import { memoize } from "@noya-app/noya-utils";
2
- import React, {
3
- createContext,
4
- CSSProperties,
5
- memo,
6
- ReactNode,
7
- useCallback,
8
- useContext,
9
- useEffect,
10
- useMemo,
11
- useRef,
12
- } from "react";
13
- import styled from "styled-components";
14
-
15
- type SelectContextValue = {
16
- addListener: (value: string, listener: () => void) => void;
17
- removeListener: (value: string) => void;
18
- };
19
-
20
- const SelectContext = createContext<SelectContextValue | undefined>(undefined);
21
-
22
- interface SelectOptionProps<T extends string> {
23
- value: T;
24
- title?: string;
25
- onSelect?: () => void;
26
- }
27
-
28
- export const SelectOption = memo(function SelectOption<T extends string>({
29
- value,
30
- title,
31
- onSelect,
32
- }: SelectOptionProps<T>) {
33
- const { addListener, removeListener } = useContext(SelectContext)!;
34
-
35
- useEffect(() => {
36
- if (!onSelect) return;
37
-
38
- addListener(value, onSelect);
39
-
40
- return () => removeListener(value);
41
- }, [addListener, onSelect, removeListener, value]);
42
-
43
- return <option value={value}>{title ?? value}</option>;
44
- });
45
-
46
- const createChevronSVGString = memoize((color: string) =>
47
- `
48
- <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15' fill='${color}'>
49
- <path d='M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z'></path>
50
- </svg>
51
- `.replace(/\n/g, "")
52
- );
53
-
54
- const SelectContainer = styled.div<{ $flex: CSSProperties["flex"] }>(
55
- ({ $flex }) => ({
56
- flex: $flex ?? "1 1 0px",
57
- display: "flex",
58
- flexDirection: "row",
59
- position: "relative",
60
- })
61
- );
62
-
63
- const SelectElement = styled.select<{ $flex: CSSProperties["flex"] }>(
64
- ({ theme, $flex }) => ({
65
- appearance: "none",
66
- ...theme.textStyles.small,
67
- color: theme.colors.text,
68
- lineHeight: "19px",
69
- width: "0px", // Reset intrinsic width
70
- flex: $flex ?? "1 1 0px",
71
- position: "relative",
72
- border: "0",
73
- outline: "none",
74
- minWidth: "0",
75
- textAlign: "left",
76
- alignSelf: "stretch",
77
- borderRadius: "4px",
78
- paddingTop: "4px",
79
- paddingBottom: "4px",
80
- paddingLeft: "6px",
81
- paddingRight: "23px",
82
- background: [
83
- `calc(100% - 6px) / 15px url("data:image/svg+xml;utf8,${createChevronSVGString(
84
- theme.colors.icon
85
- )}") no-repeat`,
86
- theme.colors.inputBackground,
87
- ].join(","),
88
- "&:focus": {
89
- boxShadow: `0 0 0 2px ${theme.colors.primary}`,
90
- },
91
- })
92
- );
93
-
94
- const SelectLabel = styled.label(({ theme }) => ({
95
- ...theme.textStyles.label,
96
- color: theme.colors.textDisabled,
97
- lineHeight: "19px",
98
- position: "absolute",
99
- inset: "0",
100
- fontWeight: "bold",
101
- fontSize: "60%",
102
- pointerEvents: "none",
103
- display: "flex",
104
- alignItems: "center",
105
- justifyContent: "end",
106
- paddingRight: "24px",
107
- }));
108
-
109
- type ChildrenProps<T> =
110
- | {
111
- children: ReactNode;
112
- }
113
- | {
114
- options: readonly T[];
115
- getTitle?: (option: T, index: number) => string;
116
- onChange: (value: T) => void;
117
- };
118
-
119
- type Props<T extends string> = ChildrenProps<T> & {
120
- id: string;
121
- flex?: CSSProperties["flex"];
122
- value: T;
123
- label?: ReactNode;
124
- };
125
-
126
- export const Select = memo(function Select<T extends string>({
127
- id,
128
- flex,
129
- value,
130
- label,
131
- ...rest
132
- }: Props<T>) {
133
- const options = "options" in rest ? rest.options : undefined;
134
- const getTitle = "options" in rest ? rest.getTitle : undefined;
135
- const onChange = "options" in rest ? rest.onChange : undefined;
136
- const children = "options" in rest ? undefined : rest.children;
137
-
138
- const optionElements = useMemo(
139
- () =>
140
- options
141
- ? options.map((option, index) => (
142
- <SelectOption
143
- key={option}
144
- value={option}
145
- title={getTitle?.(option, index)}
146
- onSelect={() => onChange?.(option)}
147
- />
148
- ))
149
- : children,
150
- [children, getTitle, onChange, options]
151
- );
152
-
153
- const listeners = useRef<Map<string, () => void>>(new Map());
154
-
155
- const contextValue: SelectContextValue = useMemo(
156
- () => ({
157
- addListener: (value, listener) => listeners.current.set(value, listener),
158
- removeListener: (value) => listeners.current.delete(value),
159
- }),
160
- []
161
- );
162
-
163
- return (
164
- <SelectContext.Provider value={contextValue}>
165
- <SelectContainer $flex={flex}>
166
- <SelectElement
167
- id={id}
168
- $flex={flex}
169
- value={value}
170
- onChange={useCallback(
171
- (event: React.ChangeEvent<HTMLSelectElement>) =>
172
- listeners.current.get(event.target.value)?.(),
173
- [listeners]
174
- )}
175
- onPointerDown={(event) => event.stopPropagation()}
176
- >
177
- {optionElements}
178
- </SelectElement>
179
- </SelectContainer>
180
- {label && <SelectLabel htmlFor={id}>{label}</SelectLabel>}
181
- </SelectContext.Provider>
182
- );
183
- });
@@ -1,155 +0,0 @@
1
- import React, {
2
- Children,
3
- CSSProperties,
4
- ForwardedRef,
5
- forwardRef,
6
- memo,
7
- ReactHTML,
8
- ReactNode,
9
- } from "react";
10
- import styled from "styled-components";
11
- import { BreakpointCollection, mergeBreakpoints } from "../utils/breakpoints";
12
- import withSeparatorElements from "../utils/withSeparatorElements";
13
-
14
- interface StyleProps {
15
- display?: "flex" | "inline-flex" | "none" | "block";
16
- visibility?: CSSProperties["visibility"];
17
- position?: CSSProperties["position"];
18
- zIndex?: CSSProperties["zIndex"];
19
- gap?: CSSProperties["gap"];
20
- inset?: CSSProperties["inset"];
21
- top?: CSSProperties["top"];
22
- right?: CSSProperties["right"];
23
- bottom?: CSSProperties["bottom"];
24
- left?: CSSProperties["left"];
25
- flexDirection?: CSSProperties["flexDirection"];
26
- justifyContent?: CSSProperties["justifyContent"];
27
- alignItems?: CSSProperties["alignItems"];
28
- alignSelf?: CSSProperties["alignSelf"];
29
- flex?: CSSProperties["flex"];
30
- flexWrap?: CSSProperties["flexWrap"];
31
- height?: CSSProperties["height"];
32
- minHeight?: CSSProperties["minHeight"];
33
- maxHeight?: CSSProperties["maxHeight"];
34
- width?: CSSProperties["width"];
35
- minWidth?: CSSProperties["minWidth"];
36
- maxWidth?: CSSProperties["maxWidth"];
37
- aspectRatio?: CSSProperties["aspectRatio"];
38
- padding?: CSSProperties["padding"];
39
- paddingVertical?: string | number;
40
- paddingHorizontal?: string | number;
41
- margin?: CSSProperties["margin"];
42
- background?: CSSProperties["background"];
43
- backgroundSize?: CSSProperties["backgroundSize"];
44
- backgroundPosition?: CSSProperties["backgroundPosition"];
45
- borderRadius?: CSSProperties["borderRadius"];
46
- overflowX?: CSSProperties["overflowX"];
47
- overflowY?: CSSProperties["overflowY"];
48
- overflow?: CSSProperties["overflow"];
49
- textOverflow?: CSSProperties["textOverflow"];
50
- boxShadow?: CSSProperties["boxShadow"];
51
- outline?: CSSProperties["outline"];
52
- border?: CSSProperties["border"];
53
- borderTop?: CSSProperties["borderTop"];
54
- borderRight?: CSSProperties["borderRight"];
55
- borderBottom?: CSSProperties["borderBottom"];
56
- borderLeft?: CSSProperties["borderLeft"];
57
- cursor?: CSSProperties["cursor"];
58
- userSelect?: CSSProperties["userSelect"];
59
- transition?: CSSProperties["transition"];
60
- opacity?: CSSProperties["opacity"];
61
- filter?: CSSProperties["filter"];
62
- color?: CSSProperties["color"];
63
- order?: CSSProperties["order"];
64
- pointerEvents?: CSSProperties["pointerEvents"];
65
- lineHeight?: CSSProperties["lineHeight"];
66
- isolation?: CSSProperties["isolation"];
67
- backdropFilter?: CSSProperties["backdropFilter"];
68
- }
69
-
70
- export type StackBreakpointList = BreakpointCollection<StyleProps>;
71
-
72
- interface Props extends StyleProps {
73
- id?: string;
74
- as?: keyof ReactHTML;
75
- className?: string;
76
- children?: ReactNode;
77
- separator?: Parameters<typeof withSeparatorElements>[1];
78
- breakpoints?: StackBreakpointList | null | false;
79
- href?: string; // Shouldn't be here, ideally
80
- tabIndex?: number;
81
- }
82
-
83
- const Element = styled.div<{
84
- $styleProps: StyleProps;
85
- $breakpoints?: StackBreakpointList | null | false;
86
- }>(({ $styleProps, $breakpoints }) => ({
87
- ...$styleProps,
88
- ...mergeBreakpoints($breakpoints || []),
89
- }));
90
-
91
- const StackBase = forwardRef(function StackBase(
92
- {
93
- id,
94
- className,
95
- as,
96
- children,
97
- separator,
98
- breakpoints,
99
- tabIndex,
100
- href,
101
- ...rest
102
- }: Props,
103
- forwardedRef: ForwardedRef<HTMLElement>
104
- ) {
105
- const elements = separator
106
- ? withSeparatorElements(Children.toArray(children), separator)
107
- : children;
108
-
109
- const styleProps: StyleProps = {
110
- display: "flex",
111
- position: "relative",
112
- alignItems: "stretch",
113
- ...rest,
114
- };
115
-
116
- return (
117
- <Element
118
- ref={forwardedRef as any}
119
- id={id}
120
- className={className}
121
- as={as}
122
- $styleProps={styleProps}
123
- $breakpoints={breakpoints}
124
- tabIndex={tabIndex}
125
- {...(href && { href })}
126
- >
127
- {elements}
128
- </Element>
129
- );
130
- });
131
-
132
- type StackProps = Omit<Props, "flexDirection">;
133
-
134
- const VerticalStack = memo(
135
- forwardRef(function VStack(
136
- props: StackProps,
137
- forwardedRef: ForwardedRef<HTMLElement>
138
- ) {
139
- return <StackBase {...props} flexDirection="column" ref={forwardedRef} />;
140
- })
141
- );
142
-
143
- const HorizontalStack = memo(
144
- forwardRef(function HStack(
145
- props: StackProps,
146
- forwardedRef: ForwardedRef<HTMLElement>
147
- ) {
148
- return <StackBase {...props} flexDirection="row" ref={forwardedRef} />;
149
- })
150
- );
151
-
152
- export const Stack = {
153
- V: VerticalStack,
154
- H: HorizontalStack,
155
- };
package/src/theme/dark.ts DELETED
@@ -1,45 +0,0 @@
1
- import produce from "immer";
2
- import * as lightTheme from "./light";
3
-
4
- export const name: string = "dark";
5
-
6
- export const colors = produce(lightTheme.colors, (colors) => {
7
- colors.logo.fill = "rgb(248,248,250)";
8
- colors.logo.highlight = "rgb(248,248,250)";
9
- colors.text = "rgb(248,248,250)";
10
- colors.textMuted = "rgb(180,179,182)";
11
- colors.textDisabled = "rgb(100,99,102)";
12
- colors.inputBackground = "rgba(181,178,255,0.08)";
13
- colors.inputBackgroundLight = "rgba(181,178,255,0.10)";
14
- colors.codeBackground = "rgb(20,19,23)";
15
- colors.dividerSubtle = "rgba(255,255,255,0.04)";
16
- colors.divider = "rgba(255,255,255,0.08)";
17
- colors.dividerStrong = "rgba(0,0,0,1)";
18
- colors.primary = "rgb(119, 66, 255)";
19
- colors.primaryLight = "rgb(134, 86, 255)";
20
- colors.secondaryBright = "#36fe91";
21
- colors.canvas.background = "rgb(20,19,23)";
22
- colors.canvas.sliceOutline = "rgb(150,150,150)";
23
- colors.canvas.grid = "rgba(0,0,0,0.1)";
24
- colors.sidebar.background = "rgb(34,33,39)";
25
- colors.sidebar.backgroundTransparent = "rgba(34,33,39,0.95)";
26
- colors.popover.background = "rgba(34,33,39,1)";
27
- colors.popover.divider = colors.divider;
28
- colors.listView.raisedBackground = "rgba(181,178,255,0.1)";
29
- colors.listView.editingBackground = "#000";
30
- colors.slider.background = "#BBB";
31
- colors.radioGroup.background = colors.inputBackground;
32
- colors.mask = "rgb(102,187,106)";
33
- colors.transparentChecker = "rgba(255,255,255,0.3)";
34
- colors.scrollbar = "rgba(199,199,199,0.2)";
35
- colors.placeholderDots = "rgba(255,255,255,0.3)";
36
- colors.dragOutline = "white";
37
- colors.activeBackground = "rgba(181,178,255,0.08)";
38
- colors.thumbnailBackground = "#1f1d33";
39
- colors.thumbnailShadow = "#1f1d3366";
40
- colors.breadcrumb.text = colors.textMuted;
41
- colors.breadcrumb.textHover = colors.textSubtle;
42
- colors.breadcrumb.icon = colors.icon;
43
- });
44
-
45
- export { fonts, sizes, textStyles } from "./light";
@@ -1,226 +0,0 @@
1
- import { CSSObject } from "styled-components";
2
- import { mediaQuery } from "../mediaQuery";
3
-
4
- export const name: string = "light";
5
-
6
- export const colors = {
7
- logo: {
8
- fill: "rgb(150, 152, 172)",
9
- highlight: "rgb(150, 152, 172)",
10
- },
11
- background: "rgb(255,255,255)",
12
- text: "rgb(38, 48, 83)",
13
- textMuted: "rgb(107, 113, 136)",
14
- textSubtle: "rgb(117, 121, 129)",
15
- textDisabled: "rgb(150, 152, 172)",
16
- textDecorativeLight: "rgb(168, 185, 212)",
17
- dividerSubtle: "rgba(30, 50, 100, 0.04)",
18
- divider: "rgba(30, 50, 100, 0.07)",
19
- dividerStrong: "rgba(30, 50, 100, 0.09)",
20
- primary: "rgb(103, 70, 255)",
21
- primaryLight: "rgb(147, 86, 255)",
22
- primaryPastel: "rgba(234, 230, 255)",
23
- secondary: "rgb(0, 151, 117)",
24
- secondaryLight: "rgb(0, 160, 129)",
25
- secondaryPastel: "rgb(205, 238, 231)",
26
- secondaryBright: "#0ab557",
27
- warning: "rgb(251, 211, 0)",
28
- neutralBackground: "rgb(222,223,232)",
29
- inputBackground: "rgb(240, 242, 246)",
30
- inputBackgroundLight: "rgb(243, 245, 249)",
31
- codeBackground: "rgb(250, 250, 250)",
32
- codeBackgroundLight: "rgb(250, 250, 250)",
33
- get codeBackgroundDark() {
34
- return colors.text;
35
- },
36
- codeBackgroundDecorativeDark: "#435080",
37
- selectedBackground: "rgb(242, 245, 250)",
38
- transparentChecker: "rgba(255,255,255,0.8)",
39
- activeBackground: "rgba(0,0,0,0.1)",
40
- scrollbar: "rgba(199,199,199,0.8)",
41
- placeholderDots: "rgba(0,0,0,0.3)",
42
- breadcrumb: {
43
- get text() {
44
- return colors.textMuted;
45
- },
46
- get textHover() {
47
- return colors.textSubtle;
48
- },
49
- get icon() {
50
- return colors.icon;
51
- },
52
- },
53
- listView: {
54
- raisedBackground: "rgba(0,0,0,0.03)",
55
- editingBackground: "#fff",
56
- },
57
- canvas: {
58
- // background: "white",
59
- background: "rgb(249,249,249)",
60
- get selectionStroke() {
61
- return colors.primary;
62
- },
63
- dragHandleStroke: "rgba(180,180,180,0.5)",
64
- measurement: "rgb(207,92,42)",
65
- sliceOutline: "rgb(210,210,210)",
66
- grid: "rgba(0,0,0,0.05)",
67
- },
68
- sidebar: {
69
- background: "rgb(255,255,255)",
70
- backgroundTransparent: "rgba(255,255,255,0.85)",
71
- },
72
- popover: {
73
- background: "rgb(252,252,252)",
74
- divider: "transparent",
75
- },
76
- slider: {
77
- background: "white",
78
- border: "#BBB",
79
- },
80
- radioGroup: {
81
- background: "white",
82
- },
83
- icon: "rgb(129, 131, 165)",
84
- iconSelected: "rgb(220, 220, 220)",
85
- mask: "rgb(12,193,67)",
86
- imageOverlay:
87
- "linear-gradient(0deg, rgba(132, 63, 255,0.55), rgba(132, 63, 255,0.55))",
88
- get dragOutline() {
89
- return colors.primary;
90
- },
91
- selection: "rgb(179,215,254)",
92
- thumbnailBackground: "#f0efff",
93
- thumbnailShadow: "#D3CEED66",
94
- inlineCode: {
95
- text: "rgb(103, 70, 255)",
96
- background: "rgb(240, 242, 246)",
97
- },
98
- textLink: "rgb(103, 70, 255)",
99
- textLinkFocused: "rgb(147, 86, 255)",
100
- };
101
-
102
- export const fonts = {
103
- normal:
104
- "'__Inter_6b0edc', '__Inter_Fallback_6b0edc', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
105
- monospace: "Menlo, Monaco, Consolas, 'Courier New', monospace",
106
- };
107
-
108
- // The last one, 0.85, I just eyeballed
109
- const typeScale = [3.052, 2.441, 1.953, 1.563, 1.25, 1, 0.85]; // Major third
110
-
111
- export const textStyles = {
112
- title: {
113
- fontFamily: fonts.normal,
114
- fontSize: `${typeScale[0]}rem`,
115
- fontWeight: "bold",
116
- lineHeight: "1.4",
117
- letterSpacing: "-0.05em",
118
- [mediaQuery.small]: {
119
- fontSize: "36px",
120
- },
121
- } as CSSObject,
122
- subtitle: {
123
- fontFamily: fonts.normal,
124
- fontSize: `${typeScale[3]}rem`,
125
- fontWeight: 500,
126
- lineHeight: "1.75",
127
- letterSpacing: "-0.05em",
128
- [mediaQuery.small]: {
129
- fontSize: "18px",
130
- },
131
- } as CSSObject,
132
- heading1: {
133
- fontFamily: fonts.normal,
134
- fontSize: `${typeScale[2]}rem`,
135
- fontWeight: 600,
136
- lineHeight: "1.6",
137
- letterSpacing: "-0.025em",
138
- } as CSSObject,
139
- heading2: {
140
- fontFamily: fonts.normal,
141
- fontSize: `${typeScale[3]}rem`,
142
- fontWeight: 500,
143
- lineHeight: "1.5",
144
- letterSpacing: "-0.025em",
145
- } as CSSObject,
146
- heading3: {
147
- fontFamily: fonts.normal,
148
- fontSize: `${typeScale[4]}rem`,
149
- fontWeight: 400,
150
- lineHeight: "1.4",
151
- letterSpacing: "-0.025em",
152
- } as CSSObject,
153
- heading4: {
154
- fontFamily: fonts.normal,
155
- fontSize: `${typeScale[5]}rem`,
156
- fontWeight: 500,
157
- lineHeight: "1.4",
158
- } as CSSObject,
159
- heading5: {
160
- fontFamily: fonts.normal,
161
- fontSize: `${typeScale[6]}rem`,
162
- fontWeight: 500,
163
- lineHeight: "1.4",
164
- } as CSSObject,
165
- body: {
166
- fontFamily: fonts.normal,
167
- fontSize: `${typeScale[5]}rem`,
168
- fontWeight: 400,
169
- lineHeight: "1.4",
170
- } as CSSObject,
171
- small: {
172
- fontFamily: fonts.normal,
173
- fontSize: `${typeScale[6]}rem`,
174
- fontWeight: 400,
175
- lineHeight: "19px",
176
- // lineHeight: "1.4",
177
- } as CSSObject,
178
- button: {
179
- fontFamily: fonts.normal,
180
- fontSize: "0.8rem",
181
- fontWeight: 500,
182
- lineHeight: "1.4",
183
- letterSpacing: "-0.2px",
184
- } as CSSObject,
185
- code: {
186
- fontFamily: fonts.monospace,
187
- fontSize: "90%",
188
- lineHeight: "1.5",
189
- } as CSSObject,
190
- label: {
191
- fontFamily: fonts.normal,
192
- fontSize: "0.62rem",
193
- fontWeight: 400,
194
- lineHeight: "19px",
195
- // lineHeight: "1.4",
196
- textTransform: "uppercase",
197
- letterSpacing: "-0.3px",
198
- } as CSSObject,
199
- };
200
-
201
- export const sizes = {
202
- inset: {
203
- top: 46,
204
- },
205
- sidebarWidth: 260,
206
- toolbar: {
207
- height: 46,
208
- itemSeparator: 8,
209
- },
210
- inspector: {
211
- horizontalSeparator: 8,
212
- verticalSeparator: 10,
213
- },
214
- spacing: {
215
- nano: 2,
216
- micro: 4,
217
- small: 8,
218
- medium: 16,
219
- large: 32,
220
- xlarge: 64,
221
- xxlarge: 128,
222
- },
223
- dialog: {
224
- padding: 16,
225
- },
226
- };
@@ -1,45 +0,0 @@
1
- import { CSSObject } from "styled-components";
2
-
3
- type BreakpointKey = number | string;
4
-
5
- export type Breakpoint<T extends object> = [BreakpointKey, T];
6
-
7
- export type BreakpointCollection<T extends object> =
8
- | Breakpoint<T>[]
9
- | Record<BreakpointKey, T>;
10
-
11
- export type StyleMap = Record<string, CSSObject>;
12
-
13
- export function mergeBreakpoints(
14
- breakpoints: BreakpointCollection<CSSObject>
15
- ): StyleMap;
16
- export function mergeBreakpoints<T extends object>(
17
- breakpoints: BreakpointCollection<T>,
18
- transform?: (value: T) => CSSObject
19
- ): StyleMap;
20
- export function mergeBreakpoints<T extends object>(
21
- breakpoints: BreakpointCollection<T>,
22
- transform?: (value: T) => CSSObject
23
- ): StyleMap {
24
- const breakpointMap = Array.isArray(breakpoints)
25
- ? breakpoints.reduce(
26
- (result: Record<number, T>, item: any /* TODO Fix type */) => {
27
- const [key, value] = item;
28
- result[key] = result[key] ? { ...result[key], ...value } : value;
29
- return result;
30
- },
31
- {}
32
- )
33
- : breakpoints;
34
-
35
- const breakpointList = Object.entries(breakpointMap) as Breakpoint<T>[];
36
-
37
- const transformedList = breakpointList
38
- .sort((a, b) => Number(b[0]) - Number(a[0]))
39
- .map(([width, value]: Breakpoint<T>) => [
40
- `@media (min-width: ${width}px)`,
41
- transform?.(value) ?? value,
42
- ]);
43
-
44
- return Object.fromEntries(transformedList);
45
- }