@ttoss/ui 1.8.2 → 1.9.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 CHANGED
@@ -23,6 +23,7 @@ import * as React from "react";
23
23
 
24
24
  // src/index.ts
25
25
  import * as color from "@theme-ui/color";
26
+ import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
26
27
  import { Themed } from "@theme-ui/mdx";
27
28
 
28
29
  // src/theme/ThemeProvider.tsx
@@ -30,6 +31,14 @@ import { Global, css } from "@emotion/react";
30
31
  import { ThemeProvider as ThemeUiProvider, merge } from "@theme-ui/core";
31
32
  import * as React2 from "react";
32
33
 
34
+ // src/theme/defaultFonts.ts
35
+ var defaultFonts = [
36
+ "https://fonts.googleapis.com/css?family=Asap",
37
+ "https://fonts.googleapis.com/css?family=Overpass",
38
+ "https://fonts.googleapis.com/css?family=Overpass+Mono",
39
+ "https://fonts.googleapis.com/css?family=Flamenco"
40
+ ];
41
+
33
42
  // src/theme/defaultTheme.ts
34
43
  var defaultTheme = {
35
44
  colors: {
@@ -37,14 +46,26 @@ var defaultTheme = {
37
46
  background: "#fff",
38
47
  primary: "#07c",
39
48
  secondary: "#639",
40
- gray: "#555"
49
+ gray: "#555",
50
+ muted: "#f6f6f6",
51
+ danger: "red"
52
+ },
53
+ space: [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
54
+ fonts: {
55
+ body: '"Asap", sans-serif',
56
+ heading: '"Overpass", sans-serif',
57
+ monospace: '"Overpass Mono", sans-serif'
41
58
  },
42
- space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
43
59
  styles: {
60
+ root: {
61
+ fontFamily: "body",
62
+ fontWeight: "body"
63
+ },
44
64
  a: {
45
65
  color: "primary",
46
66
  textDecoration: "underline",
47
- cursor: "pointer"
67
+ cursor: "pointer",
68
+ fontFamily: "body"
48
69
  },
49
70
  progress: {
50
71
  color: "primary",
@@ -52,26 +73,44 @@ var defaultTheme = {
52
73
  }
53
74
  },
54
75
  buttons: {
55
- primary: {
76
+ cta: {
56
77
  color: "white",
57
78
  backgroundColor: "primary"
58
79
  },
59
- secondary: {
80
+ muted: {
81
+ color: "text",
82
+ backgroundColor: "muted"
83
+ },
84
+ danger: {
60
85
  color: "white",
61
- backgroundColor: "secondary"
86
+ backgroundColor: "danger"
62
87
  }
63
88
  },
64
89
  cards: {
65
90
  primary: {
66
91
  backgroundColor: "background",
67
92
  border: "1px solid black",
68
- padding: [4, 5]
93
+ padding: [4, 5],
94
+ display: "flex",
95
+ flexDirection: "column",
96
+ alignItems: "center",
97
+ width: "fit-content"
98
+ }
99
+ },
100
+ forms: {
101
+ input: {
102
+ fontFamily: "body"
69
103
  }
70
104
  },
71
105
  text: {
106
+ default: {
107
+ color: "text",
108
+ fontFamily: "body"
109
+ },
72
110
  title: {
73
- fontSize: [4, 5],
74
- textAlign: "center"
111
+ fontFamily: "heading",
112
+ fontSize: 4,
113
+ lineSpace: "3.5"
75
114
  }
76
115
  }
77
116
  };
@@ -80,7 +119,7 @@ var defaultTheme = {
80
119
  var ThemeProvider = ({
81
120
  children,
82
121
  theme = {},
83
- fonts = []
122
+ fonts = defaultFonts
84
123
  }) => {
85
124
  const mergedTheme = React2.useMemo(() => {
86
125
  if (typeof theme === "function") {
@@ -116,7 +155,7 @@ import { Box } from "@theme-ui/components";
116
155
  import { Button as ButtonUi } from "@theme-ui/components";
117
156
  var Button = (props) => {
118
157
  return /* @__PURE__ */ React.createElement(ButtonUi, __spreadProps(__spreadValues({}, props), {
119
- sx: __spreadValues({ cursor: "pointer", padding: 2 }, props.sx)
158
+ sx: __spreadValues({ cursor: "pointer", fontFamily: "body" }, props.sx)
120
159
  }));
121
160
  };
122
161
  var Button_default = Button;
@@ -185,5 +224,7 @@ export {
185
224
  ThemeProvider_default as ThemeProvider,
186
225
  Themed,
187
226
  color,
227
+ useBreakpointIndex,
228
+ useResponsiveValue,
188
229
  useTheme
189
230
  };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { color };
3
3
  import * as _theme_ui_core from '@theme-ui/core';
4
4
  import { Theme } from '@theme-ui/core';
5
5
  export { Theme } from '@theme-ui/core';
6
+ export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
6
7
  export { Themed } from '@theme-ui/mdx';
7
8
  import * as React from 'react';
8
9
  import * as _theme_ui_components from '@theme-ui/components';
package/dist/index.js CHANGED
@@ -59,6 +59,8 @@ __export(src_exports, {
59
59
  ThemeProvider: () => ThemeProvider_default,
60
60
  Themed: () => import_mdx.Themed,
61
61
  color: () => color,
62
+ useBreakpointIndex: () => import_match_media.useBreakpointIndex,
63
+ useResponsiveValue: () => import_match_media.useResponsiveValue,
62
64
  useTheme: () => useTheme
63
65
  });
64
66
 
@@ -67,6 +69,7 @@ var React = __toESM(require("react"));
67
69
 
68
70
  // src/index.ts
69
71
  var color = __toESM(require("@theme-ui/color"));
72
+ var import_match_media = require("@theme-ui/match-media");
70
73
  var import_mdx = require("@theme-ui/mdx");
71
74
 
72
75
  // src/theme/ThemeProvider.tsx
@@ -74,6 +77,14 @@ var import_react = require("@emotion/react");
74
77
  var import_core = require("@theme-ui/core");
75
78
  var React2 = __toESM(require("react"));
76
79
 
80
+ // src/theme/defaultFonts.ts
81
+ var defaultFonts = [
82
+ "https://fonts.googleapis.com/css?family=Asap",
83
+ "https://fonts.googleapis.com/css?family=Overpass",
84
+ "https://fonts.googleapis.com/css?family=Overpass+Mono",
85
+ "https://fonts.googleapis.com/css?family=Flamenco"
86
+ ];
87
+
77
88
  // src/theme/defaultTheme.ts
78
89
  var defaultTheme = {
79
90
  colors: {
@@ -81,14 +92,26 @@ var defaultTheme = {
81
92
  background: "#fff",
82
93
  primary: "#07c",
83
94
  secondary: "#639",
84
- gray: "#555"
95
+ gray: "#555",
96
+ muted: "#f6f6f6",
97
+ danger: "red"
98
+ },
99
+ space: [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
100
+ fonts: {
101
+ body: '"Asap", sans-serif',
102
+ heading: '"Overpass", sans-serif',
103
+ monospace: '"Overpass Mono", sans-serif'
85
104
  },
86
- space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
87
105
  styles: {
106
+ root: {
107
+ fontFamily: "body",
108
+ fontWeight: "body"
109
+ },
88
110
  a: {
89
111
  color: "primary",
90
112
  textDecoration: "underline",
91
- cursor: "pointer"
113
+ cursor: "pointer",
114
+ fontFamily: "body"
92
115
  },
93
116
  progress: {
94
117
  color: "primary",
@@ -96,26 +119,44 @@ var defaultTheme = {
96
119
  }
97
120
  },
98
121
  buttons: {
99
- primary: {
122
+ cta: {
100
123
  color: "white",
101
124
  backgroundColor: "primary"
102
125
  },
103
- secondary: {
126
+ muted: {
127
+ color: "text",
128
+ backgroundColor: "muted"
129
+ },
130
+ danger: {
104
131
  color: "white",
105
- backgroundColor: "secondary"
132
+ backgroundColor: "danger"
106
133
  }
107
134
  },
108
135
  cards: {
109
136
  primary: {
110
137
  backgroundColor: "background",
111
138
  border: "1px solid black",
112
- padding: [4, 5]
139
+ padding: [4, 5],
140
+ display: "flex",
141
+ flexDirection: "column",
142
+ alignItems: "center",
143
+ width: "fit-content"
144
+ }
145
+ },
146
+ forms: {
147
+ input: {
148
+ fontFamily: "body"
113
149
  }
114
150
  },
115
151
  text: {
152
+ default: {
153
+ color: "text",
154
+ fontFamily: "body"
155
+ },
116
156
  title: {
117
- fontSize: [4, 5],
118
- textAlign: "center"
157
+ fontFamily: "heading",
158
+ fontSize: 4,
159
+ lineSpace: "3.5"
119
160
  }
120
161
  }
121
162
  };
@@ -124,7 +165,7 @@ var defaultTheme = {
124
165
  var ThemeProvider = ({
125
166
  children,
126
167
  theme = {},
127
- fonts = []
168
+ fonts = defaultFonts
128
169
  }) => {
129
170
  const mergedTheme = React2.useMemo(() => {
130
171
  if (typeof theme === "function") {
@@ -160,7 +201,7 @@ var import_components = require("@theme-ui/components");
160
201
  var import_components2 = require("@theme-ui/components");
161
202
  var Button = (props) => {
162
203
  return /* @__PURE__ */ React.createElement(import_components2.Button, __spreadProps(__spreadValues({}, props), {
163
- sx: __spreadValues({ cursor: "pointer", padding: 2 }, props.sx)
204
+ sx: __spreadValues({ cursor: "pointer", fontFamily: "body" }, props.sx)
164
205
  }));
165
206
  };
166
207
  var Button_default = Button;
@@ -231,5 +272,7 @@ module.exports = __toCommonJS(src_exports);
231
272
  ThemeProvider,
232
273
  Themed,
233
274
  color,
275
+ useBreakpointIndex,
276
+ useResponsiveValue,
234
277
  useTheme
235
278
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/ui",
3
- "version": "1.8.2",
3
+ "version": "1.9.2",
4
4
  "description": "Primitive layout, typographic, and other components for styling applications.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -37,14 +37,15 @@
37
37
  "@theme-ui/color": "^0.13.1",
38
38
  "@theme-ui/components": "^0.13.1",
39
39
  "@theme-ui/core": "^0.13.1",
40
+ "@theme-ui/match-media": "^0.13.1",
40
41
  "@theme-ui/mdx": "^0.13.1"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": ">=17.0.2"
44
45
  },
45
46
  "devDependencies": {
46
- "@ttoss/config": "^1.8.2",
47
- "@ttoss/test-utils": "^1.8.2"
47
+ "@ttoss/config": "^1.9.2",
48
+ "@ttoss/test-utils": "^1.9.2"
48
49
  },
49
- "gitHead": "22b40decb1068840be424f2054d5de2af37f3f2e"
50
+ "gitHead": "528f6ffab12b98a8b9eab219de9defe41bc8d141"
50
51
  }
@@ -6,7 +6,10 @@ export type { ButtonProps };
6
6
 
7
7
  const Button = (props: ButtonProps) => {
8
8
  return (
9
- <ButtonUi {...props} sx={{ cursor: 'pointer', padding: 2, ...props.sx }} />
9
+ <ButtonUi
10
+ {...props}
11
+ sx={{ cursor: 'pointer', fontFamily: 'body', ...props.sx }}
12
+ />
10
13
  );
11
14
  };
12
15
 
@@ -0,0 +1,7 @@
1
+ import * as uiModule from './';
2
+
3
+ test('should export methods', () => {
4
+ expect(uiModule.useBreakpointIndex).toBeDefined();
5
+ expect(uiModule.useResponsiveValue).toBeDefined();
6
+ expect(uiModule.useTheme).toBeDefined();
7
+ });
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * as color from '@theme-ui/color';
2
2
  export type { Theme } from '@theme-ui/core';
3
+ export { useResponsiveValue, useBreakpointIndex } from '@theme-ui/match-media';
3
4
  export { Themed } from '@theme-ui/mdx';
4
5
 
5
6
  export {
@@ -2,6 +2,7 @@ import { Global, css } from '@emotion/react';
2
2
  import { ThemeProvider as ThemeUiProvider, Theme, merge } from '@theme-ui/core';
3
3
  import * as React from 'react';
4
4
 
5
+ import { defaultFonts } from './defaultFonts';
5
6
  import { defaultTheme } from './defaultTheme';
6
7
 
7
8
  export type ThemeProviderProps = {
@@ -16,7 +17,7 @@ export type ThemeProviderProps = {
16
17
  const ThemeProvider = ({
17
18
  children,
18
19
  theme = {},
19
- fonts = [],
20
+ fonts = defaultFonts,
20
21
  }: ThemeProviderProps) => {
21
22
  const mergedTheme = React.useMemo(() => {
22
23
  if (typeof theme === 'function') {
@@ -0,0 +1,6 @@
1
+ export const defaultFonts = [
2
+ 'https://fonts.googleapis.com/css?family=Asap',
3
+ 'https://fonts.googleapis.com/css?family=Overpass',
4
+ 'https://fonts.googleapis.com/css?family=Overpass+Mono',
5
+ 'https://fonts.googleapis.com/css?family=Flamenco',
6
+ ];
@@ -7,13 +7,25 @@ export const defaultTheme: Theme = {
7
7
  primary: '#07c',
8
8
  secondary: '#639',
9
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',
10
18
  },
11
- space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
12
19
  styles: {
20
+ root: {
21
+ fontFamily: 'body',
22
+ fontWeight: 'body',
23
+ },
13
24
  a: {
14
25
  color: 'primary',
15
26
  textDecoration: 'underline',
16
27
  cursor: 'pointer',
28
+ fontFamily: 'body',
17
29
  },
18
30
  progress: {
19
31
  color: 'primary',
@@ -21,13 +33,17 @@ export const defaultTheme: Theme = {
21
33
  },
22
34
  },
23
35
  buttons: {
24
- primary: {
36
+ cta: {
25
37
  color: 'white',
26
38
  backgroundColor: 'primary',
27
39
  },
28
- secondary: {
40
+ muted: {
41
+ color: 'text',
42
+ backgroundColor: 'muted',
43
+ },
44
+ danger: {
29
45
  color: 'white',
30
- backgroundColor: 'secondary',
46
+ backgroundColor: 'danger',
31
47
  },
32
48
  },
33
49
  cards: {
@@ -35,12 +51,26 @@ export const defaultTheme: Theme = {
35
51
  backgroundColor: 'background',
36
52
  border: '1px solid black',
37
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',
38
63
  },
39
64
  },
40
65
  text: {
66
+ default: {
67
+ color: 'text',
68
+ fontFamily: 'body',
69
+ },
41
70
  title: {
42
- fontSize: [4, 5],
43
- textAlign: 'center',
71
+ fontFamily: 'heading',
72
+ fontSize: 4,
73
+ lineSpace: '3.5',
44
74
  },
45
75
  },
46
76
  };