@ttoss/ui 0.9.2 → 1.4.1
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 +180 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +226 -0
- package/package.json +8 -6
- package/src/components/Button/Button.tsx +12 -2
- 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 +9 -0
- package/src/theme/ThemeProvider.spec.tsx +7 -1
- package/src/theme/ThemeProvider.tsx +21 -11
- package/src/theme/defaultTheme.ts +28 -7
|
@@ -0,0 +1,180 @@
|
|
|
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
|
+
|
|
21
|
+
// tsup.inject.js
|
|
22
|
+
import * as React from "react";
|
|
23
|
+
|
|
24
|
+
// src/index.ts
|
|
25
|
+
import * as color from "@theme-ui/color";
|
|
26
|
+
import { Themed } from "@theme-ui/mdx";
|
|
27
|
+
|
|
28
|
+
// src/theme/ThemeProvider.tsx
|
|
29
|
+
import { Global } from "@emotion/react";
|
|
30
|
+
import { ThemeProvider as ThemeUiProvider, merge } from "@theme-ui/core";
|
|
31
|
+
import * as React2 from "react";
|
|
32
|
+
|
|
33
|
+
// src/theme/defaultTheme.ts
|
|
34
|
+
var defaultTheme = {
|
|
35
|
+
colors: {
|
|
36
|
+
text: "#000",
|
|
37
|
+
background: "#fff",
|
|
38
|
+
primary: "#07c",
|
|
39
|
+
secondary: "#639",
|
|
40
|
+
gray: "#555"
|
|
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
|
+
},
|
|
54
|
+
buttons: {
|
|
55
|
+
primary: {
|
|
56
|
+
color: "white",
|
|
57
|
+
backgroundColor: "primary"
|
|
58
|
+
},
|
|
59
|
+
secondary: {
|
|
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"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/theme/ThemeProvider.tsx
|
|
80
|
+
var ThemeProvider = ({ children, theme = {} }) => {
|
|
81
|
+
const mergedTheme = React2.useMemo(() => {
|
|
82
|
+
if (typeof theme === "function") {
|
|
83
|
+
return theme;
|
|
84
|
+
}
|
|
85
|
+
return merge(defaultTheme, theme);
|
|
86
|
+
}, [theme]);
|
|
87
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ThemeUiProvider, {
|
|
88
|
+
theme: mergedTheme
|
|
89
|
+
}, /* @__PURE__ */ React2.createElement(Global, {
|
|
90
|
+
styles: {
|
|
91
|
+
"*": {
|
|
92
|
+
margin: 0
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}), children));
|
|
96
|
+
};
|
|
97
|
+
var ThemeProvider_default = ThemeProvider;
|
|
98
|
+
|
|
99
|
+
// src/theme/useTheme.ts
|
|
100
|
+
import { useThemeUI } from "@theme-ui/core";
|
|
101
|
+
var useTheme = useThemeUI;
|
|
102
|
+
|
|
103
|
+
// src/components/Box/Box.tsx
|
|
104
|
+
import { Box } from "@theme-ui/components";
|
|
105
|
+
|
|
106
|
+
// src/components/Button/Button.tsx
|
|
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";
|
|
117
|
+
|
|
118
|
+
// src/components/Flex/Flex.tsx
|
|
119
|
+
import { Flex } from "@theme-ui/components";
|
|
120
|
+
|
|
121
|
+
// src/components/FormField/FormField.tsx
|
|
122
|
+
import * as React3 from "react";
|
|
123
|
+
|
|
124
|
+
// src/components/Label/Label.tsx
|
|
125
|
+
import { Label } from "@theme-ui/components";
|
|
126
|
+
|
|
127
|
+
// src/components/Text/Text.tsx
|
|
128
|
+
import { Text } from "@theme-ui/components";
|
|
129
|
+
|
|
130
|
+
// src/components/FormField/FormField.tsx
|
|
131
|
+
var FormField = ({ children, label, error }) => {
|
|
132
|
+
const errorAsArray = (() => {
|
|
133
|
+
if (Array.isArray(error)) {
|
|
134
|
+
return error;
|
|
135
|
+
}
|
|
136
|
+
if (typeof error === "string") {
|
|
137
|
+
return [error];
|
|
138
|
+
}
|
|
139
|
+
return [];
|
|
140
|
+
})();
|
|
141
|
+
return /* @__PURE__ */ React3.createElement(Box, null, /* @__PURE__ */ React3.createElement(Label, {
|
|
142
|
+
sx: { display: "flex", flexDirection: "column" }
|
|
143
|
+
}, label && /* @__PURE__ */ React3.createElement(Text, {
|
|
144
|
+
as: "span"
|
|
145
|
+
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(Text, {
|
|
146
|
+
key: err,
|
|
147
|
+
as: "span",
|
|
148
|
+
variant: "error"
|
|
149
|
+
}, err)));
|
|
150
|
+
};
|
|
151
|
+
var FormField_default = FormField;
|
|
152
|
+
|
|
153
|
+
// src/components/Image/Image.tsx
|
|
154
|
+
import { Image } from "@theme-ui/components";
|
|
155
|
+
|
|
156
|
+
// src/components/Input/Input.tsx
|
|
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;
|
|
165
|
+
export {
|
|
166
|
+
Box,
|
|
167
|
+
Button_default as Button,
|
|
168
|
+
Card,
|
|
169
|
+
Flex,
|
|
170
|
+
FormField_default as FormField,
|
|
171
|
+
Image,
|
|
172
|
+
Input,
|
|
173
|
+
LinearProgress,
|
|
174
|
+
Link,
|
|
175
|
+
Text,
|
|
176
|
+
ThemeProvider_default as ThemeProvider,
|
|
177
|
+
Themed,
|
|
178
|
+
color,
|
|
179
|
+
useTheme
|
|
180
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as color from '@theme-ui/color';
|
|
2
|
+
export { color };
|
|
3
|
+
import * as _theme_ui_core from '@theme-ui/core';
|
|
4
|
+
import { Theme } from '@theme-ui/core';
|
|
5
|
+
export { Theme } from '@theme-ui/core';
|
|
6
|
+
export { Themed } from '@theme-ui/mdx';
|
|
7
|
+
import * as React from 'react';
|
|
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';
|
|
11
|
+
|
|
12
|
+
declare type ThemeProviderProps = {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
theme?: Theme;
|
|
15
|
+
};
|
|
16
|
+
declare const ThemeProvider: ({ children, theme }: ThemeProviderProps) => JSX.Element;
|
|
17
|
+
|
|
18
|
+
declare const useTheme: () => _theme_ui_core.ThemeUIContextValue;
|
|
19
|
+
|
|
20
|
+
declare const Button: (props: ButtonProps) => JSX.Element;
|
|
21
|
+
|
|
22
|
+
declare type FormFieldProps = {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
label?: string;
|
|
25
|
+
error?: string[] | string;
|
|
26
|
+
};
|
|
27
|
+
declare const FormField: ({ children, label, error }: FormFieldProps) => JSX.Element;
|
|
28
|
+
|
|
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
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
30
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(module2))
|
|
32
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
33
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (module2, isNodeMode) => {
|
|
38
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
39
|
+
};
|
|
40
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
+
return (module2, temp) => {
|
|
42
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
+
};
|
|
44
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
45
|
+
|
|
46
|
+
// src/index.ts
|
|
47
|
+
var src_exports = {};
|
|
48
|
+
__export(src_exports, {
|
|
49
|
+
Box: () => import_components.Box,
|
|
50
|
+
Button: () => Button_default,
|
|
51
|
+
Card: () => import_components3.Card,
|
|
52
|
+
Flex: () => import_components4.Flex,
|
|
53
|
+
FormField: () => FormField_default,
|
|
54
|
+
Image: () => import_components7.Image,
|
|
55
|
+
Input: () => import_components8.Input,
|
|
56
|
+
LinearProgress: () => LinearProgress,
|
|
57
|
+
Link: () => import_components9.Link,
|
|
58
|
+
Text: () => import_components6.Text,
|
|
59
|
+
ThemeProvider: () => ThemeProvider_default,
|
|
60
|
+
Themed: () => import_mdx.Themed,
|
|
61
|
+
color: () => color,
|
|
62
|
+
useTheme: () => useTheme
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// tsup.inject.js
|
|
66
|
+
var React = __toESM(require("react"));
|
|
67
|
+
|
|
68
|
+
// src/index.ts
|
|
69
|
+
var color = __toESM(require("@theme-ui/color"));
|
|
70
|
+
var import_mdx = require("@theme-ui/mdx");
|
|
71
|
+
|
|
72
|
+
// src/theme/ThemeProvider.tsx
|
|
73
|
+
var import_react = require("@emotion/react");
|
|
74
|
+
var import_core = require("@theme-ui/core");
|
|
75
|
+
var React2 = __toESM(require("react"));
|
|
76
|
+
|
|
77
|
+
// src/theme/defaultTheme.ts
|
|
78
|
+
var defaultTheme = {
|
|
79
|
+
colors: {
|
|
80
|
+
text: "#000",
|
|
81
|
+
background: "#fff",
|
|
82
|
+
primary: "#07c",
|
|
83
|
+
secondary: "#639",
|
|
84
|
+
gray: "#555"
|
|
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
|
+
},
|
|
98
|
+
buttons: {
|
|
99
|
+
primary: {
|
|
100
|
+
color: "white",
|
|
101
|
+
backgroundColor: "primary"
|
|
102
|
+
},
|
|
103
|
+
secondary: {
|
|
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"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// src/theme/ThemeProvider.tsx
|
|
124
|
+
var ThemeProvider = ({ children, theme = {} }) => {
|
|
125
|
+
const mergedTheme = React2.useMemo(() => {
|
|
126
|
+
if (typeof theme === "function") {
|
|
127
|
+
return theme;
|
|
128
|
+
}
|
|
129
|
+
return (0, import_core.merge)(defaultTheme, theme);
|
|
130
|
+
}, [theme]);
|
|
131
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(import_core.ThemeProvider, {
|
|
132
|
+
theme: mergedTheme
|
|
133
|
+
}, /* @__PURE__ */ React2.createElement(import_react.Global, {
|
|
134
|
+
styles: {
|
|
135
|
+
"*": {
|
|
136
|
+
margin: 0
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}), children));
|
|
140
|
+
};
|
|
141
|
+
var ThemeProvider_default = ThemeProvider;
|
|
142
|
+
|
|
143
|
+
// src/theme/useTheme.ts
|
|
144
|
+
var import_core2 = require("@theme-ui/core");
|
|
145
|
+
var useTheme = import_core2.useThemeUI;
|
|
146
|
+
|
|
147
|
+
// src/components/Box/Box.tsx
|
|
148
|
+
var import_components = require("@theme-ui/components");
|
|
149
|
+
|
|
150
|
+
// src/components/Button/Button.tsx
|
|
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;
|
|
158
|
+
|
|
159
|
+
// src/components/Card/Card.tsx
|
|
160
|
+
var import_components3 = require("@theme-ui/components");
|
|
161
|
+
|
|
162
|
+
// src/components/Flex/Flex.tsx
|
|
163
|
+
var import_components4 = require("@theme-ui/components");
|
|
164
|
+
|
|
165
|
+
// src/components/FormField/FormField.tsx
|
|
166
|
+
var React3 = __toESM(require("react"));
|
|
167
|
+
|
|
168
|
+
// src/components/Label/Label.tsx
|
|
169
|
+
var import_components5 = require("@theme-ui/components");
|
|
170
|
+
|
|
171
|
+
// src/components/Text/Text.tsx
|
|
172
|
+
var import_components6 = require("@theme-ui/components");
|
|
173
|
+
|
|
174
|
+
// src/components/FormField/FormField.tsx
|
|
175
|
+
var FormField = ({ children, label, error }) => {
|
|
176
|
+
const errorAsArray = (() => {
|
|
177
|
+
if (Array.isArray(error)) {
|
|
178
|
+
return error;
|
|
179
|
+
}
|
|
180
|
+
if (typeof error === "string") {
|
|
181
|
+
return [error];
|
|
182
|
+
}
|
|
183
|
+
return [];
|
|
184
|
+
})();
|
|
185
|
+
return /* @__PURE__ */ React3.createElement(import_components.Box, null, /* @__PURE__ */ React3.createElement(import_components5.Label, {
|
|
186
|
+
sx: { display: "flex", flexDirection: "column" }
|
|
187
|
+
}, label && /* @__PURE__ */ React3.createElement(import_components6.Text, {
|
|
188
|
+
as: "span"
|
|
189
|
+
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(import_components6.Text, {
|
|
190
|
+
key: err,
|
|
191
|
+
as: "span",
|
|
192
|
+
variant: "error"
|
|
193
|
+
}, err)));
|
|
194
|
+
};
|
|
195
|
+
var FormField_default = FormField;
|
|
196
|
+
|
|
197
|
+
// src/components/Image/Image.tsx
|
|
198
|
+
var import_components7 = require("@theme-ui/components");
|
|
199
|
+
|
|
200
|
+
// src/components/Input/Input.tsx
|
|
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;
|
|
209
|
+
module.exports = __toCommonJS(src_exports);
|
|
210
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
211
|
+
0 && (module.exports = {
|
|
212
|
+
Box,
|
|
213
|
+
Button,
|
|
214
|
+
Card,
|
|
215
|
+
Flex,
|
|
216
|
+
FormField,
|
|
217
|
+
Image,
|
|
218
|
+
Input,
|
|
219
|
+
LinearProgress,
|
|
220
|
+
Link,
|
|
221
|
+
Text,
|
|
222
|
+
ThemeProvider,
|
|
223
|
+
Themed,
|
|
224
|
+
color,
|
|
225
|
+
useTheme
|
|
226
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,15 +34,17 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@emotion/react": "^11",
|
|
36
36
|
"@emotion/styled": "^11",
|
|
37
|
+
"@theme-ui/color": "^0.13.1",
|
|
37
38
|
"@theme-ui/components": "^0.13.1",
|
|
38
|
-
"@theme-ui/core": "^0.13.1"
|
|
39
|
+
"@theme-ui/core": "^0.13.1",
|
|
40
|
+
"@theme-ui/mdx": "^0.13.1"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
41
|
-
"react": ">=
|
|
43
|
+
"react": ">=17.0.2"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@ttoss/config": "^
|
|
45
|
-
"@ttoss/test-utils": "^
|
|
46
|
+
"@ttoss/config": "^1.4.1",
|
|
47
|
+
"@ttoss/test-utils": "^1.4.1"
|
|
46
48
|
},
|
|
47
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "c5a8ea6093886fc6e500e22db72687e011cdb5bc"
|
|
48
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,
|
|
@@ -15,4 +19,9 @@ export {
|
|
|
15
19
|
} from './components/FormField/FormField';
|
|
16
20
|
export { default as Image, ImageProps } from './components/Image/Image';
|
|
17
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';
|
|
18
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
|
};
|