@ttoss/ui 1.20.1 → 1.20.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/README.md +53 -35
- package/dist/esm/index.js +14 -9
- package/dist/index.js +18 -8
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,53 +1,71 @@
|
|
|
1
1
|
# @ttoss/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**@ttoss/ui** is a library of React low level components for building user interfaces and defining the design system of your application. It is built on top of [Theme UI: The Design Graph Framework](https://theme-ui.com/), so that you'll be able to consult the [Theme UI documentation](https://theme-ui.com/getting-started) to learn more about the design system and the components.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```shell
|
|
8
|
+
yarn add @ttoss/ui @emotion/react
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Quick start
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
Create a theme object to define the design tokens of your application.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import type { Theme } from '@ttoss/ui';
|
|
17
|
+
|
|
18
|
+
export const theme: Theme = {
|
|
19
|
+
colors: {
|
|
20
|
+
text: '#000',
|
|
21
|
+
background: '#fff',
|
|
22
|
+
primary: '#33e',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Pass your theme to the `ThemeProvider` component at the root of your application.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Heading, ThemeProvider } from '@ttoss/ui';
|
|
31
|
+
import { theme } from './theme';
|
|
32
|
+
|
|
33
|
+
export const App = () => (
|
|
34
|
+
<ThemeProvider theme={theme}>
|
|
35
|
+
<Heading as="h1" sx={{ color: 'primary' }}>
|
|
36
|
+
Hello
|
|
37
|
+
</Heading>
|
|
38
|
+
</ThemeProvider>
|
|
39
|
+
);
|
|
15
40
|
```
|
|
16
41
|
|
|
17
|
-
|
|
42
|
+
Now, you can use the components of the library in your application and access the [design tokens](/docs/design/design-tokens) defined in your theme through the [`sx` prop](https://theme-ui.com/getting-started#sx-prop).
|
|
18
43
|
|
|
19
44
|
```tsx
|
|
20
|
-
import { Flex, Text, Box, Button } from
|
|
45
|
+
import { Flex, Text, Box, Button } from '@ttoss/ui';
|
|
21
46
|
|
|
22
|
-
const
|
|
47
|
+
export const Component = () => {
|
|
23
48
|
return (
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</
|
|
33
|
-
</
|
|
49
|
+
<Flex sx={{ flexDirection: 'column' }}>
|
|
50
|
+
<Text>Text Value</Text>
|
|
51
|
+
<Button
|
|
52
|
+
sx={{
|
|
53
|
+
backgroundColor: 'primary',
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
Button Primary
|
|
57
|
+
</Button>
|
|
58
|
+
</Flex>
|
|
34
59
|
);
|
|
35
60
|
};
|
|
36
|
-
|
|
37
|
-
export default App;
|
|
38
61
|
```
|
|
39
62
|
|
|
40
|
-
|
|
63
|
+
:::note Note
|
|
41
64
|
|
|
42
|
-
You
|
|
65
|
+
You don't need to use the custom /\*\* @jsxImportSource theme-ui \*/ pragma if you use the `sx` prop directly on the components of the library.
|
|
43
66
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
]}
|
|
50
|
-
>
|
|
51
|
-
<App />
|
|
52
|
-
</ThemeProvider>
|
|
53
|
-
```
|
|
67
|
+
:::
|
|
68
|
+
|
|
69
|
+
## Components
|
|
70
|
+
|
|
71
|
+
You can check all the components of the library `@ttoss/ui` on the [Storybook](https://storybook.ttoss.dev/?path=/story/ui).
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
// tsup.inject.js
|
|
4
2
|
import * as React from "react";
|
|
5
3
|
|
|
@@ -96,6 +94,7 @@ var defaultTheme = {
|
|
|
96
94
|
};
|
|
97
95
|
|
|
98
96
|
// src/theme/ThemeProvider.tsx
|
|
97
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
99
98
|
var ThemeProvider = ({
|
|
100
99
|
children,
|
|
101
100
|
theme = {},
|
|
@@ -107,14 +106,19 @@ var ThemeProvider = ({
|
|
|
107
106
|
}
|
|
108
107
|
return merge(defaultTheme, theme);
|
|
109
108
|
}, [theme]);
|
|
110
|
-
return /* @__PURE__ */
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
110
|
+
children: /* @__PURE__ */ jsxs(ThemeUiProvider, {
|
|
111
|
+
theme: mergedTheme,
|
|
112
|
+
children: [
|
|
113
|
+
fonts.map((url) => /* @__PURE__ */ jsx(Global, {
|
|
114
|
+
styles: css`
|
|
115
115
|
@import url('${url}');
|
|
116
116
|
`
|
|
117
|
-
|
|
117
|
+
}, url)),
|
|
118
|
+
children
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
});
|
|
118
122
|
};
|
|
119
123
|
var ThemeProvider_default = ThemeProvider;
|
|
120
124
|
|
|
@@ -127,8 +131,9 @@ import { Box } from "theme-ui";
|
|
|
127
131
|
|
|
128
132
|
// src/components/Button/Button.tsx
|
|
129
133
|
import { Button as ButtonUi } from "theme-ui";
|
|
134
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
130
135
|
var Button = (props) => {
|
|
131
|
-
return /* @__PURE__ */
|
|
136
|
+
return /* @__PURE__ */ jsx2(ButtonUi, {
|
|
132
137
|
...props,
|
|
133
138
|
sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
|
|
134
139
|
});
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
|
|
23
26
|
// src/index.ts
|
|
@@ -141,6 +144,7 @@ var defaultTheme = {
|
|
|
141
144
|
};
|
|
142
145
|
|
|
143
146
|
// src/theme/ThemeProvider.tsx
|
|
147
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
144
148
|
var ThemeProvider = ({
|
|
145
149
|
children,
|
|
146
150
|
theme = {},
|
|
@@ -152,14 +156,19 @@ var ThemeProvider = ({
|
|
|
152
156
|
}
|
|
153
157
|
return (0, import_theme_ui.merge)(defaultTheme, theme);
|
|
154
158
|
}, [theme]);
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_theme_ui.ThemeProvider, {
|
|
161
|
+
theme: mergedTheme,
|
|
162
|
+
children: [
|
|
163
|
+
fonts.map((url) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Global, {
|
|
164
|
+
styles: import_react.css`
|
|
160
165
|
@import url('${url}');
|
|
161
166
|
`
|
|
162
|
-
|
|
167
|
+
}, url)),
|
|
168
|
+
children
|
|
169
|
+
]
|
|
170
|
+
})
|
|
171
|
+
});
|
|
163
172
|
};
|
|
164
173
|
var ThemeProvider_default = ThemeProvider;
|
|
165
174
|
|
|
@@ -172,8 +181,9 @@ var import_theme_ui3 = require("theme-ui");
|
|
|
172
181
|
|
|
173
182
|
// src/components/Button/Button.tsx
|
|
174
183
|
var import_theme_ui4 = require("theme-ui");
|
|
184
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
175
185
|
var Button = (props) => {
|
|
176
|
-
return /* @__PURE__ */
|
|
186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_theme_ui4.Button, {
|
|
177
187
|
...props,
|
|
178
188
|
sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
|
|
179
189
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
},
|
|
21
21
|
"typings": "dist/index.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"@theme-ui/match-media": "^0.14.3",
|
|
26
|
-
"theme-ui": "^0.14.6"
|
|
23
|
+
"@theme-ui/match-media": "^0.15.1",
|
|
24
|
+
"theme-ui": "^0.15.1"
|
|
27
25
|
},
|
|
28
26
|
"peerDependencies": {
|
|
27
|
+
"@emotion/react": "^11",
|
|
29
28
|
"react": ">=18.0.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
31
|
+
"@emotion/react": "^11.10.4",
|
|
32
32
|
"@ttoss/config": "^1.18.1",
|
|
33
33
|
"@ttoss/test-utils": "^1.16.8",
|
|
34
|
-
"@types/jest": "^
|
|
35
|
-
"jest": "^
|
|
36
|
-
"tsup": "^6.
|
|
34
|
+
"@types/jest": "^29.1.1",
|
|
35
|
+
"jest": "^29.1.2",
|
|
36
|
+
"tsup": "^6.2.3"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"React",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "0759c1ec512f6cb0a613c209beba1fcf6af7e232"
|
|
47
47
|
}
|