@ttoss/ui 0.9.1 → 1.4.0
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/dist/esm/index.js +87 -20
- package/dist/index.d.ts +19 -5
- package/dist/index.js +99 -27
- package/package.json +10 -6
- package/src/components/Button/Button.tsx +12 -2
- package/src/components/Card/Card.tsx +3 -0
- package/src/components/FormField/FormField.spec.tsx +5 -5
- package/src/components/LinearProgress/LinearProgress.tsx +5 -0
- package/src/components/Link/Link.tsx +3 -0
- package/src/index.ts +10 -0
- package/src/theme/ThemeProvider.spec.tsx +7 -1
- package/src/theme/ThemeProvider.tsx +21 -11
- package/src/theme/defaultTheme.ts +28 -7
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
1
21
|
// tsup.inject.js
|
|
2
22
|
import * as React from "react";
|
|
3
23
|
|
|
24
|
+
// src/index.ts
|
|
25
|
+
import * as color from "@theme-ui/color";
|
|
26
|
+
import { Themed } from "@theme-ui/mdx";
|
|
27
|
+
|
|
4
28
|
// src/theme/ThemeProvider.tsx
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
merge
|
|
8
|
-
} from "@theme-ui/core";
|
|
29
|
+
import { Global } from "@emotion/react";
|
|
30
|
+
import { ThemeProvider as ThemeUiProvider, merge } from "@theme-ui/core";
|
|
9
31
|
import * as React2 from "react";
|
|
10
32
|
|
|
11
33
|
// src/theme/defaultTheme.ts
|
|
@@ -17,36 +39,60 @@ var defaultTheme = {
|
|
|
17
39
|
secondary: "#639",
|
|
18
40
|
gray: "#555"
|
|
19
41
|
},
|
|
42
|
+
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
|
|
43
|
+
styles: {
|
|
44
|
+
a: {
|
|
45
|
+
color: "primary",
|
|
46
|
+
textDecoration: "underline",
|
|
47
|
+
cursor: "pointer"
|
|
48
|
+
},
|
|
49
|
+
progress: {
|
|
50
|
+
color: "primary",
|
|
51
|
+
backgroundColor: "background"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
20
54
|
buttons: {
|
|
21
55
|
primary: {
|
|
22
|
-
color: "
|
|
23
|
-
|
|
56
|
+
color: "white",
|
|
57
|
+
backgroundColor: "primary"
|
|
24
58
|
},
|
|
25
59
|
secondary: {
|
|
26
|
-
color: "
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
60
|
+
color: "white",
|
|
61
|
+
backgroundColor: "secondary"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
cards: {
|
|
65
|
+
primary: {
|
|
66
|
+
backgroundColor: "background",
|
|
67
|
+
border: "1px solid black",
|
|
68
|
+
padding: [4, 5]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
text: {
|
|
72
|
+
title: {
|
|
73
|
+
fontSize: [4, 5],
|
|
74
|
+
textAlign: "center"
|
|
32
75
|
}
|
|
33
76
|
}
|
|
34
77
|
};
|
|
35
78
|
|
|
36
79
|
// src/theme/ThemeProvider.tsx
|
|
37
|
-
var ThemeProvider = ({
|
|
38
|
-
children,
|
|
39
|
-
theme = {}
|
|
40
|
-
}) => {
|
|
80
|
+
var ThemeProvider = ({ children, theme = {} }) => {
|
|
41
81
|
const mergedTheme = React2.useMemo(() => {
|
|
42
82
|
if (typeof theme === "function") {
|
|
43
83
|
return theme;
|
|
44
84
|
}
|
|
45
85
|
return merge(defaultTheme, theme);
|
|
46
86
|
}, [theme]);
|
|
47
|
-
return /* @__PURE__ */ React2.createElement(ThemeUiProvider, {
|
|
87
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ThemeUiProvider, {
|
|
48
88
|
theme: mergedTheme
|
|
49
|
-
},
|
|
89
|
+
}, /* @__PURE__ */ React2.createElement(Global, {
|
|
90
|
+
styles: {
|
|
91
|
+
"*": {
|
|
92
|
+
margin: 0
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}), children));
|
|
50
96
|
};
|
|
51
97
|
var ThemeProvider_default = ThemeProvider;
|
|
52
98
|
|
|
@@ -58,7 +104,16 @@ var useTheme = useThemeUI;
|
|
|
58
104
|
import { Box } from "@theme-ui/components";
|
|
59
105
|
|
|
60
106
|
// src/components/Button/Button.tsx
|
|
61
|
-
import { Button } from "@theme-ui/components";
|
|
107
|
+
import { Button as ButtonUi } from "@theme-ui/components";
|
|
108
|
+
var Button = (props) => {
|
|
109
|
+
return /* @__PURE__ */ React.createElement(ButtonUi, __spreadProps(__spreadValues({}, props), {
|
|
110
|
+
sx: __spreadValues({ cursor: "pointer", padding: 2 }, props.sx)
|
|
111
|
+
}));
|
|
112
|
+
};
|
|
113
|
+
var Button_default = Button;
|
|
114
|
+
|
|
115
|
+
// src/components/Card/Card.tsx
|
|
116
|
+
import { Card } from "@theme-ui/components";
|
|
62
117
|
|
|
63
118
|
// src/components/Flex/Flex.tsx
|
|
64
119
|
import { Flex } from "@theme-ui/components";
|
|
@@ -100,14 +155,26 @@ import { Image } from "@theme-ui/components";
|
|
|
100
155
|
|
|
101
156
|
// src/components/Input/Input.tsx
|
|
102
157
|
import { Input } from "@theme-ui/components";
|
|
158
|
+
|
|
159
|
+
// src/components/Link/Link.tsx
|
|
160
|
+
import { Link } from "@theme-ui/components";
|
|
161
|
+
|
|
162
|
+
// src/components/LinearProgress/LinearProgress.tsx
|
|
163
|
+
import { Progress } from "@theme-ui/components";
|
|
164
|
+
var LinearProgress = Progress;
|
|
103
165
|
export {
|
|
104
166
|
Box,
|
|
105
|
-
Button,
|
|
167
|
+
Button_default as Button,
|
|
168
|
+
Card,
|
|
106
169
|
Flex,
|
|
107
170
|
FormField_default as FormField,
|
|
108
171
|
Image,
|
|
109
172
|
Input,
|
|
173
|
+
LinearProgress,
|
|
174
|
+
Link,
|
|
110
175
|
Text,
|
|
111
176
|
ThemeProvider_default as ThemeProvider,
|
|
177
|
+
Themed,
|
|
178
|
+
color,
|
|
112
179
|
useTheme
|
|
113
180
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import * as color from '@theme-ui/color';
|
|
2
|
+
export { color };
|
|
1
3
|
import * as _theme_ui_core from '@theme-ui/core';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
+
import { Theme } from '@theme-ui/core';
|
|
5
|
+
export { Theme } from '@theme-ui/core';
|
|
6
|
+
export { Themed } from '@theme-ui/mdx';
|
|
4
7
|
import * as React from 'react';
|
|
5
|
-
|
|
8
|
+
import * as _theme_ui_components from '@theme-ui/components';
|
|
9
|
+
import { ButtonProps, ProgressProps } from '@theme-ui/components';
|
|
10
|
+
export { Box, BoxProps, ButtonProps, Card, CardProps, Flex, FlexProps, Image, ImageProps, Input, InputProps, Link, LinkProps, Text, TextProps } from '@theme-ui/components';
|
|
6
11
|
|
|
7
|
-
declare
|
|
12
|
+
declare type ThemeProviderProps = {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
theme?: Theme;
|
|
15
|
+
};
|
|
16
|
+
declare const ThemeProvider: ({ children, theme }: ThemeProviderProps) => JSX.Element;
|
|
8
17
|
|
|
9
18
|
declare const useTheme: () => _theme_ui_core.ThemeUIContextValue;
|
|
10
19
|
|
|
20
|
+
declare const Button: (props: ButtonProps) => JSX.Element;
|
|
21
|
+
|
|
11
22
|
declare type FormFieldProps = {
|
|
12
23
|
children?: React.ReactNode;
|
|
13
24
|
label?: string;
|
|
@@ -15,4 +26,7 @@ declare type FormFieldProps = {
|
|
|
15
26
|
};
|
|
16
27
|
declare const FormField: ({ children, label, error }: FormFieldProps) => JSX.Element;
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
declare type LinearProgressProps = ProgressProps;
|
|
30
|
+
declare const LinearProgress: _theme_ui_components.ForwardRef<HTMLProgressElement, ProgressProps>;
|
|
31
|
+
|
|
32
|
+
export { Button, FormField, FormFieldProps, LinearProgress, LinearProgressProps, ThemeProvider, ThemeProviderProps, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
25
|
var __export = (target, all) => {
|
|
9
26
|
for (var name in all)
|
|
@@ -30,20 +47,30 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
30
47
|
var src_exports = {};
|
|
31
48
|
__export(src_exports, {
|
|
32
49
|
Box: () => import_components.Box,
|
|
33
|
-
Button: () =>
|
|
34
|
-
|
|
50
|
+
Button: () => Button_default,
|
|
51
|
+
Card: () => import_components3.Card,
|
|
52
|
+
Flex: () => import_components4.Flex,
|
|
35
53
|
FormField: () => FormField_default,
|
|
36
|
-
Image: () =>
|
|
37
|
-
Input: () =>
|
|
38
|
-
|
|
54
|
+
Image: () => import_components7.Image,
|
|
55
|
+
Input: () => import_components8.Input,
|
|
56
|
+
LinearProgress: () => LinearProgress,
|
|
57
|
+
Link: () => import_components9.Link,
|
|
58
|
+
Text: () => import_components6.Text,
|
|
39
59
|
ThemeProvider: () => ThemeProvider_default,
|
|
60
|
+
Themed: () => import_mdx.Themed,
|
|
61
|
+
color: () => color,
|
|
40
62
|
useTheme: () => useTheme
|
|
41
63
|
});
|
|
42
64
|
|
|
43
65
|
// tsup.inject.js
|
|
44
66
|
var React = __toESM(require("react"));
|
|
45
67
|
|
|
68
|
+
// src/index.ts
|
|
69
|
+
var color = __toESM(require("@theme-ui/color"));
|
|
70
|
+
var import_mdx = require("@theme-ui/mdx");
|
|
71
|
+
|
|
46
72
|
// src/theme/ThemeProvider.tsx
|
|
73
|
+
var import_react = require("@emotion/react");
|
|
47
74
|
var import_core = require("@theme-ui/core");
|
|
48
75
|
var React2 = __toESM(require("react"));
|
|
49
76
|
|
|
@@ -56,36 +83,60 @@ var defaultTheme = {
|
|
|
56
83
|
secondary: "#639",
|
|
57
84
|
gray: "#555"
|
|
58
85
|
},
|
|
86
|
+
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
|
|
87
|
+
styles: {
|
|
88
|
+
a: {
|
|
89
|
+
color: "primary",
|
|
90
|
+
textDecoration: "underline",
|
|
91
|
+
cursor: "pointer"
|
|
92
|
+
},
|
|
93
|
+
progress: {
|
|
94
|
+
color: "primary",
|
|
95
|
+
backgroundColor: "background"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
59
98
|
buttons: {
|
|
60
99
|
primary: {
|
|
61
|
-
color: "
|
|
62
|
-
|
|
100
|
+
color: "white",
|
|
101
|
+
backgroundColor: "primary"
|
|
63
102
|
},
|
|
64
103
|
secondary: {
|
|
65
|
-
color: "
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
color: "white",
|
|
105
|
+
backgroundColor: "secondary"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
cards: {
|
|
109
|
+
primary: {
|
|
110
|
+
backgroundColor: "background",
|
|
111
|
+
border: "1px solid black",
|
|
112
|
+
padding: [4, 5]
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
text: {
|
|
116
|
+
title: {
|
|
117
|
+
fontSize: [4, 5],
|
|
118
|
+
textAlign: "center"
|
|
71
119
|
}
|
|
72
120
|
}
|
|
73
121
|
};
|
|
74
122
|
|
|
75
123
|
// src/theme/ThemeProvider.tsx
|
|
76
|
-
var ThemeProvider = ({
|
|
77
|
-
children,
|
|
78
|
-
theme = {}
|
|
79
|
-
}) => {
|
|
124
|
+
var ThemeProvider = ({ children, theme = {} }) => {
|
|
80
125
|
const mergedTheme = React2.useMemo(() => {
|
|
81
126
|
if (typeof theme === "function") {
|
|
82
127
|
return theme;
|
|
83
128
|
}
|
|
84
129
|
return (0, import_core.merge)(defaultTheme, theme);
|
|
85
130
|
}, [theme]);
|
|
86
|
-
return /* @__PURE__ */ React2.createElement(import_core.ThemeProvider, {
|
|
131
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(import_core.ThemeProvider, {
|
|
87
132
|
theme: mergedTheme
|
|
88
|
-
},
|
|
133
|
+
}, /* @__PURE__ */ React2.createElement(import_react.Global, {
|
|
134
|
+
styles: {
|
|
135
|
+
"*": {
|
|
136
|
+
margin: 0
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}), children));
|
|
89
140
|
};
|
|
90
141
|
var ThemeProvider_default = ThemeProvider;
|
|
91
142
|
|
|
@@ -98,18 +149,27 @@ var import_components = require("@theme-ui/components");
|
|
|
98
149
|
|
|
99
150
|
// src/components/Button/Button.tsx
|
|
100
151
|
var import_components2 = require("@theme-ui/components");
|
|
152
|
+
var Button = (props) => {
|
|
153
|
+
return /* @__PURE__ */ React.createElement(import_components2.Button, __spreadProps(__spreadValues({}, props), {
|
|
154
|
+
sx: __spreadValues({ cursor: "pointer", padding: 2 }, props.sx)
|
|
155
|
+
}));
|
|
156
|
+
};
|
|
157
|
+
var Button_default = Button;
|
|
101
158
|
|
|
102
|
-
// src/components/
|
|
159
|
+
// src/components/Card/Card.tsx
|
|
103
160
|
var import_components3 = require("@theme-ui/components");
|
|
104
161
|
|
|
162
|
+
// src/components/Flex/Flex.tsx
|
|
163
|
+
var import_components4 = require("@theme-ui/components");
|
|
164
|
+
|
|
105
165
|
// src/components/FormField/FormField.tsx
|
|
106
166
|
var React3 = __toESM(require("react"));
|
|
107
167
|
|
|
108
168
|
// src/components/Label/Label.tsx
|
|
109
|
-
var
|
|
169
|
+
var import_components5 = require("@theme-ui/components");
|
|
110
170
|
|
|
111
171
|
// src/components/Text/Text.tsx
|
|
112
|
-
var
|
|
172
|
+
var import_components6 = require("@theme-ui/components");
|
|
113
173
|
|
|
114
174
|
// src/components/FormField/FormField.tsx
|
|
115
175
|
var FormField = ({ children, label, error }) => {
|
|
@@ -122,11 +182,11 @@ var FormField = ({ children, label, error }) => {
|
|
|
122
182
|
}
|
|
123
183
|
return [];
|
|
124
184
|
})();
|
|
125
|
-
return /* @__PURE__ */ React3.createElement(import_components.Box, null, /* @__PURE__ */ React3.createElement(
|
|
185
|
+
return /* @__PURE__ */ React3.createElement(import_components.Box, null, /* @__PURE__ */ React3.createElement(import_components5.Label, {
|
|
126
186
|
sx: { display: "flex", flexDirection: "column" }
|
|
127
|
-
}, label && /* @__PURE__ */ React3.createElement(
|
|
187
|
+
}, label && /* @__PURE__ */ React3.createElement(import_components6.Text, {
|
|
128
188
|
as: "span"
|
|
129
|
-
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(
|
|
189
|
+
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(import_components6.Text, {
|
|
130
190
|
key: err,
|
|
131
191
|
as: "span",
|
|
132
192
|
variant: "error"
|
|
@@ -135,20 +195,32 @@ var FormField = ({ children, label, error }) => {
|
|
|
135
195
|
var FormField_default = FormField;
|
|
136
196
|
|
|
137
197
|
// src/components/Image/Image.tsx
|
|
138
|
-
var
|
|
198
|
+
var import_components7 = require("@theme-ui/components");
|
|
139
199
|
|
|
140
200
|
// src/components/Input/Input.tsx
|
|
141
|
-
var
|
|
201
|
+
var import_components8 = require("@theme-ui/components");
|
|
202
|
+
|
|
203
|
+
// src/components/Link/Link.tsx
|
|
204
|
+
var import_components9 = require("@theme-ui/components");
|
|
205
|
+
|
|
206
|
+
// src/components/LinearProgress/LinearProgress.tsx
|
|
207
|
+
var import_components10 = require("@theme-ui/components");
|
|
208
|
+
var LinearProgress = import_components10.Progress;
|
|
142
209
|
module.exports = __toCommonJS(src_exports);
|
|
143
210
|
// Annotate the CommonJS export names for ESM import in node:
|
|
144
211
|
0 && (module.exports = {
|
|
145
212
|
Box,
|
|
146
213
|
Button,
|
|
214
|
+
Card,
|
|
147
215
|
Flex,
|
|
148
216
|
FormField,
|
|
149
217
|
Image,
|
|
150
218
|
Input,
|
|
219
|
+
LinearProgress,
|
|
220
|
+
Link,
|
|
151
221
|
Text,
|
|
152
222
|
ThemeProvider,
|
|
223
|
+
Themed,
|
|
224
|
+
color,
|
|
153
225
|
useTheme
|
|
154
226
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,15 +32,19 @@
|
|
|
32
32
|
"dev": "yarn workspace @ttoss/storybook run dev"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@emotion/react": "^11",
|
|
36
|
+
"@emotion/styled": "^11",
|
|
37
|
+
"@theme-ui/color": "^0.13.1",
|
|
35
38
|
"@theme-ui/components": "^0.13.1",
|
|
36
|
-
"@theme-ui/core": "^0.13.1"
|
|
39
|
+
"@theme-ui/core": "^0.13.1",
|
|
40
|
+
"@theme-ui/mdx": "^0.13.1"
|
|
37
41
|
},
|
|
38
42
|
"peerDependencies": {
|
|
39
|
-
"react": ">=
|
|
43
|
+
"react": ">=17.0.2"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"@ttoss/config": "^
|
|
43
|
-
"@ttoss/test-utils": "^
|
|
46
|
+
"@ttoss/config": "^1.4.0",
|
|
47
|
+
"@ttoss/test-utils": "^1.4.0"
|
|
44
48
|
},
|
|
45
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d5ba3afb31742bb86625512b11188841fea0152b"
|
|
46
50
|
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { Button as ButtonUi } from '@theme-ui/components';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { ButtonProps } from '@theme-ui/components';
|
|
4
|
+
|
|
5
|
+
export type { ButtonProps };
|
|
6
|
+
|
|
7
|
+
const Button = (props: ButtonProps) => {
|
|
8
|
+
return (
|
|
9
|
+
<ButtonUi {...props} sx={{ cursor: 'pointer', padding: 2, ...props.sx }} />
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default Button;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from '@ttoss/test-utils';
|
|
2
2
|
|
|
3
3
|
import Input from '../Input/Input';
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ const label = 'Label';
|
|
|
8
8
|
const value = 'Value';
|
|
9
9
|
|
|
10
10
|
test('check if label is rendered on screen', () => {
|
|
11
|
-
|
|
11
|
+
render(
|
|
12
12
|
<FormField label={label}>
|
|
13
13
|
<Input defaultValue={value} />
|
|
14
14
|
</FormField>
|
|
@@ -18,7 +18,7 @@ test('check if label is rendered on screen', () => {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
test('check if label is associated with input', () => {
|
|
21
|
-
|
|
21
|
+
render(
|
|
22
22
|
<FormField label={label}>
|
|
23
23
|
<Input defaultValue={value} />
|
|
24
24
|
</FormField>
|
|
@@ -30,7 +30,7 @@ test('check if label is associated with input', () => {
|
|
|
30
30
|
test('check if renders a single error', () => {
|
|
31
31
|
const error = 'Error';
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
render(
|
|
34
34
|
<FormField label={label} error={error}>
|
|
35
35
|
<Input defaultValue={value} />
|
|
36
36
|
</FormField>
|
|
@@ -42,7 +42,7 @@ test('check if renders a single error', () => {
|
|
|
42
42
|
test('check if renders multiple errors', () => {
|
|
43
43
|
const errors = ['Error1', 'Error2', 'Error3'];
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
render(
|
|
46
46
|
<FormField label={label} error={errors}>
|
|
47
47
|
<Input defaultValue={value} />
|
|
48
48
|
</FormField>
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export * as color from '@theme-ui/color';
|
|
2
|
+
export type { Theme } from '@theme-ui/core';
|
|
3
|
+
export { Themed } from '@theme-ui/mdx';
|
|
4
|
+
|
|
1
5
|
export {
|
|
2
6
|
default as ThemeProvider,
|
|
3
7
|
ThemeProviderProps,
|
|
@@ -7,6 +11,7 @@ export { useTheme } from './theme/useTheme';
|
|
|
7
11
|
|
|
8
12
|
export { default as Box, BoxProps } from './components/Box/Box';
|
|
9
13
|
export { default as Button, ButtonProps } from './components/Button/Button';
|
|
14
|
+
export { default as Card, CardProps } from './components/Card/Card';
|
|
10
15
|
export { default as Flex, FlexProps } from './components/Flex/Flex';
|
|
11
16
|
export {
|
|
12
17
|
default as FormField,
|
|
@@ -14,4 +19,9 @@ export {
|
|
|
14
19
|
} from './components/FormField/FormField';
|
|
15
20
|
export { default as Image, ImageProps } from './components/Image/Image';
|
|
16
21
|
export { default as Input, InputProps } from './components/Input/Input';
|
|
22
|
+
export { default as Link, LinkProps } from './components/Link/Link';
|
|
23
|
+
export {
|
|
24
|
+
LinearProgress,
|
|
25
|
+
LinearProgressProps,
|
|
26
|
+
} from './components/LinearProgress/LinearProgress';
|
|
17
27
|
export { default as Text, TextProps } from './components/Text/Text';
|
|
@@ -64,5 +64,11 @@ test('should pass variants', () => {
|
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
expect(result.current.theme).toEqual(
|
|
67
|
+
expect(result.current.theme.cards).toEqual(
|
|
68
|
+
expect.objectContaining(variants.cards)
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(result.current.theme.layout).toEqual(
|
|
72
|
+
expect.objectContaining(variants.layout)
|
|
73
|
+
);
|
|
68
74
|
});
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ThemeProviderProps,
|
|
4
|
-
merge,
|
|
5
|
-
} from '@theme-ui/core';
|
|
1
|
+
import { Global } from '@emotion/react';
|
|
2
|
+
import { ThemeProvider as ThemeUiProvider, Theme, merge } from '@theme-ui/core';
|
|
6
3
|
import * as React from 'react';
|
|
7
4
|
|
|
8
5
|
import { defaultTheme } from './defaultTheme';
|
|
9
6
|
|
|
10
|
-
export type
|
|
7
|
+
export type ThemeProviderProps = {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
theme?: Theme;
|
|
10
|
+
};
|
|
11
11
|
|
|
12
|
-
const ThemeProvider:
|
|
13
|
-
children,
|
|
14
|
-
theme = {},
|
|
15
|
-
}) => {
|
|
12
|
+
const ThemeProvider = ({ children, theme = {} }: ThemeProviderProps) => {
|
|
16
13
|
const mergedTheme = React.useMemo(() => {
|
|
17
14
|
if (typeof theme === 'function') {
|
|
18
15
|
return theme;
|
|
@@ -21,7 +18,20 @@ const ThemeProvider: React.FC<Partial<ThemeProviderProps>> = ({
|
|
|
21
18
|
return merge(defaultTheme, theme);
|
|
22
19
|
}, [theme]);
|
|
23
20
|
|
|
24
|
-
return
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<ThemeUiProvider theme={mergedTheme}>
|
|
24
|
+
<Global
|
|
25
|
+
styles={{
|
|
26
|
+
'*': {
|
|
27
|
+
margin: 0,
|
|
28
|
+
},
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
{children}
|
|
32
|
+
</ThemeUiProvider>
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
25
35
|
};
|
|
26
36
|
|
|
27
37
|
export default ThemeProvider;
|
|
@@ -8,18 +8,39 @@ export const defaultTheme: Theme = {
|
|
|
8
8
|
secondary: '#639',
|
|
9
9
|
gray: '#555',
|
|
10
10
|
},
|
|
11
|
+
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
|
|
12
|
+
styles: {
|
|
13
|
+
a: {
|
|
14
|
+
color: 'primary',
|
|
15
|
+
textDecoration: 'underline',
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
},
|
|
18
|
+
progress: {
|
|
19
|
+
color: 'primary',
|
|
20
|
+
backgroundColor: 'background',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
11
23
|
buttons: {
|
|
12
24
|
primary: {
|
|
13
|
-
color: '
|
|
14
|
-
|
|
25
|
+
color: 'white',
|
|
26
|
+
backgroundColor: 'primary',
|
|
15
27
|
},
|
|
16
28
|
secondary: {
|
|
17
|
-
color: '
|
|
18
|
-
|
|
29
|
+
color: 'white',
|
|
30
|
+
backgroundColor: 'secondary',
|
|
19
31
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
},
|
|
33
|
+
cards: {
|
|
34
|
+
primary: {
|
|
35
|
+
backgroundColor: 'background',
|
|
36
|
+
border: '1px solid black',
|
|
37
|
+
padding: [4, 5],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
text: {
|
|
41
|
+
title: {
|
|
42
|
+
fontSize: [4, 5],
|
|
43
|
+
textAlign: 'center',
|
|
23
44
|
},
|
|
24
45
|
},
|
|
25
46
|
};
|