@ttoss/ui 1.21.0 → 1.21.2
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 +25 -14
- package/dist/index.d.ts +9 -2
- package/dist/index.js +26 -14
- package/package.json +4 -2
- package/src/components/Icon/Icon.tsx +15 -0
- package/src/index.ts +1 -0
- 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, {
|
|
@@ -184,6 +182,18 @@ import { Spinner } from "theme-ui";
|
|
|
184
182
|
|
|
185
183
|
// src/components/Radio/Radio.tsx
|
|
186
184
|
import { Radio } from "theme-ui";
|
|
185
|
+
|
|
186
|
+
// src/components/Icon/Icon.tsx
|
|
187
|
+
import { Icon as IconUI } from "@iconify/react";
|
|
188
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
189
|
+
var Icon = ({ icon, sx }) => {
|
|
190
|
+
return /* @__PURE__ */ jsx3(Text, {
|
|
191
|
+
sx,
|
|
192
|
+
children: /* @__PURE__ */ jsx3(IconUI, {
|
|
193
|
+
icon
|
|
194
|
+
})
|
|
195
|
+
});
|
|
196
|
+
};
|
|
187
197
|
export {
|
|
188
198
|
Box,
|
|
189
199
|
Button,
|
|
@@ -192,6 +202,7 @@ export {
|
|
|
192
202
|
Flex,
|
|
193
203
|
Grid,
|
|
194
204
|
Heading,
|
|
205
|
+
Icon,
|
|
195
206
|
Image,
|
|
196
207
|
Input,
|
|
197
208
|
Label,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as theme_ui from 'theme-ui';
|
|
2
|
-
import { Theme, ButtonProps } from 'theme-ui';
|
|
2
|
+
import { Theme, ButtonProps, TextProps } from 'theme-ui';
|
|
3
3
|
export { Box, BoxProps, ButtonProps, Card, CardProps, Divider, DividerProps, Flex, FlexProps, Grid, GridProps, Heading, HeadingProps, Image, ImageProps, Input, InputProps, Label, LabelProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Link, LinkProps, Radio, RadioProps, Select, SelectProps, Spinner, SpinnerProps, Text, TextProps, Theme } from 'theme-ui';
|
|
4
4
|
export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
+
import { IconProps as IconProps$1 } from '@iconify/react';
|
|
6
7
|
|
|
7
8
|
declare type ThemeProviderProps = {
|
|
8
9
|
children?: React.ReactNode;
|
|
@@ -18,4 +19,10 @@ declare const useTheme: () => theme_ui.ThemeUIContextValue;
|
|
|
18
19
|
|
|
19
20
|
declare const Button: (props: ButtonProps) => JSX.Element;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
declare type IconProps = {
|
|
23
|
+
icon: IconProps$1['icon'];
|
|
24
|
+
sx?: TextProps['sx'];
|
|
25
|
+
};
|
|
26
|
+
declare const Icon: ({ icon, sx }: IconProps) => JSX.Element;
|
|
27
|
+
|
|
28
|
+
export { Button, Icon, IconProps, ThemeProvider, ThemeProviderProps, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
Flex: () => import_theme_ui7.Flex,
|
|
35
35
|
Grid: () => import_theme_ui8.Grid,
|
|
36
36
|
Heading: () => import_theme_ui9.Heading,
|
|
37
|
+
Icon: () => Icon,
|
|
37
38
|
Image: () => import_theme_ui10.Image,
|
|
38
39
|
Input: () => import_theme_ui11.Input,
|
|
39
40
|
Label: () => import_theme_ui12.Label,
|
|
@@ -58,19 +59,9 @@ var import_match_media = require("@theme-ui/match-media");
|
|
|
58
59
|
|
|
59
60
|
// src/theme/ThemeProvider.tsx
|
|
60
61
|
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
62
|
|
|
72
|
-
//
|
|
73
|
-
var
|
|
63
|
+
// ../theme/dist/esm/index.js
|
|
64
|
+
var DefaultTheme = {
|
|
74
65
|
colors: {
|
|
75
66
|
text: "#000",
|
|
76
67
|
background: "#fff",
|
|
@@ -144,19 +135,27 @@ var defaultTheme = {
|
|
|
144
135
|
}
|
|
145
136
|
}
|
|
146
137
|
};
|
|
138
|
+
var DefaultFonts = [
|
|
139
|
+
"https://fonts.googleapis.com/css?family=Asap",
|
|
140
|
+
"https://fonts.googleapis.com/css?family=Overpass",
|
|
141
|
+
"https://fonts.googleapis.com/css?family=Overpass+Mono",
|
|
142
|
+
"https://fonts.googleapis.com/css?family=Flamenco"
|
|
143
|
+
];
|
|
147
144
|
|
|
148
145
|
// src/theme/ThemeProvider.tsx
|
|
146
|
+
var import_react = require("@emotion/react");
|
|
147
|
+
var import_theme_ui = require("theme-ui");
|
|
149
148
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
150
149
|
var ThemeProvider = ({
|
|
151
150
|
children,
|
|
152
151
|
theme = {},
|
|
153
|
-
fonts =
|
|
152
|
+
fonts = DefaultFonts
|
|
154
153
|
}) => {
|
|
155
154
|
const mergedTheme = React2.useMemo(() => {
|
|
156
155
|
if (typeof theme === "function") {
|
|
157
156
|
return theme;
|
|
158
157
|
}
|
|
159
|
-
return (0, import_theme_ui.merge)(
|
|
158
|
+
return (0, import_theme_ui.merge)(DefaultTheme, theme);
|
|
160
159
|
}, [theme]);
|
|
161
160
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
162
161
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_theme_ui.ThemeProvider, {
|
|
@@ -232,6 +231,18 @@ var import_theme_ui17 = require("theme-ui");
|
|
|
232
231
|
|
|
233
232
|
// src/components/Radio/Radio.tsx
|
|
234
233
|
var import_theme_ui18 = require("theme-ui");
|
|
234
|
+
|
|
235
|
+
// src/components/Icon/Icon.tsx
|
|
236
|
+
var import_react2 = require("@iconify/react");
|
|
237
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
238
|
+
var Icon = ({ icon, sx }) => {
|
|
239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_theme_ui15.Text, {
|
|
240
|
+
sx,
|
|
241
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.Icon, {
|
|
242
|
+
icon
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
};
|
|
235
246
|
// Annotate the CommonJS export names for ESM import in node:
|
|
236
247
|
0 && (module.exports = {
|
|
237
248
|
Box,
|
|
@@ -241,6 +252,7 @@ var import_theme_ui18 = require("theme-ui");
|
|
|
241
252
|
Flex,
|
|
242
253
|
Grid,
|
|
243
254
|
Heading,
|
|
255
|
+
Icon,
|
|
244
256
|
Image,
|
|
245
257
|
Input,
|
|
246
258
|
Label,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"typings": "dist/index.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@iconify/react": "^4.0.0",
|
|
23
24
|
"@theme-ui/match-media": "^0.15.1",
|
|
24
25
|
"theme-ui": "^0.15.1"
|
|
25
26
|
},
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"@emotion/react": "^11.10.4",
|
|
32
33
|
"@ttoss/config": "^1.18.3",
|
|
33
34
|
"@ttoss/test-utils": "^1.16.10",
|
|
35
|
+
"@ttoss/theme": "^1.0.2",
|
|
34
36
|
"@types/jest": "^29.1.1",
|
|
35
37
|
"jest": "^29.1.2",
|
|
36
38
|
"tsup": "^6.2.3"
|
|
@@ -43,5 +45,5 @@
|
|
|
43
45
|
"publishConfig": {
|
|
44
46
|
"access": "public"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "b939e6a717618f4cc06605df922e37f89b877561"
|
|
47
49
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconProps as IconPropsUI, Icon as IconUI } from '@iconify/react';
|
|
2
|
+
import { Text, TextProps } from '../Text/Text';
|
|
3
|
+
|
|
4
|
+
export type IconProps = {
|
|
5
|
+
icon: IconPropsUI['icon'];
|
|
6
|
+
sx?: TextProps['sx'];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Icon = ({ icon, sx }: IconProps) => {
|
|
10
|
+
return (
|
|
11
|
+
<Text sx={sx}>
|
|
12
|
+
<IconUI icon={icon} />
|
|
13
|
+
</Text>
|
|
14
|
+
);
|
|
15
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -27,3 +27,4 @@ export { Text, type TextProps } from './components/Text/Text';
|
|
|
27
27
|
export { Select, type SelectProps } from './components/Select/Select';
|
|
28
28
|
export { Spinner, type SpinnerProps } from './components/Spinner/Spinner';
|
|
29
29
|
export { Radio, type RadioProps } from './components/Radio/Radio';
|
|
30
|
+
export { Icon, type IconProps } from './components/Icon/Icon';
|
|
@@ -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
|
-
};
|