@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 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,4 +1,4 @@
1
- "use strict";
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__ */ 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`
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
- })), children));
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__ */ React.createElement(ButtonUi, {
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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__ */ 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`
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
- })), children));
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__ */ React.createElement(import_theme_ui4.Button, {
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.1",
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
- "@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": {
32
- "@ttoss/config": "^1.18.1",
33
- "@ttoss/test-utils": "^1.16.8",
34
- "@types/jest": "^28.1.3",
35
- "jest": "^28.1.1",
36
- "tsup": "^6.1.2"
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": "5624791e118681b8ecbe2372bbc61806442df71b"
46
+ "gitHead": "4548135614dd048140cece482703445cf436f39f"
47
47
  }