@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 CHANGED
@@ -1,53 +1,71 @@
1
1
  # @ttoss/ui
2
2
 
3
- ## 📚 About
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
- <strong> @ttoss/ui</strong> is a easiest way to use Ui components in your React application.
5
+ ## Installation
6
6
 
7
- ## 🚀 Getting Started
7
+ ```shell
8
+ yarn add @ttoss/ui @emotion/react
9
+ ```
8
10
 
9
- ### Install @ttoss/ui
11
+ ## Quick start
10
12
 
11
- ```shell
12
- $ yarn add @ttoss/ui
13
- # or
14
- $ npm install @ttoss/ui
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
- ## 📄 Examples of use
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 "@ttoss/ui";
45
+ import { Flex, Text, Box, Button } from '@ttoss/ui';
21
46
 
22
- const App = () => {
47
+ export const Component = () => {
23
48
  return (
24
- <ThemeProvider>
25
- <Flex sx={{ flexDirection: "column" }}>
26
- <Text>Text Value</Text>
27
- <Box>
28
- <Text>Text Value</Text>
29
-
30
- <Button>Button Primary</Button>
31
- </Box>
32
- </Flex>
33
- </ThemeProvider>
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
- ### Loading Fonts
63
+ :::note Note
41
64
 
42
- You can pass fonts URLs to `ThemeProvider` component thought `fonts` prop.
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
- ```tsx
45
- <ThemeProvider
46
- fonts={[
47
- "https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap",
48
- "https://fonts.googleapis.com/css?family=Roboto+Mono&display=swap",
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__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ThemeUiProvider, {
111
- theme: mergedTheme
112
- }, fonts.map((url) => /* @__PURE__ */ React2.createElement(Global, {
113
- key: url,
114
- styles: css`
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
- })), children));
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__ */ React.createElement(ButtonUi, {
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(import_theme_ui.ThemeProvider, {
156
- theme: mergedTheme
157
- }, fonts.map((url) => /* @__PURE__ */ React2.createElement(import_react.Global, {
158
- key: url,
159
- styles: import_react.css`
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
- })), children));
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__ */ React.createElement(import_theme_ui4.Button, {
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.1",
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
- "@emotion/react": "^11",
24
- "@mdx-js/react": "^1",
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": "^28.1.3",
35
- "jest": "^28.1.1",
36
- "tsup": "^6.1.2"
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": "5624791e118681b8ecbe2372bbc61806442df71b"
46
+ "gitHead": "0759c1ec512f6cb0a613c209beba1fcf6af7e232"
47
47
  }