@ttoss/ui 0.8.5 → 1.2.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 +104 -22
- package/dist/index.d.ts +16 -9
- package/dist/index.js +111 -30
- package/package.json +11 -7
- package/src/components/Button/Button.tsx +12 -2
- package/src/components/Card/Card.tsx +3 -0
- package/src/components/Link/Link.tsx +3 -0
- package/src/index.ts +8 -2
- package/src/theme/ThemeProvider.spec.tsx +74 -0
- package/src/theme/ThemeProvider.tsx +32 -8
- package/src/theme/defaultTheme.ts +42 -0
- package/src/theme/useTheme.ts +3 -0
- package/src/theme/theme.ts +0 -25
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
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 {
|
|
29
|
+
import { Global } from "@emotion/react";
|
|
30
|
+
import {
|
|
31
|
+
ThemeProvider as ThemeUiProvider,
|
|
32
|
+
merge
|
|
33
|
+
} from "@theme-ui/core";
|
|
34
|
+
import * as React2 from "react";
|
|
6
35
|
|
|
7
|
-
// src/theme/
|
|
8
|
-
var
|
|
36
|
+
// src/theme/defaultTheme.ts
|
|
37
|
+
var defaultTheme = {
|
|
9
38
|
colors: {
|
|
10
39
|
text: "#000",
|
|
11
40
|
background: "#fff",
|
|
@@ -13,41 +42,86 @@ var theme = {
|
|
|
13
42
|
secondary: "#639",
|
|
14
43
|
gray: "#555"
|
|
15
44
|
},
|
|
45
|
+
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
|
|
46
|
+
styles: {
|
|
47
|
+
a: {
|
|
48
|
+
color: "primary",
|
|
49
|
+
textDecoration: "underline",
|
|
50
|
+
cursor: "pointer"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
16
53
|
buttons: {
|
|
17
54
|
primary: {
|
|
18
|
-
color: "
|
|
19
|
-
|
|
55
|
+
color: "white",
|
|
56
|
+
backgroundColor: "primary"
|
|
20
57
|
},
|
|
21
58
|
secondary: {
|
|
22
|
-
color: "
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
59
|
+
color: "white",
|
|
60
|
+
backgroundColor: "secondary"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
cards: {
|
|
64
|
+
primary: {
|
|
65
|
+
backgroundColor: "background",
|
|
66
|
+
border: "1px solid black",
|
|
67
|
+
padding: [4, 5]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
text: {
|
|
71
|
+
title: {
|
|
72
|
+
fontSize: [4, 5],
|
|
73
|
+
textAlign: "center"
|
|
28
74
|
}
|
|
29
75
|
}
|
|
30
76
|
};
|
|
31
77
|
|
|
32
78
|
// src/theme/ThemeProvider.tsx
|
|
33
|
-
var ThemeProvider = ({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
79
|
+
var ThemeProvider = ({
|
|
80
|
+
children,
|
|
81
|
+
theme = {}
|
|
82
|
+
}) => {
|
|
83
|
+
const mergedTheme = React2.useMemo(() => {
|
|
84
|
+
if (typeof theme === "function") {
|
|
85
|
+
return theme;
|
|
86
|
+
}
|
|
87
|
+
return merge(defaultTheme, theme);
|
|
88
|
+
}, [theme]);
|
|
89
|
+
return /* @__PURE__ */ React2.createElement(ThemeUiProvider, {
|
|
90
|
+
theme: mergedTheme
|
|
91
|
+
}, /* @__PURE__ */ React2.createElement(Global, {
|
|
92
|
+
styles: {
|
|
93
|
+
"*": {
|
|
94
|
+
margin: 0
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}), children);
|
|
37
98
|
};
|
|
38
99
|
var ThemeProvider_default = ThemeProvider;
|
|
39
100
|
|
|
101
|
+
// src/theme/useTheme.ts
|
|
102
|
+
import { useThemeUI } from "@theme-ui/core";
|
|
103
|
+
var useTheme = useThemeUI;
|
|
104
|
+
|
|
40
105
|
// src/components/Box/Box.tsx
|
|
41
106
|
import { Box } from "@theme-ui/components";
|
|
42
107
|
|
|
43
108
|
// src/components/Button/Button.tsx
|
|
44
|
-
import { Button } from "@theme-ui/components";
|
|
109
|
+
import { Button as ButtonUi } from "@theme-ui/components";
|
|
110
|
+
var Button = (props) => {
|
|
111
|
+
return /* @__PURE__ */ React.createElement(ButtonUi, __spreadProps(__spreadValues({}, props), {
|
|
112
|
+
sx: __spreadValues({ cursor: "pointer", padding: 2 }, props.sx)
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
var Button_default = Button;
|
|
116
|
+
|
|
117
|
+
// src/components/Card/Card.tsx
|
|
118
|
+
import { Card } from "@theme-ui/components";
|
|
45
119
|
|
|
46
120
|
// src/components/Flex/Flex.tsx
|
|
47
121
|
import { Flex } from "@theme-ui/components";
|
|
48
122
|
|
|
49
123
|
// src/components/FormField/FormField.tsx
|
|
50
|
-
import * as
|
|
124
|
+
import * as React3 from "react";
|
|
51
125
|
|
|
52
126
|
// src/components/Label/Label.tsx
|
|
53
127
|
import { Label } from "@theme-ui/components";
|
|
@@ -66,11 +140,11 @@ var FormField = ({ children, label, error }) => {
|
|
|
66
140
|
}
|
|
67
141
|
return [];
|
|
68
142
|
})();
|
|
69
|
-
return /* @__PURE__ */
|
|
143
|
+
return /* @__PURE__ */ React3.createElement(Box, null, /* @__PURE__ */ React3.createElement(Label, {
|
|
70
144
|
sx: { display: "flex", flexDirection: "column" }
|
|
71
|
-
}, label && /* @__PURE__ */
|
|
145
|
+
}, label && /* @__PURE__ */ React3.createElement(Text, {
|
|
72
146
|
as: "span"
|
|
73
|
-
}, label), children), errorAsArray.map((err) => /* @__PURE__ */
|
|
147
|
+
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(Text, {
|
|
74
148
|
key: err,
|
|
75
149
|
as: "span",
|
|
76
150
|
variant: "error"
|
|
@@ -83,13 +157,21 @@ import { Image } from "@theme-ui/components";
|
|
|
83
157
|
|
|
84
158
|
// src/components/Input/Input.tsx
|
|
85
159
|
import { Input } from "@theme-ui/components";
|
|
160
|
+
|
|
161
|
+
// src/components/Link/Link.tsx
|
|
162
|
+
import { Link } from "@theme-ui/components";
|
|
86
163
|
export {
|
|
87
164
|
Box,
|
|
88
|
-
Button,
|
|
165
|
+
Button_default as Button,
|
|
166
|
+
Card,
|
|
89
167
|
Flex,
|
|
90
168
|
FormField_default as FormField,
|
|
91
169
|
Image,
|
|
92
170
|
Input,
|
|
171
|
+
Link,
|
|
93
172
|
Text,
|
|
94
|
-
ThemeProvider_default as ThemeProvider
|
|
173
|
+
ThemeProvider_default as ThemeProvider,
|
|
174
|
+
Themed,
|
|
175
|
+
color,
|
|
176
|
+
useTheme
|
|
95
177
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
3
|
-
import * as
|
|
1
|
+
import * as color from '@theme-ui/color';
|
|
2
|
+
export { color };
|
|
3
|
+
import * as _theme_ui_core from '@theme-ui/core';
|
|
4
|
+
import { ThemeProviderProps } from '@theme-ui/core';
|
|
5
|
+
export { Theme, ThemeProviderProps } from '@theme-ui/core';
|
|
6
|
+
export { Themed } from '@theme-ui/mdx';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { ButtonProps } from '@theme-ui/components';
|
|
9
|
+
export { Box, BoxProps, ButtonProps, Card, CardProps, Flex, FlexProps, Image, ImageProps, Input, InputProps, Link, LinkProps, Text, TextProps } from '@theme-ui/components';
|
|
4
10
|
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
declare const ThemeProvider: React.FC<Partial<ThemeProviderProps>>;
|
|
12
|
+
|
|
13
|
+
declare const useTheme: () => _theme_ui_core.ThemeUIContextValue;
|
|
14
|
+
|
|
15
|
+
declare const Button: (props: ButtonProps) => JSX.Element;
|
|
9
16
|
|
|
10
17
|
declare type FormFieldProps = {
|
|
11
|
-
children?: React
|
|
18
|
+
children?: React.ReactNode;
|
|
12
19
|
label?: string;
|
|
13
20
|
error?: string[] | string;
|
|
14
21
|
};
|
|
15
22
|
declare const FormField: ({ children, label, error }: FormFieldProps) => JSX.Element;
|
|
16
23
|
|
|
17
|
-
export { FormField, FormFieldProps, ThemeProvider,
|
|
24
|
+
export { Button, FormField, FormFieldProps, ThemeProvider, 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,23 +47,34 @@ 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
|
-
|
|
39
|
-
|
|
54
|
+
Image: () => import_components7.Image,
|
|
55
|
+
Input: () => import_components8.Input,
|
|
56
|
+
Link: () => import_components9.Link,
|
|
57
|
+
Text: () => import_components6.Text,
|
|
58
|
+
ThemeProvider: () => ThemeProvider_default,
|
|
59
|
+
Themed: () => import_mdx.Themed,
|
|
60
|
+
color: () => color,
|
|
61
|
+
useTheme: () => useTheme
|
|
40
62
|
});
|
|
41
63
|
|
|
42
64
|
// tsup.inject.js
|
|
43
65
|
var React = __toESM(require("react"));
|
|
44
66
|
|
|
67
|
+
// src/index.ts
|
|
68
|
+
var color = __toESM(require("@theme-ui/color"));
|
|
69
|
+
var import_mdx = require("@theme-ui/mdx");
|
|
70
|
+
|
|
45
71
|
// src/theme/ThemeProvider.tsx
|
|
72
|
+
var import_react = require("@emotion/react");
|
|
46
73
|
var import_core = require("@theme-ui/core");
|
|
74
|
+
var React2 = __toESM(require("react"));
|
|
47
75
|
|
|
48
|
-
// src/theme/
|
|
49
|
-
var
|
|
76
|
+
// src/theme/defaultTheme.ts
|
|
77
|
+
var defaultTheme = {
|
|
50
78
|
colors: {
|
|
51
79
|
text: "#000",
|
|
52
80
|
background: "#fff",
|
|
@@ -54,47 +82,92 @@ var theme = {
|
|
|
54
82
|
secondary: "#639",
|
|
55
83
|
gray: "#555"
|
|
56
84
|
},
|
|
85
|
+
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
|
|
86
|
+
styles: {
|
|
87
|
+
a: {
|
|
88
|
+
color: "primary",
|
|
89
|
+
textDecoration: "underline",
|
|
90
|
+
cursor: "pointer"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
57
93
|
buttons: {
|
|
58
94
|
primary: {
|
|
59
|
-
color: "
|
|
60
|
-
|
|
95
|
+
color: "white",
|
|
96
|
+
backgroundColor: "primary"
|
|
61
97
|
},
|
|
62
98
|
secondary: {
|
|
63
|
-
color: "
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
99
|
+
color: "white",
|
|
100
|
+
backgroundColor: "secondary"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
cards: {
|
|
104
|
+
primary: {
|
|
105
|
+
backgroundColor: "background",
|
|
106
|
+
border: "1px solid black",
|
|
107
|
+
padding: [4, 5]
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
text: {
|
|
111
|
+
title: {
|
|
112
|
+
fontSize: [4, 5],
|
|
113
|
+
textAlign: "center"
|
|
69
114
|
}
|
|
70
115
|
}
|
|
71
116
|
};
|
|
72
117
|
|
|
73
118
|
// src/theme/ThemeProvider.tsx
|
|
74
|
-
var ThemeProvider = ({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
119
|
+
var ThemeProvider = ({
|
|
120
|
+
children,
|
|
121
|
+
theme = {}
|
|
122
|
+
}) => {
|
|
123
|
+
const mergedTheme = React2.useMemo(() => {
|
|
124
|
+
if (typeof theme === "function") {
|
|
125
|
+
return theme;
|
|
126
|
+
}
|
|
127
|
+
return (0, import_core.merge)(defaultTheme, theme);
|
|
128
|
+
}, [theme]);
|
|
129
|
+
return /* @__PURE__ */ React2.createElement(import_core.ThemeProvider, {
|
|
130
|
+
theme: mergedTheme
|
|
131
|
+
}, /* @__PURE__ */ React2.createElement(import_react.Global, {
|
|
132
|
+
styles: {
|
|
133
|
+
"*": {
|
|
134
|
+
margin: 0
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}), children);
|
|
78
138
|
};
|
|
79
139
|
var ThemeProvider_default = ThemeProvider;
|
|
80
140
|
|
|
141
|
+
// src/theme/useTheme.ts
|
|
142
|
+
var import_core2 = require("@theme-ui/core");
|
|
143
|
+
var useTheme = import_core2.useThemeUI;
|
|
144
|
+
|
|
81
145
|
// src/components/Box/Box.tsx
|
|
82
146
|
var import_components = require("@theme-ui/components");
|
|
83
147
|
|
|
84
148
|
// src/components/Button/Button.tsx
|
|
85
149
|
var import_components2 = require("@theme-ui/components");
|
|
150
|
+
var Button = (props) => {
|
|
151
|
+
return /* @__PURE__ */ React.createElement(import_components2.Button, __spreadProps(__spreadValues({}, props), {
|
|
152
|
+
sx: __spreadValues({ cursor: "pointer", padding: 2 }, props.sx)
|
|
153
|
+
}));
|
|
154
|
+
};
|
|
155
|
+
var Button_default = Button;
|
|
86
156
|
|
|
87
|
-
// src/components/
|
|
157
|
+
// src/components/Card/Card.tsx
|
|
88
158
|
var import_components3 = require("@theme-ui/components");
|
|
89
159
|
|
|
160
|
+
// src/components/Flex/Flex.tsx
|
|
161
|
+
var import_components4 = require("@theme-ui/components");
|
|
162
|
+
|
|
90
163
|
// src/components/FormField/FormField.tsx
|
|
91
|
-
var
|
|
164
|
+
var React3 = __toESM(require("react"));
|
|
92
165
|
|
|
93
166
|
// src/components/Label/Label.tsx
|
|
94
|
-
var
|
|
167
|
+
var import_components5 = require("@theme-ui/components");
|
|
95
168
|
|
|
96
169
|
// src/components/Text/Text.tsx
|
|
97
|
-
var
|
|
170
|
+
var import_components6 = require("@theme-ui/components");
|
|
98
171
|
|
|
99
172
|
// src/components/FormField/FormField.tsx
|
|
100
173
|
var FormField = ({ children, label, error }) => {
|
|
@@ -107,11 +180,11 @@ var FormField = ({ children, label, error }) => {
|
|
|
107
180
|
}
|
|
108
181
|
return [];
|
|
109
182
|
})();
|
|
110
|
-
return /* @__PURE__ */
|
|
183
|
+
return /* @__PURE__ */ React3.createElement(import_components.Box, null, /* @__PURE__ */ React3.createElement(import_components5.Label, {
|
|
111
184
|
sx: { display: "flex", flexDirection: "column" }
|
|
112
|
-
}, label && /* @__PURE__ */
|
|
185
|
+
}, label && /* @__PURE__ */ React3.createElement(import_components6.Text, {
|
|
113
186
|
as: "span"
|
|
114
|
-
}, label), children), errorAsArray.map((err) => /* @__PURE__ */
|
|
187
|
+
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(import_components6.Text, {
|
|
115
188
|
key: err,
|
|
116
189
|
as: "span",
|
|
117
190
|
variant: "error"
|
|
@@ -120,19 +193,27 @@ var FormField = ({ children, label, error }) => {
|
|
|
120
193
|
var FormField_default = FormField;
|
|
121
194
|
|
|
122
195
|
// src/components/Image/Image.tsx
|
|
123
|
-
var
|
|
196
|
+
var import_components7 = require("@theme-ui/components");
|
|
124
197
|
|
|
125
198
|
// src/components/Input/Input.tsx
|
|
126
|
-
var
|
|
199
|
+
var import_components8 = require("@theme-ui/components");
|
|
200
|
+
|
|
201
|
+
// src/components/Link/Link.tsx
|
|
202
|
+
var import_components9 = require("@theme-ui/components");
|
|
127
203
|
module.exports = __toCommonJS(src_exports);
|
|
128
204
|
// Annotate the CommonJS export names for ESM import in node:
|
|
129
205
|
0 && (module.exports = {
|
|
130
206
|
Box,
|
|
131
207
|
Button,
|
|
208
|
+
Card,
|
|
132
209
|
Flex,
|
|
133
210
|
FormField,
|
|
134
211
|
Image,
|
|
135
212
|
Input,
|
|
213
|
+
Link,
|
|
136
214
|
Text,
|
|
137
|
-
ThemeProvider
|
|
215
|
+
ThemeProvider,
|
|
216
|
+
Themed,
|
|
217
|
+
color,
|
|
218
|
+
useTheme
|
|
138
219
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.2.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
|
-
"@
|
|
36
|
-
"@
|
|
35
|
+
"@emotion/react": "^11",
|
|
36
|
+
"@emotion/styled": "^11",
|
|
37
|
+
"@theme-ui/color": "^0.13.1",
|
|
38
|
+
"@theme-ui/components": "^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.2.0",
|
|
47
|
+
"@ttoss/test-utils": "^1.2.0"
|
|
44
48
|
},
|
|
45
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "f86ec742bf1e8baec64c99ad5950835a6ff8b5c1"
|
|
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;
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
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,
|
|
4
8
|
} from './theme/ThemeProvider';
|
|
5
9
|
|
|
6
|
-
export {
|
|
7
|
-
export type { BoxProps } from './components/Box/Box';
|
|
10
|
+
export { useTheme } from './theme/useTheme';
|
|
8
11
|
|
|
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,5 @@ 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';
|
|
17
23
|
export { default as Text, TextProps } from './components/Text/Text';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { renderHook } from '@ttoss/test-utils';
|
|
2
|
+
|
|
3
|
+
import { defaultTheme } from './defaultTheme';
|
|
4
|
+
import ThemeProvider from './ThemeProvider';
|
|
5
|
+
import { useTheme } from './useTheme';
|
|
6
|
+
|
|
7
|
+
test('should return default theme colors', () => {
|
|
8
|
+
const { result } = renderHook(() => useTheme(), {
|
|
9
|
+
wrapper: ThemeProvider,
|
|
10
|
+
initialProps: { theme: {} },
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
expect(result.current.theme.colors).toEqual(defaultTheme.colors);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('should return new theme colors', () => {
|
|
17
|
+
const newColor = '#000';
|
|
18
|
+
|
|
19
|
+
const { result } = renderHook(() => useTheme(), {
|
|
20
|
+
wrapper: ThemeProvider,
|
|
21
|
+
initialProps: {
|
|
22
|
+
theme: {
|
|
23
|
+
colors: {
|
|
24
|
+
background: newColor,
|
|
25
|
+
text: newColor,
|
|
26
|
+
primary: newColor,
|
|
27
|
+
secondary: newColor,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(result.current.theme.colors?.background).toEqual(newColor);
|
|
34
|
+
expect(result.current.theme.colors?.text).toEqual(newColor);
|
|
35
|
+
expect(result.current.theme.colors?.primary).toEqual(newColor);
|
|
36
|
+
expect(result.current.theme.colors?.secondary).toEqual(newColor);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('should pass variants', () => {
|
|
40
|
+
const authCard = {
|
|
41
|
+
backgroundColor: 'red',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const authLayout = {
|
|
45
|
+
backgroundColor: 'blue',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const variants = {
|
|
49
|
+
layout: {
|
|
50
|
+
auth: authLayout,
|
|
51
|
+
},
|
|
52
|
+
cards: {
|
|
53
|
+
auth: authCard,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const { result } = renderHook(() => useTheme(), {
|
|
58
|
+
wrapper: ThemeProvider,
|
|
59
|
+
initialProps: {
|
|
60
|
+
theme: {
|
|
61
|
+
colors: {},
|
|
62
|
+
...variants,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
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
|
+
);
|
|
74
|
+
});
|
|
@@ -1,15 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { Global } from '@emotion/react';
|
|
2
|
+
import {
|
|
3
|
+
ThemeProvider as ThemeUiProvider,
|
|
4
|
+
ThemeProviderProps,
|
|
5
|
+
merge,
|
|
6
|
+
} from '@theme-ui/core';
|
|
7
|
+
import * as React from 'react';
|
|
2
8
|
|
|
3
|
-
import {
|
|
9
|
+
import { defaultTheme } from './defaultTheme';
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
export type { ThemeProviderProps };
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
13
|
+
const ThemeProvider: React.FC<Partial<ThemeProviderProps>> = ({
|
|
14
|
+
children,
|
|
15
|
+
theme = {},
|
|
16
|
+
}) => {
|
|
17
|
+
const mergedTheme = React.useMemo(() => {
|
|
18
|
+
if (typeof theme === 'function') {
|
|
19
|
+
return theme;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return merge(defaultTheme, theme);
|
|
23
|
+
}, [theme]);
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
|
|
25
|
+
return (
|
|
26
|
+
<ThemeUiProvider theme={mergedTheme}>
|
|
27
|
+
<Global
|
|
28
|
+
styles={{
|
|
29
|
+
'*': {
|
|
30
|
+
margin: 0,
|
|
31
|
+
},
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
{children}
|
|
35
|
+
</ThemeUiProvider>
|
|
36
|
+
);
|
|
13
37
|
};
|
|
14
38
|
|
|
15
39
|
export default ThemeProvider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Theme } from '@theme-ui/core';
|
|
2
|
+
|
|
3
|
+
export const defaultTheme: Theme = {
|
|
4
|
+
colors: {
|
|
5
|
+
text: '#000',
|
|
6
|
+
background: '#fff',
|
|
7
|
+
primary: '#07c',
|
|
8
|
+
secondary: '#639',
|
|
9
|
+
gray: '#555',
|
|
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
|
+
},
|
|
19
|
+
buttons: {
|
|
20
|
+
primary: {
|
|
21
|
+
color: 'white',
|
|
22
|
+
backgroundColor: 'primary',
|
|
23
|
+
},
|
|
24
|
+
secondary: {
|
|
25
|
+
color: 'white',
|
|
26
|
+
backgroundColor: 'secondary',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
cards: {
|
|
30
|
+
primary: {
|
|
31
|
+
backgroundColor: 'background',
|
|
32
|
+
border: '1px solid black',
|
|
33
|
+
padding: [4, 5],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
text: {
|
|
37
|
+
title: {
|
|
38
|
+
fontSize: [4, 5],
|
|
39
|
+
textAlign: 'center',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
package/src/theme/theme.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Theme } from '@theme-ui/core';
|
|
2
|
-
|
|
3
|
-
export const theme: Theme = {
|
|
4
|
-
colors: {
|
|
5
|
-
text: '#000',
|
|
6
|
-
background: '#fff',
|
|
7
|
-
primary: '#07c',
|
|
8
|
-
secondary: '#639',
|
|
9
|
-
gray: '#555',
|
|
10
|
-
},
|
|
11
|
-
buttons: {
|
|
12
|
-
primary: {
|
|
13
|
-
color: 'background',
|
|
14
|
-
bg: 'primary',
|
|
15
|
-
},
|
|
16
|
-
secondary: {
|
|
17
|
-
color: 'background',
|
|
18
|
-
bg: 'secondary',
|
|
19
|
-
},
|
|
20
|
-
gray: {
|
|
21
|
-
color: 'background',
|
|
22
|
-
bg: 'gray',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|