@noya-app/noya-designsystem 0.0.13 → 0.0.15
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +24 -0
- package/dist/index.d.mts +65 -44
- package/dist/index.d.ts +65 -44
- package/dist/index.js +71 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/components/Button.tsx +84 -78
- package/src/components/Chip.tsx +74 -73
- package/src/components/Dialog.tsx +51 -26
- package/src/components/GridView.tsx +113 -100
- package/src/components/IconButton.tsx +10 -8
- package/src/components/InputFieldWithCompletions.tsx +3 -0
- package/src/components/InspectorPrimitives.tsx +1 -1
- package/src/components/Switch.tsx +25 -25
- package/src/components/Text.tsx +60 -56
- package/src/theme/dark.ts +33 -31
- package/src/theme/light.ts +76 -64
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-designsystem",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"@dnd-kit/core": "3.1.1",
|
|
13
13
|
"@dnd-kit/modifiers": "3.0.0",
|
|
14
14
|
"@dnd-kit/sortable": "4.0.0",
|
|
15
|
-
"@noya-app/noya-colorpicker": "0.0.
|
|
16
|
-
"@noya-app/noya-utils": "0.0.
|
|
17
|
-
"@noya-app/noya-geometry": "0.0.
|
|
18
|
-
"@noya-app/noya-icons": "0.0.
|
|
19
|
-
"@noya-app/noya-keymap": "0.0.
|
|
15
|
+
"@noya-app/noya-colorpicker": "0.0.9",
|
|
16
|
+
"@noya-app/noya-utils": "0.0.12",
|
|
17
|
+
"@noya-app/noya-geometry": "0.0.13",
|
|
18
|
+
"@noya-app/noya-icons": "0.0.6",
|
|
19
|
+
"@noya-app/noya-keymap": "0.0.8",
|
|
20
20
|
"@radix-ui/primitive": "^1.0.0",
|
|
21
21
|
"@radix-ui/react-avatar": "^1.0.1",
|
|
22
22
|
"@radix-ui/react-compose-refs": "^1.0.0",
|
|
@@ -4,21 +4,21 @@ import React, {
|
|
|
4
4
|
forwardRef,
|
|
5
5
|
ReactNode,
|
|
6
6
|
useCallback,
|
|
7
|
-
} from
|
|
8
|
-
import styled from
|
|
9
|
-
import { Tooltip } from
|
|
7
|
+
} from "react";
|
|
8
|
+
import styled from "styled-components";
|
|
9
|
+
import { Tooltip } from "./Tooltip";
|
|
10
10
|
|
|
11
11
|
type ButtonVariant =
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
12
|
+
| "normal"
|
|
13
|
+
| "primary"
|
|
14
|
+
| "secondary"
|
|
15
|
+
| "secondaryBright"
|
|
16
|
+
| "white"
|
|
17
|
+
| "thin"
|
|
18
|
+
| "floating"
|
|
19
|
+
| "none";
|
|
20
20
|
|
|
21
|
-
type ButtonSize =
|
|
21
|
+
type ButtonSize = "normal" | "large";
|
|
22
22
|
|
|
23
23
|
/* ----------------------------------------------------------------------------
|
|
24
24
|
* Element
|
|
@@ -28,98 +28,98 @@ export const ButtonElement = styled.button<{
|
|
|
28
28
|
active: boolean;
|
|
29
29
|
variant: ButtonVariant;
|
|
30
30
|
size: ButtonSize;
|
|
31
|
-
flex?: CSSProperties[
|
|
31
|
+
flex?: CSSProperties["flex"];
|
|
32
32
|
}>(({ theme, active, disabled, variant, size, flex }) => ({
|
|
33
|
-
...(size ===
|
|
34
|
-
textDecoration:
|
|
35
|
-
lineHeight:
|
|
36
|
-
flex: flex ??
|
|
37
|
-
position:
|
|
38
|
-
border:
|
|
39
|
-
outline:
|
|
40
|
-
WebkitAppRegion:
|
|
41
|
-
userSelect:
|
|
42
|
-
minWidth: variant ===
|
|
43
|
-
textAlign:
|
|
44
|
-
borderRadius:
|
|
45
|
-
paddingTop: variant ===
|
|
46
|
-
paddingRight: variant ===
|
|
47
|
-
paddingBottom: variant ===
|
|
48
|
-
paddingLeft: variant ===
|
|
49
|
-
...(size ===
|
|
50
|
-
paddingTop:
|
|
51
|
-
paddingRight:
|
|
52
|
-
paddingBottom:
|
|
53
|
-
paddingLeft:
|
|
33
|
+
...(size === "large" ? theme.textStyles.heading4 : theme.textStyles.small),
|
|
34
|
+
textDecoration: "none",
|
|
35
|
+
lineHeight: "1",
|
|
36
|
+
flex: flex ?? "0 0 auto",
|
|
37
|
+
position: "relative",
|
|
38
|
+
border: "0",
|
|
39
|
+
outline: "none",
|
|
40
|
+
WebkitAppRegion: "no-drag",
|
|
41
|
+
userSelect: "none",
|
|
42
|
+
minWidth: variant === "normal" ? "31px" : undefined,
|
|
43
|
+
textAlign: "left",
|
|
44
|
+
borderRadius: "4px",
|
|
45
|
+
paddingTop: variant === "none" ? "0px" : "4px",
|
|
46
|
+
paddingRight: variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
|
|
47
|
+
paddingBottom: variant === "none" ? "0px" : "4px",
|
|
48
|
+
paddingLeft: variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
|
|
49
|
+
...(size === "large" && {
|
|
50
|
+
paddingTop: "12px",
|
|
51
|
+
paddingRight: "16px",
|
|
52
|
+
paddingBottom: "12px",
|
|
53
|
+
paddingLeft: "16px",
|
|
54
54
|
}),
|
|
55
55
|
background: active
|
|
56
56
|
? theme.colors.primary
|
|
57
|
-
: variant ===
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
color: active ?
|
|
57
|
+
: variant === "none" || variant === "thin"
|
|
58
|
+
? "transparent"
|
|
59
|
+
: theme.colors.inputBackground,
|
|
60
|
+
color: active ? "white" : theme.colors.text,
|
|
61
61
|
opacity: disabled ? 0.25 : 1,
|
|
62
|
-
|
|
62
|
+
"&:focus": {
|
|
63
63
|
boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${theme.colors.primary}`,
|
|
64
64
|
},
|
|
65
|
-
|
|
65
|
+
"&:hover": {
|
|
66
66
|
background: theme.colors.inputBackgroundLight,
|
|
67
67
|
},
|
|
68
|
-
|
|
68
|
+
"&:active": {
|
|
69
69
|
background: theme.colors.activeBackground,
|
|
70
70
|
},
|
|
71
|
-
...(variant ===
|
|
71
|
+
...(variant === "primary" && {
|
|
72
72
|
background: theme.colors.primary,
|
|
73
|
-
color:
|
|
74
|
-
|
|
73
|
+
color: "white",
|
|
74
|
+
"&:hover": {
|
|
75
75
|
background: theme.colors.primaryLight,
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
"&:active": {
|
|
78
78
|
background: theme.colors.primary,
|
|
79
79
|
},
|
|
80
80
|
}),
|
|
81
|
-
...(variant ===
|
|
81
|
+
...(variant === "secondary" && {
|
|
82
82
|
background: theme.colors.secondary,
|
|
83
|
-
color:
|
|
84
|
-
|
|
83
|
+
color: "white",
|
|
84
|
+
"&:hover": {
|
|
85
85
|
background: theme.colors.secondaryLight,
|
|
86
86
|
},
|
|
87
|
-
|
|
87
|
+
"&:active": {
|
|
88
88
|
background: theme.colors.secondary,
|
|
89
89
|
},
|
|
90
90
|
}),
|
|
91
|
-
...(variant ===
|
|
92
|
-
background:
|
|
93
|
-
color:
|
|
94
|
-
|
|
91
|
+
...(variant === "secondaryBright" && {
|
|
92
|
+
background: "#0ab557",
|
|
93
|
+
color: "white",
|
|
94
|
+
"&:hover": {
|
|
95
95
|
opacity: 0.8,
|
|
96
96
|
},
|
|
97
|
-
|
|
97
|
+
"&:active": {
|
|
98
98
|
opacity: 0.9,
|
|
99
99
|
},
|
|
100
100
|
}),
|
|
101
|
-
...(variant ===
|
|
102
|
-
background:
|
|
103
|
-
|
|
101
|
+
...(variant === "white" && {
|
|
102
|
+
background: "white",
|
|
103
|
+
"&:hover": {
|
|
104
104
|
opacity: 0.8,
|
|
105
105
|
},
|
|
106
|
-
|
|
106
|
+
"&:active": {
|
|
107
107
|
opacity: 0.9,
|
|
108
108
|
},
|
|
109
109
|
}),
|
|
110
|
-
...(variant ===
|
|
111
|
-
background:
|
|
110
|
+
...(variant === "floating" && {
|
|
111
|
+
background: "white",
|
|
112
112
|
color: theme.colors.text,
|
|
113
|
-
boxShadow:
|
|
114
|
-
fontSize:
|
|
115
|
-
padding:
|
|
113
|
+
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)",
|
|
114
|
+
fontSize: "12px",
|
|
115
|
+
padding: "0px 4px",
|
|
116
116
|
}),
|
|
117
|
-
display:
|
|
118
|
-
alignItems:
|
|
119
|
-
justifyContent:
|
|
117
|
+
display: "flex",
|
|
118
|
+
alignItems: "center",
|
|
119
|
+
justifyContent: "center",
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
pointerEvents:
|
|
121
|
+
"& *": {
|
|
122
|
+
pointerEvents: "none",
|
|
123
123
|
},
|
|
124
124
|
}));
|
|
125
125
|
|
|
@@ -130,14 +130,14 @@ export const ButtonElement = styled.button<{
|
|
|
130
130
|
const ButtonContent = styled.span(({ theme }) => ({
|
|
131
131
|
// Line height of small text - maybe figure out better way to ensure
|
|
132
132
|
// icons don't have a smaller height
|
|
133
|
-
minHeight:
|
|
134
|
-
display:
|
|
135
|
-
alignItems:
|
|
136
|
-
flex:
|
|
137
|
-
justifyContent:
|
|
133
|
+
minHeight: "19px",
|
|
134
|
+
display: "flex",
|
|
135
|
+
alignItems: "center",
|
|
136
|
+
flex: "1",
|
|
137
|
+
justifyContent: "center",
|
|
138
138
|
|
|
139
139
|
// Helps with alignment with the default small text
|
|
140
|
-
lineHeight:
|
|
140
|
+
lineHeight: "15px",
|
|
141
141
|
}));
|
|
142
142
|
|
|
143
143
|
/* ----------------------------------------------------------------------------
|
|
@@ -146,7 +146,9 @@ const ButtonContent = styled.span(({ theme }) => ({
|
|
|
146
146
|
|
|
147
147
|
export interface ButtonRootProps {
|
|
148
148
|
id?: string;
|
|
149
|
-
|
|
149
|
+
className?: string;
|
|
150
|
+
style?: CSSProperties;
|
|
151
|
+
flex?: CSSProperties["flex"];
|
|
150
152
|
tabIndex?: number;
|
|
151
153
|
children: ReactNode;
|
|
152
154
|
active?: boolean;
|
|
@@ -166,24 +168,28 @@ export interface ButtonRootProps {
|
|
|
166
168
|
export const Button = forwardRef(function Button(
|
|
167
169
|
{
|
|
168
170
|
id,
|
|
171
|
+
className,
|
|
172
|
+
style,
|
|
169
173
|
flex,
|
|
170
174
|
tabIndex,
|
|
171
175
|
tooltip,
|
|
172
176
|
active = false,
|
|
173
177
|
disabled = false,
|
|
174
|
-
variant =
|
|
175
|
-
size =
|
|
178
|
+
variant = "normal",
|
|
179
|
+
size = "normal",
|
|
176
180
|
contentStyle,
|
|
177
181
|
onClick,
|
|
178
182
|
children,
|
|
179
183
|
...rest // Propagate any other props so this component works as a Slot
|
|
180
184
|
}: ButtonRootProps,
|
|
181
|
-
forwardedRef: ForwardedRef<HTMLButtonElement
|
|
185
|
+
forwardedRef: ForwardedRef<HTMLButtonElement>
|
|
182
186
|
) {
|
|
183
187
|
const buttonElement = (
|
|
184
188
|
<ButtonElement
|
|
185
189
|
ref={forwardedRef}
|
|
186
190
|
id={id}
|
|
191
|
+
className={className}
|
|
192
|
+
style={style}
|
|
187
193
|
flex={flex}
|
|
188
194
|
tabIndex={tabIndex}
|
|
189
195
|
active={active}
|
package/src/components/Chip.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Cross1Icon, PlusIcon } from
|
|
2
|
-
import React, { memo } from
|
|
3
|
-
import styled from
|
|
4
|
-
import { useDesignSystemTheme } from
|
|
5
|
-
import { useHover } from
|
|
1
|
+
import { Cross1Icon, PlusIcon } from "@noya-app/noya-icons";
|
|
2
|
+
import React, { memo } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { useDesignSystemTheme } from "../contexts/DesignSystemConfiguration";
|
|
5
|
+
import { useHover } from "../hooks/useHover";
|
|
6
6
|
|
|
7
|
-
type ChipColorScheme =
|
|
8
|
-
type ChipSize =
|
|
9
|
-
type ChipVariant =
|
|
7
|
+
type ChipColorScheme = "primary" | "secondary" | "error";
|
|
8
|
+
type ChipSize = "small" | "medium";
|
|
9
|
+
type ChipVariant = "solid" | "outlined" | "ghost";
|
|
10
10
|
|
|
11
11
|
const ChipElement = styled.span<{
|
|
12
12
|
colorScheme?: ChipColorScheme;
|
|
@@ -16,69 +16,70 @@ const ChipElement = styled.span<{
|
|
|
16
16
|
isInteractive: boolean;
|
|
17
17
|
}>(({ theme, colorScheme, size, variant, monospace, isInteractive }) => {
|
|
18
18
|
const color =
|
|
19
|
-
colorScheme ===
|
|
19
|
+
colorScheme === "primary"
|
|
20
20
|
? theme.colors.primary
|
|
21
|
-
: colorScheme ===
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
: colorScheme === "secondary"
|
|
22
|
+
? theme.colors.secondary
|
|
23
|
+
: theme.colors.text;
|
|
24
24
|
|
|
25
25
|
const backgroundColor =
|
|
26
|
-
colorScheme ===
|
|
27
|
-
?
|
|
28
|
-
: colorScheme ===
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
colorScheme === "primary"
|
|
27
|
+
? "rgb(238, 229, 255)"
|
|
28
|
+
: colorScheme === "secondary"
|
|
29
|
+
? "rgb(205, 238, 231)"
|
|
30
|
+
: colorScheme === "error"
|
|
31
|
+
? "rgb(255, 219, 219)"
|
|
32
|
+
: theme.colors.inputBackground;
|
|
33
33
|
|
|
34
34
|
const subtleColor =
|
|
35
|
-
colorScheme ===
|
|
36
|
-
?
|
|
37
|
-
: colorScheme ===
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
colorScheme === "primary"
|
|
36
|
+
? "rgba(238, 229, 255, 0.2)"
|
|
37
|
+
: colorScheme === "secondary"
|
|
38
|
+
? "rgba(205, 238, 231, 0.2)"
|
|
39
|
+
: colorScheme === "error"
|
|
40
|
+
? "rgba(255, 219, 219, 0.2)"
|
|
41
|
+
: "rgba(0, 0, 0, 0.1)";
|
|
42
42
|
|
|
43
43
|
return {
|
|
44
|
-
textTransform:
|
|
44
|
+
textTransform: "initial",
|
|
45
45
|
borderRadius: 4,
|
|
46
|
-
userSelect:
|
|
47
|
-
display:
|
|
48
|
-
alignItems:
|
|
49
|
-
lineHeight:
|
|
50
|
-
|
|
46
|
+
userSelect: "none",
|
|
47
|
+
display: "inline-flex",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
lineHeight: "1.4",
|
|
50
|
+
whiteSpace: "pre",
|
|
51
|
+
...(size === "medium"
|
|
51
52
|
? {
|
|
52
|
-
fontSize:
|
|
53
|
-
padding:
|
|
53
|
+
fontSize: "11px",
|
|
54
|
+
padding: "4px 8px",
|
|
54
55
|
}
|
|
55
56
|
: {
|
|
56
|
-
fontSize:
|
|
57
|
-
padding:
|
|
57
|
+
fontSize: "9px",
|
|
58
|
+
padding: "0px 4px",
|
|
58
59
|
}),
|
|
59
60
|
...(monospace && {
|
|
60
61
|
fontFamily: theme.fonts.monospace,
|
|
61
62
|
}),
|
|
62
|
-
...(variant ===
|
|
63
|
+
...(variant === "solid"
|
|
63
64
|
? {
|
|
64
65
|
color,
|
|
65
66
|
backgroundColor,
|
|
66
67
|
}
|
|
67
|
-
: variant ===
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
...(variant ===
|
|
68
|
+
: variant === "outlined"
|
|
69
|
+
? {
|
|
70
|
+
color,
|
|
71
|
+
backgroundColor: "transparent",
|
|
72
|
+
boxShadow: `0 0 0 1px ${subtleColor} inset`,
|
|
73
|
+
}
|
|
74
|
+
: {}),
|
|
75
|
+
"&:hover": {
|
|
76
|
+
...(variant === "outlined" && {
|
|
76
77
|
backgroundColor: subtleColor,
|
|
77
|
-
boxShadow:
|
|
78
|
+
boxShadow: "none",
|
|
78
79
|
}),
|
|
79
80
|
},
|
|
80
81
|
...(isInteractive && {
|
|
81
|
-
cursor:
|
|
82
|
+
cursor: "pointer",
|
|
82
83
|
}),
|
|
83
84
|
};
|
|
84
85
|
});
|
|
@@ -86,27 +87,27 @@ const ChipElement = styled.span<{
|
|
|
86
87
|
const DeleteElement = styled(Cross1Icon)<{
|
|
87
88
|
size: ChipSize;
|
|
88
89
|
}>(({ size }) => ({
|
|
89
|
-
position:
|
|
90
|
-
marginRight:
|
|
91
|
-
cursor:
|
|
90
|
+
position: "relative",
|
|
91
|
+
marginRight: "-2px",
|
|
92
|
+
cursor: "pointer",
|
|
92
93
|
opacity: 0.5,
|
|
93
94
|
|
|
94
|
-
...(size ===
|
|
95
|
+
...(size === "medium"
|
|
95
96
|
? {
|
|
96
|
-
marginLeft:
|
|
97
|
+
marginLeft: "2px",
|
|
97
98
|
// top: '-1px',
|
|
98
|
-
transform:
|
|
99
|
+
transform: "scale(0.75)",
|
|
99
100
|
}
|
|
100
101
|
: {
|
|
101
|
-
transform:
|
|
102
|
+
transform: "scale(0.6)",
|
|
102
103
|
}),
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
"&:hover": {
|
|
105
106
|
opacity: 0.85,
|
|
106
107
|
},
|
|
107
108
|
}));
|
|
108
109
|
|
|
109
|
-
const ignoredProps = new Set([
|
|
110
|
+
const ignoredProps = new Set(["size", "isOnlyChild"]);
|
|
110
111
|
|
|
111
112
|
const AddElement = styled(PlusIcon).withConfig({
|
|
112
113
|
shouldForwardProp: (prop) => !ignoredProps.has(prop),
|
|
@@ -114,23 +115,23 @@ const AddElement = styled(PlusIcon).withConfig({
|
|
|
114
115
|
size: ChipSize;
|
|
115
116
|
isOnlyChild: boolean;
|
|
116
117
|
}>(({ size, isOnlyChild }) => ({
|
|
117
|
-
position:
|
|
118
|
-
marginRight:
|
|
119
|
-
cursor:
|
|
118
|
+
position: "relative",
|
|
119
|
+
marginRight: "-2px",
|
|
120
|
+
cursor: "pointer",
|
|
120
121
|
opacity: 0.5,
|
|
121
122
|
|
|
122
|
-
...(size ===
|
|
123
|
+
...(size === "medium"
|
|
123
124
|
? {
|
|
124
|
-
marginLeft:
|
|
125
|
-
top:
|
|
126
|
-
transform:
|
|
125
|
+
marginLeft: "2px",
|
|
126
|
+
top: "-1px",
|
|
127
|
+
transform: "scale(0.75)",
|
|
127
128
|
}
|
|
128
129
|
: {
|
|
129
|
-
transform:
|
|
130
|
-
...(isOnlyChild && { marginLeft:
|
|
130
|
+
transform: "scale(0.6)",
|
|
131
|
+
...(isOnlyChild && { marginLeft: "-2px" }),
|
|
131
132
|
}),
|
|
132
133
|
|
|
133
|
-
|
|
134
|
+
"&:hover": {
|
|
134
135
|
opacity: 0.85,
|
|
135
136
|
},
|
|
136
137
|
}));
|
|
@@ -157,8 +158,8 @@ export const Chip = memo(function Chip({
|
|
|
157
158
|
deletable,
|
|
158
159
|
addable,
|
|
159
160
|
style,
|
|
160
|
-
size =
|
|
161
|
-
variant =
|
|
161
|
+
size = "medium",
|
|
162
|
+
variant = "solid",
|
|
162
163
|
monospace = false,
|
|
163
164
|
tabIndex,
|
|
164
165
|
onDelete,
|
|
@@ -175,11 +176,11 @@ export const Chip = memo(function Chip({
|
|
|
175
176
|
const handleClick = !children && !deletable && addable ? onAdd : onClick;
|
|
176
177
|
|
|
177
178
|
const color =
|
|
178
|
-
colorScheme ===
|
|
179
|
+
colorScheme === "primary"
|
|
179
180
|
? theme.colors.primary
|
|
180
|
-
: colorScheme ===
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
: colorScheme === "secondary"
|
|
182
|
+
? theme.colors.secondary
|
|
183
|
+
: theme.colors.text;
|
|
183
184
|
|
|
184
185
|
return (
|
|
185
186
|
<ChipElement
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as DialogPrimitive from
|
|
1
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
2
2
|
import React, {
|
|
3
3
|
ComponentProps,
|
|
4
4
|
ForwardedRef,
|
|
@@ -6,35 +6,35 @@ import React, {
|
|
|
6
6
|
ReactNode,
|
|
7
7
|
useImperativeHandle,
|
|
8
8
|
useRef,
|
|
9
|
-
} from
|
|
10
|
-
import styled from
|
|
11
|
-
import { IconButton } from
|
|
12
|
-
import { Spacer } from
|
|
9
|
+
} from "react";
|
|
10
|
+
import styled from "styled-components";
|
|
11
|
+
import { IconButton } from "./IconButton";
|
|
12
|
+
import { Spacer } from "./Spacer";
|
|
13
13
|
|
|
14
14
|
const StyledOverlay = styled(DialogPrimitive.Overlay)({
|
|
15
|
-
backgroundColor:
|
|
16
|
-
position:
|
|
15
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
16
|
+
position: "fixed",
|
|
17
17
|
inset: 0,
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
const StyledContent = styled(DialogPrimitive.Content)(({ theme }) => ({
|
|
21
21
|
boxShadow:
|
|
22
|
-
|
|
23
|
-
position:
|
|
24
|
-
top:
|
|
25
|
-
left:
|
|
26
|
-
transform:
|
|
27
|
-
width:
|
|
28
|
-
maxWidth:
|
|
29
|
-
maxHeight:
|
|
22
|
+
"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
|
23
|
+
position: "fixed",
|
|
24
|
+
top: "50%",
|
|
25
|
+
left: "50%",
|
|
26
|
+
transform: "translate(-50%, -50%)",
|
|
27
|
+
width: "90vw",
|
|
28
|
+
maxWidth: "450px",
|
|
29
|
+
maxHeight: "85vh",
|
|
30
30
|
padding: theme.sizes.dialog.padding,
|
|
31
31
|
borderRadius: 2,
|
|
32
32
|
...theme.textStyles.small,
|
|
33
33
|
backgroundColor: theme.colors.popover.background,
|
|
34
|
-
overflowY:
|
|
34
|
+
overflowY: "auto",
|
|
35
35
|
color: theme.colors.textMuted,
|
|
36
|
-
|
|
37
|
-
pointerEvents:
|
|
36
|
+
"&:focus": { outline: "none" },
|
|
37
|
+
pointerEvents: "all",
|
|
38
38
|
zIndex: 1000,
|
|
39
39
|
}));
|
|
40
40
|
|
|
@@ -51,13 +51,13 @@ const StyledDescription = styled(DialogPrimitive.Description)(({ theme }) => ({
|
|
|
51
51
|
}));
|
|
52
52
|
|
|
53
53
|
export const CloseButtonContainer = styled.div(({ theme }) => ({
|
|
54
|
-
position:
|
|
54
|
+
position: "absolute",
|
|
55
55
|
top: theme.sizes.dialog.padding,
|
|
56
56
|
right: theme.sizes.dialog.padding,
|
|
57
57
|
zIndex: 1,
|
|
58
58
|
backgroundColor: theme.colors.popover.background,
|
|
59
|
-
padding:
|
|
60
|
-
borderRadius:
|
|
59
|
+
padding: "4px 6px",
|
|
60
|
+
borderRadius: "2px",
|
|
61
61
|
// boxShadow: `0 0 2px rgba(0, 0, 0, 0.2)`,
|
|
62
62
|
border: `1px solid rgba(128,128,128,0.2)`,
|
|
63
63
|
}));
|
|
@@ -70,12 +70,12 @@ interface Props {
|
|
|
70
70
|
title?: ReactNode;
|
|
71
71
|
description?: ReactNode;
|
|
72
72
|
children?: ReactNode;
|
|
73
|
-
style?: ComponentProps<typeof StyledContent>[
|
|
74
|
-
open: ComponentProps<typeof DialogPrimitive.Root>[
|
|
75
|
-
onOpenChange?: ComponentProps<typeof DialogPrimitive.Root>[
|
|
73
|
+
style?: ComponentProps<typeof StyledContent>["style"];
|
|
74
|
+
open: ComponentProps<typeof DialogPrimitive.Root>["open"];
|
|
75
|
+
onOpenChange?: ComponentProps<typeof DialogPrimitive.Root>["onOpenChange"];
|
|
76
76
|
onOpenAutoFocus?: ComponentProps<
|
|
77
77
|
typeof DialogPrimitive.Content
|
|
78
|
-
>[
|
|
78
|
+
>["onOpenAutoFocus"];
|
|
79
79
|
closeOnInteractOutside?: boolean;
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -90,7 +90,7 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
90
90
|
onOpenAutoFocus,
|
|
91
91
|
closeOnInteractOutside = true,
|
|
92
92
|
}: Props,
|
|
93
|
-
forwardedRef: ForwardedRef<IDialog
|
|
93
|
+
forwardedRef: ForwardedRef<IDialog>
|
|
94
94
|
) {
|
|
95
95
|
const contentRef = useRef<HTMLDivElement>(null);
|
|
96
96
|
|
|
@@ -141,3 +141,28 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
141
141
|
</DialogPrimitive.Root>
|
|
142
142
|
);
|
|
143
143
|
});
|
|
144
|
+
|
|
145
|
+
export const FullscreenDialog = forwardRef(function FullscreenDialog(
|
|
146
|
+
{ style, ...rest }: Props,
|
|
147
|
+
forwardedRef: ForwardedRef<IDialog>
|
|
148
|
+
) {
|
|
149
|
+
return (
|
|
150
|
+
<Dialog
|
|
151
|
+
ref={forwardedRef}
|
|
152
|
+
style={{
|
|
153
|
+
width: "100%",
|
|
154
|
+
height: "100%",
|
|
155
|
+
maxWidth: "100%",
|
|
156
|
+
maxHeight: "100%",
|
|
157
|
+
top: "0",
|
|
158
|
+
left: "0",
|
|
159
|
+
transform: "none",
|
|
160
|
+
display: "flex",
|
|
161
|
+
flexDirection: "column",
|
|
162
|
+
padding: 0,
|
|
163
|
+
...style,
|
|
164
|
+
}}
|
|
165
|
+
{...rest}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
});
|