@ttoss/ui 1.21.0 → 1.21.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 +12 -14
- package/dist/index.js +12 -14
- package/package.json +3 -2
- package/src/theme/ThemeProvider.spec.tsx +2 -2
- package/src/theme/ThemeProvider.tsx +3 -4
- package/src/theme/defaultFonts.ts +0 -6
- package/src/theme/defaultTheme.ts +0 -76
package/dist/esm/index.js
CHANGED
|
@@ -8,19 +8,9 @@ import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
|
|
|
8
8
|
|
|
9
9
|
// src/theme/ThemeProvider.tsx
|
|
10
10
|
import * as React2 from "react";
|
|
11
|
-
import { Global, css } from "@emotion/react";
|
|
12
|
-
import { ThemeProvider as ThemeUiProvider, merge } from "theme-ui";
|
|
13
|
-
|
|
14
|
-
// src/theme/defaultFonts.ts
|
|
15
|
-
var defaultFonts = [
|
|
16
|
-
"https://fonts.googleapis.com/css?family=Asap",
|
|
17
|
-
"https://fonts.googleapis.com/css?family=Overpass",
|
|
18
|
-
"https://fonts.googleapis.com/css?family=Overpass+Mono",
|
|
19
|
-
"https://fonts.googleapis.com/css?family=Flamenco"
|
|
20
|
-
];
|
|
21
11
|
|
|
22
|
-
//
|
|
23
|
-
var
|
|
12
|
+
// ../theme/dist/esm/index.js
|
|
13
|
+
var DefaultTheme = {
|
|
24
14
|
colors: {
|
|
25
15
|
text: "#000",
|
|
26
16
|
background: "#fff",
|
|
@@ -94,19 +84,27 @@ var defaultTheme = {
|
|
|
94
84
|
}
|
|
95
85
|
}
|
|
96
86
|
};
|
|
87
|
+
var DefaultFonts = [
|
|
88
|
+
"https://fonts.googleapis.com/css?family=Asap",
|
|
89
|
+
"https://fonts.googleapis.com/css?family=Overpass",
|
|
90
|
+
"https://fonts.googleapis.com/css?family=Overpass+Mono",
|
|
91
|
+
"https://fonts.googleapis.com/css?family=Flamenco"
|
|
92
|
+
];
|
|
97
93
|
|
|
98
94
|
// src/theme/ThemeProvider.tsx
|
|
95
|
+
import { Global, css } from "@emotion/react";
|
|
96
|
+
import { ThemeProvider as ThemeUiProvider, merge } from "theme-ui";
|
|
99
97
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
100
98
|
var ThemeProvider = ({
|
|
101
99
|
children,
|
|
102
100
|
theme = {},
|
|
103
|
-
fonts =
|
|
101
|
+
fonts = DefaultFonts
|
|
104
102
|
}) => {
|
|
105
103
|
const mergedTheme = React2.useMemo(() => {
|
|
106
104
|
if (typeof theme === "function") {
|
|
107
105
|
return theme;
|
|
108
106
|
}
|
|
109
|
-
return merge(
|
|
107
|
+
return merge(DefaultTheme, theme);
|
|
110
108
|
}, [theme]);
|
|
111
109
|
return /* @__PURE__ */ jsx(Fragment, {
|
|
112
110
|
children: /* @__PURE__ */ jsxs(ThemeUiProvider, {
|
package/dist/index.js
CHANGED
|
@@ -58,19 +58,9 @@ var import_match_media = require("@theme-ui/match-media");
|
|
|
58
58
|
|
|
59
59
|
// src/theme/ThemeProvider.tsx
|
|
60
60
|
var React2 = __toESM(require("react"));
|
|
61
|
-
var import_react = require("@emotion/react");
|
|
62
|
-
var import_theme_ui = require("theme-ui");
|
|
63
|
-
|
|
64
|
-
// src/theme/defaultFonts.ts
|
|
65
|
-
var defaultFonts = [
|
|
66
|
-
"https://fonts.googleapis.com/css?family=Asap",
|
|
67
|
-
"https://fonts.googleapis.com/css?family=Overpass",
|
|
68
|
-
"https://fonts.googleapis.com/css?family=Overpass+Mono",
|
|
69
|
-
"https://fonts.googleapis.com/css?family=Flamenco"
|
|
70
|
-
];
|
|
71
61
|
|
|
72
|
-
//
|
|
73
|
-
var
|
|
62
|
+
// ../theme/dist/esm/index.js
|
|
63
|
+
var DefaultTheme = {
|
|
74
64
|
colors: {
|
|
75
65
|
text: "#000",
|
|
76
66
|
background: "#fff",
|
|
@@ -144,19 +134,27 @@ var defaultTheme = {
|
|
|
144
134
|
}
|
|
145
135
|
}
|
|
146
136
|
};
|
|
137
|
+
var DefaultFonts = [
|
|
138
|
+
"https://fonts.googleapis.com/css?family=Asap",
|
|
139
|
+
"https://fonts.googleapis.com/css?family=Overpass",
|
|
140
|
+
"https://fonts.googleapis.com/css?family=Overpass+Mono",
|
|
141
|
+
"https://fonts.googleapis.com/css?family=Flamenco"
|
|
142
|
+
];
|
|
147
143
|
|
|
148
144
|
// src/theme/ThemeProvider.tsx
|
|
145
|
+
var import_react = require("@emotion/react");
|
|
146
|
+
var import_theme_ui = require("theme-ui");
|
|
149
147
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
150
148
|
var ThemeProvider = ({
|
|
151
149
|
children,
|
|
152
150
|
theme = {},
|
|
153
|
-
fonts =
|
|
151
|
+
fonts = DefaultFonts
|
|
154
152
|
}) => {
|
|
155
153
|
const mergedTheme = React2.useMemo(() => {
|
|
156
154
|
if (typeof theme === "function") {
|
|
157
155
|
return theme;
|
|
158
156
|
}
|
|
159
|
-
return (0, import_theme_ui.merge)(
|
|
157
|
+
return (0, import_theme_ui.merge)(DefaultTheme, theme);
|
|
160
158
|
}, [theme]);
|
|
161
159
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
162
160
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_theme_ui.ThemeProvider, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@emotion/react": "^11.10.4",
|
|
32
32
|
"@ttoss/config": "^1.18.3",
|
|
33
33
|
"@ttoss/test-utils": "^1.16.10",
|
|
34
|
+
"@ttoss/theme": "^1.0.1",
|
|
34
35
|
"@types/jest": "^29.1.1",
|
|
35
36
|
"jest": "^29.1.2",
|
|
36
37
|
"tsup": "^6.2.3"
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"publishConfig": {
|
|
44
45
|
"access": "public"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "3879642eff43efd073abf52595ed0efe7196946a"
|
|
47
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DefaultTheme } from '@ttoss/theme';
|
|
2
2
|
import { renderHook } from '@ttoss/test-utils';
|
|
3
3
|
import { useTheme } from './useTheme';
|
|
4
4
|
import ThemeProvider from './ThemeProvider';
|
|
@@ -9,7 +9,7 @@ test('should return default theme colors', () => {
|
|
|
9
9
|
initialProps: { theme: {} },
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
expect(result.current.theme.rawColors).toEqual(
|
|
12
|
+
expect(result.current.theme.rawColors).toEqual(DefaultTheme.colors);
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
test('should return new theme colors', () => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { DefaultFonts, DefaultTheme } from '@ttoss/theme';
|
|
2
3
|
import { Global, css } from '@emotion/react';
|
|
3
4
|
import { Theme, ThemeProvider as ThemeUiProvider, merge } from 'theme-ui';
|
|
4
|
-
import { defaultFonts } from './defaultFonts';
|
|
5
|
-
import { defaultTheme } from './defaultTheme';
|
|
6
5
|
|
|
7
6
|
export type ThemeProviderProps = {
|
|
8
7
|
children?: React.ReactNode;
|
|
@@ -16,14 +15,14 @@ export type ThemeProviderProps = {
|
|
|
16
15
|
const ThemeProvider = ({
|
|
17
16
|
children,
|
|
18
17
|
theme = {},
|
|
19
|
-
fonts =
|
|
18
|
+
fonts = DefaultFonts,
|
|
20
19
|
}: ThemeProviderProps) => {
|
|
21
20
|
const mergedTheme = React.useMemo(() => {
|
|
22
21
|
if (typeof theme === 'function') {
|
|
23
22
|
return theme;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
return merge(
|
|
25
|
+
return merge(DefaultTheme, theme);
|
|
27
26
|
}, [theme]);
|
|
28
27
|
|
|
29
28
|
return (
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Theme } from 'theme-ui';
|
|
2
|
-
|
|
3
|
-
export const defaultTheme: Theme = {
|
|
4
|
-
colors: {
|
|
5
|
-
text: '#000',
|
|
6
|
-
background: '#fff',
|
|
7
|
-
primary: '#07c',
|
|
8
|
-
secondary: '#639',
|
|
9
|
-
gray: '#555',
|
|
10
|
-
muted: '#f6f6f6',
|
|
11
|
-
danger: 'red',
|
|
12
|
-
},
|
|
13
|
-
space: [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
|
|
14
|
-
fonts: {
|
|
15
|
-
body: '"Asap", sans-serif',
|
|
16
|
-
heading: '"Overpass", sans-serif',
|
|
17
|
-
monospace: '"Overpass Mono", sans-serif',
|
|
18
|
-
},
|
|
19
|
-
styles: {
|
|
20
|
-
root: {
|
|
21
|
-
fontFamily: 'body',
|
|
22
|
-
fontWeight: 'body',
|
|
23
|
-
},
|
|
24
|
-
a: {
|
|
25
|
-
color: 'primary',
|
|
26
|
-
textDecoration: 'underline',
|
|
27
|
-
cursor: 'pointer',
|
|
28
|
-
fontFamily: 'body',
|
|
29
|
-
},
|
|
30
|
-
progress: {
|
|
31
|
-
color: 'primary',
|
|
32
|
-
backgroundColor: 'background',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
buttons: {
|
|
36
|
-
cta: {
|
|
37
|
-
color: 'white',
|
|
38
|
-
backgroundColor: 'primary',
|
|
39
|
-
},
|
|
40
|
-
muted: {
|
|
41
|
-
color: 'text',
|
|
42
|
-
backgroundColor: 'muted',
|
|
43
|
-
},
|
|
44
|
-
danger: {
|
|
45
|
-
color: 'white',
|
|
46
|
-
backgroundColor: 'danger',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
cards: {
|
|
50
|
-
primary: {
|
|
51
|
-
backgroundColor: 'background',
|
|
52
|
-
border: '1px solid black',
|
|
53
|
-
padding: [4, 5],
|
|
54
|
-
display: 'flex',
|
|
55
|
-
flexDirection: 'column',
|
|
56
|
-
alignItems: 'center',
|
|
57
|
-
width: 'fit-content',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
forms: {
|
|
61
|
-
input: {
|
|
62
|
-
fontFamily: 'body',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
text: {
|
|
66
|
-
default: {
|
|
67
|
-
color: 'text',
|
|
68
|
-
fontFamily: 'body',
|
|
69
|
-
},
|
|
70
|
-
title: {
|
|
71
|
-
fontFamily: 'heading',
|
|
72
|
-
fontSize: 4,
|
|
73
|
-
lineSpace: '3.5',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
};
|