@ttoss/ui 1.20.1 → 1.20.3
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 +15 -8
- package/dist/index.js +19 -8
- package/package.json +11 -11
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,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
|
|
3
3
|
// tsup.inject.js
|
|
4
4
|
import * as React from "react";
|
|
@@ -96,6 +96,7 @@ var defaultTheme = {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
// src/theme/ThemeProvider.tsx
|
|
99
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
99
100
|
var ThemeProvider = ({
|
|
100
101
|
children,
|
|
101
102
|
theme = {},
|
|
@@ -107,14 +108,19 @@ var ThemeProvider = ({
|
|
|
107
108
|
}
|
|
108
109
|
return merge(defaultTheme, theme);
|
|
109
110
|
}, [theme]);
|
|
110
|
-
return /* @__PURE__ */
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
112
|
+
children: /* @__PURE__ */ jsxs(ThemeUiProvider, {
|
|
113
|
+
theme: mergedTheme,
|
|
114
|
+
children: [
|
|
115
|
+
fonts.map((url) => /* @__PURE__ */ jsx(Global, {
|
|
116
|
+
styles: css`
|
|
115
117
|
@import url('${url}');
|
|
116
118
|
`
|
|
117
|
-
|
|
119
|
+
}, url)),
|
|
120
|
+
children
|
|
121
|
+
]
|
|
122
|
+
})
|
|
123
|
+
});
|
|
118
124
|
};
|
|
119
125
|
var ThemeProvider_default = ThemeProvider;
|
|
120
126
|
|
|
@@ -127,8 +133,9 @@ import { Box } from "theme-ui";
|
|
|
127
133
|
|
|
128
134
|
// src/components/Button/Button.tsx
|
|
129
135
|
import { Button as ButtonUi } from "theme-ui";
|
|
136
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
130
137
|
var Button = (props) => {
|
|
131
|
-
return /* @__PURE__ */
|
|
138
|
+
return /* @__PURE__ */ jsx2(ButtonUi, {
|
|
132
139
|
...props,
|
|
133
140
|
sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
|
|
134
141
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
1
2
|
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -17,7 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
18
|
}
|
|
18
19
|
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
21
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
26
|
|
|
23
27
|
// src/index.ts
|
|
@@ -141,6 +145,7 @@ var defaultTheme = {
|
|
|
141
145
|
};
|
|
142
146
|
|
|
143
147
|
// src/theme/ThemeProvider.tsx
|
|
148
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
144
149
|
var ThemeProvider = ({
|
|
145
150
|
children,
|
|
146
151
|
theme = {},
|
|
@@ -152,14 +157,19 @@ var ThemeProvider = ({
|
|
|
152
157
|
}
|
|
153
158
|
return (0, import_theme_ui.merge)(defaultTheme, theme);
|
|
154
159
|
}, [theme]);
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
161
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_theme_ui.ThemeProvider, {
|
|
162
|
+
theme: mergedTheme,
|
|
163
|
+
children: [
|
|
164
|
+
fonts.map((url) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Global, {
|
|
165
|
+
styles: import_react.css`
|
|
160
166
|
@import url('${url}');
|
|
161
167
|
`
|
|
162
|
-
|
|
168
|
+
}, url)),
|
|
169
|
+
children
|
|
170
|
+
]
|
|
171
|
+
})
|
|
172
|
+
});
|
|
163
173
|
};
|
|
164
174
|
var ThemeProvider_default = ThemeProvider;
|
|
165
175
|
|
|
@@ -172,8 +182,9 @@ var import_theme_ui3 = require("theme-ui");
|
|
|
172
182
|
|
|
173
183
|
// src/components/Button/Button.tsx
|
|
174
184
|
var import_theme_ui4 = require("theme-ui");
|
|
185
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
175
186
|
var Button = (props) => {
|
|
176
|
-
return /* @__PURE__ */
|
|
187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_theme_ui4.Button, {
|
|
177
188
|
...props,
|
|
178
189
|
sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
|
|
179
190
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.3",
|
|
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": {
|
|
32
|
-
"@
|
|
33
|
-
"@ttoss/
|
|
34
|
-
"@
|
|
35
|
-
"jest": "^
|
|
36
|
-
"
|
|
31
|
+
"@emotion/react": "^11.10.4",
|
|
32
|
+
"@ttoss/config": "^1.18.2",
|
|
33
|
+
"@ttoss/test-utils": "^1.16.9",
|
|
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": "4548135614dd048140cece482703445cf436f39f"
|
|
47
47
|
}
|