@rarui/styles 1.0.0-rc.1

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +37 -0
  3. package/dist/index.css +1 -0
  4. package/dist/index.d.ts +185 -0
  5. package/dist/index.js +1 -0
  6. package/dist/styles.css +1 -0
  7. package/dist/themes/dark.css +1 -0
  8. package/dist/themes/dark.d.ts +9 -0
  9. package/dist/themes/dark.js +1 -0
  10. package/package.json +33 -0
  11. package/src/components/ThemeProvider.tsx +30 -0
  12. package/src/components/contexts/ThemeProviderContext/ThemeProviderContext.tsx +6 -0
  13. package/src/components/contexts/ThemeProviderContext/index.ts +5 -0
  14. package/src/components/contexts/ThemeProviderContext/themeProviderContext.types.ts +7 -0
  15. package/src/components/contexts/index.ts +1 -0
  16. package/src/components/hooks/index.ts +1 -0
  17. package/src/components/hooks/useTheme/index.ts +1 -0
  18. package/src/components/hooks/useTheme/useTheme.spec.tsx +27 -0
  19. package/src/components/hooks/useTheme/useTheme.ts +9 -0
  20. package/src/components/index.ts +6 -0
  21. package/src/components/themeProvider.definitions.ts +6 -0
  22. package/src/components/themeProvider.spec.tsx +41 -0
  23. package/src/components/themeProvider.types.ts +10 -0
  24. package/src/index.ts +8 -0
  25. package/src/index.types.ts +71 -0
  26. package/src/packages/atomic/button/index.ts +6 -0
  27. package/src/packages/atomic/button/rarui-button.commons.ts +82 -0
  28. package/src/packages/atomic/button/rarui-button.css.ts +331 -0
  29. package/src/packages/atomic/button/rarui-button.types.ts +4 -0
  30. package/src/themes/contract.css.ts +241 -0
  31. package/src/themes/globals.css.ts +256 -0
  32. package/src/themes/index.ts +2 -0
  33. package/src/themes/mediaQueries.ts +10 -0
  34. package/src/themes/rarui-theme-dark.css.ts +126 -0
  35. package/tsconfig.json +4 -0
  36. package/webpack.config.ts +30 -0
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+
4
+ import { ThemeProvider } from ".";
5
+ import { ThemeProviderProps } from "./themeProvider.types";
6
+
7
+ const makeSut = (props: ThemeProviderProps) => {
8
+ render(<ThemeProvider {...props} data-testid="theme-provider-element" />);
9
+ };
10
+
11
+ describe("GIVEN <ThemeProvider />", () => {
12
+ describe("WHEN rendered", () => {
13
+ it("THEN should render the submitted children", () => {
14
+ makeSut({ children: "My children" });
15
+ expect(screen.getByText("My children")).toBeDefined();
16
+ });
17
+ });
18
+
19
+ describe("THEN should correctly render the submitted theme", () => {
20
+ it("THEN should correctly render the padding default", () => {
21
+ makeSut({ children: "My children" });
22
+ expect(
23
+ screen.getByTestId("theme-provider-element").getAttribute("class"),
24
+ ).toEqual("");
25
+ });
26
+
27
+ it("THEN should correctly render the padding base", () => {
28
+ makeSut({ children: "My children", theme: "base" });
29
+ expect(
30
+ screen.getByTestId("theme-provider-element").getAttribute("class"),
31
+ ).toEqual("");
32
+ });
33
+
34
+ it("THEN should correctly render the padding dark", () => {
35
+ makeSut({ children: "My children", theme: "dark" });
36
+ expect(
37
+ screen.getByTestId("theme-provider-element").getAttribute("class"),
38
+ ).toContain("dark");
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,10 @@
1
+ import { HTMLAttributes } from "react";
2
+
3
+ export type Theme = "dark" | "base";
4
+
5
+ export interface ThemeProviderProperties {
6
+ theme?: Theme;
7
+ }
8
+
9
+ export type ThemeProviderProps = ThemeProviderProperties &
10
+ HTMLAttributes<HTMLElement>;
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ // components
2
+ export * from "./components";
3
+
4
+ // atomics
5
+ export { button } from "./packages/atomic/button";
6
+
7
+ // types
8
+ export type { ButtonVariants } from "./packages/atomic/button";
@@ -0,0 +1,71 @@
1
+ export interface Conditions<T> {
2
+ xs?: T;
3
+ md?: T;
4
+ lg?: T;
5
+ xl?: T;
6
+ }
7
+ export type AspectRatio =
8
+ | "1/1"
9
+ | "16/9"
10
+ | "9/16"
11
+ | "4/3"
12
+ | "3/4"
13
+ | "2/1"
14
+ | "1/2";
15
+ export type BorderStyle = "solid" | "none" | "hidden" | "dashed" | "dotted";
16
+ export type BoxSizing = "border-box" | "content-box";
17
+ export type Cursor = "auto" | "pointer" | "not-allowed" | "grab" | "inherit";
18
+ export type Display =
19
+ | "block"
20
+ | "flex"
21
+ | "inline-flex"
22
+ | "grid"
23
+ | "inline-grid"
24
+ | "none";
25
+ export type FlexWrap = "nowrap" | "wrap" | "wrap-reverse";
26
+ export type FlexDirection = "row" | "row-reverse" | "column" | "column-reverse";
27
+ export type JustifyContent =
28
+ | "flex-start"
29
+ | "flex-end"
30
+ | "center"
31
+ | "space-between"
32
+ | "space-around"
33
+ | "space-evenly";
34
+ export type AlignItems =
35
+ | "stretch"
36
+ | "flex-start"
37
+ | "flex-end"
38
+ | "center"
39
+ | "baseline";
40
+ export type AlignSelf =
41
+ | "auto"
42
+ | "flex-start"
43
+ | "flex-end"
44
+ | "center"
45
+ | "baseline"
46
+ | "stretch";
47
+ export type TextAlign = "left" | "right" | "center" | "justify";
48
+ export type TextDecoration = "none" | "underline";
49
+ export type Position = "absolute" | "fixed" | "relative" | "static" | "sticky";
50
+ export type Overflow = "visible" | "hidden" | "scroll" | "auto";
51
+ export type PointerEvents =
52
+ | "auto"
53
+ | "none"
54
+ | "visiblePainted"
55
+ | "visibleFill"
56
+ | "visibleStroke"
57
+ | "visible"
58
+ | "painted"
59
+ | "fill"
60
+ | "stroke"
61
+ | "all"
62
+ | "inherit";
63
+ export type TransitionTiming =
64
+ | "ease"
65
+ | "ease-in"
66
+ | "ease-out"
67
+ | "ease-in-out"
68
+ | "linear"
69
+ | "step-start"
70
+ | "step-end";
71
+ export type WordBreak = "normal" | "break-all" | "keep-all" | "break-word";
@@ -0,0 +1,6 @@
1
+ import * as styles from "./rarui-button.css";
2
+
3
+ export const button = {
4
+ classnames: { ...styles },
5
+ };
6
+ export type { ButtonVariants } from "./rarui-button.types";
@@ -0,0 +1,82 @@
1
+ import { varsThemeBase } from "../../../themes";
2
+
3
+ export const buttonOutlined = {
4
+ brand: {
5
+ ":hover": {
6
+ backgroundColor: varsThemeBase.colors.surface["brand-hover"],
7
+ },
8
+ ":active": {
9
+ backgroundColor: varsThemeBase.colors.surface["brand-press"],
10
+ },
11
+ color: varsThemeBase.colors.content.brand,
12
+ },
13
+ "brand-secondary": {
14
+ ":hover": {
15
+ backgroundColor: varsThemeBase.colors.surface["brand-secondary-hover"],
16
+ },
17
+ ":active": {
18
+ backgroundColor: varsThemeBase.colors.surface["brand-secondary-press"],
19
+ },
20
+ color: varsThemeBase.colors.content["brand-secondary"],
21
+ },
22
+ danger: {
23
+ ":hover": {
24
+ backgroundColor: varsThemeBase.colors.surface["error-hover"],
25
+ },
26
+ ":active": {
27
+ backgroundColor: varsThemeBase.colors.surface["error-press"],
28
+ },
29
+ color: varsThemeBase.colors.content.error,
30
+ },
31
+ success: {
32
+ ":hover": {
33
+ backgroundColor: varsThemeBase.colors.surface["success-hover"],
34
+ },
35
+ ":active": {
36
+ backgroundColor: varsThemeBase.colors.surface["success-press"],
37
+ },
38
+ color: varsThemeBase.colors.content.success,
39
+ },
40
+ warning: {
41
+ ":hover": {
42
+ backgroundColor: varsThemeBase.colors.surface["warning-hover"],
43
+ },
44
+ ":active": {
45
+ backgroundColor: varsThemeBase.colors.surface["warning-press"],
46
+ },
47
+ color: varsThemeBase.colors.content.warning,
48
+ },
49
+ neutral: {
50
+ ":hover": {
51
+ backgroundColor: varsThemeBase.colors.surface.hover,
52
+ },
53
+ ":active": {
54
+ backgroundColor: varsThemeBase.colors.surface.press,
55
+ },
56
+ color: varsThemeBase.colors.content.primary,
57
+ },
58
+ inverted: {
59
+ ":hover": {
60
+ backgroundColor: varsThemeBase.colors.surface["invert-hover"],
61
+ },
62
+ ":active": {
63
+ backgroundColor: varsThemeBase.colors.surface["invert-press"],
64
+ },
65
+ color: varsThemeBase.colors.content.invert,
66
+ },
67
+ };
68
+
69
+ export const buttonText = {
70
+ brand: buttonOutlined.brand,
71
+ "brand-secondary": buttonOutlined["brand-secondary"],
72
+ danger: buttonOutlined.danger,
73
+ success: buttonOutlined.success,
74
+ warning: buttonOutlined.warning,
75
+ neutral: buttonOutlined.neutral,
76
+ inverted: buttonOutlined.inverted,
77
+ };
78
+
79
+ export const buttonVariants = {
80
+ outlined: buttonOutlined,
81
+ text: buttonText,
82
+ };
@@ -0,0 +1,331 @@
1
+ import { globalStyle, style } from "@vanilla-extract/css";
2
+ import { recipe } from "@vanilla-extract/recipes";
3
+ import { varsThemeBase } from "../../../themes";
4
+ import { buttonVariants } from "./rarui-button.commons";
5
+
6
+ export const button = recipe({
7
+ base: {
8
+ display: "flex",
9
+ alignItems: "center",
10
+ justifyContent: "center",
11
+ width: "fit-content",
12
+ textDecoration: "none",
13
+ cursor: "pointer",
14
+ boxSizing: "border-box",
15
+ position: "relative",
16
+ overflow: "hidden",
17
+ gap: varsThemeBase.spacing["4xs"],
18
+ fontWeight: varsThemeBase.fontWeight.semiBold,
19
+ lineHeight: varsThemeBase.lineWeight.button.l,
20
+ fontSize: varsThemeBase.fontSize.button.l,
21
+ fontFamily: varsThemeBase.fontFamily.inter,
22
+ borderRadius: varsThemeBase.shape.border.radius["2xs"],
23
+ borderWidth: varsThemeBase.shape.border.width[1],
24
+ borderStyle: "solid",
25
+ borderColor: varsThemeBase.colors.surface.brand,
26
+ ":disabled": {
27
+ background: varsThemeBase.colors.surface.disabled,
28
+ borderColor: varsThemeBase.colors.surface.disabled,
29
+ color: varsThemeBase.colors.content.disabled,
30
+ cursor: "not-allowed",
31
+ },
32
+ },
33
+ variants: {
34
+ appearance: {
35
+ brand: {
36
+ backgroundColor: varsThemeBase.colors.surface.brand,
37
+ borderColor: varsThemeBase.colors.surface.brand,
38
+ color: varsThemeBase.colors.content["on-brand"],
39
+ },
40
+ "brand-secondary": {
41
+ backgroundColor: varsThemeBase.colors.surface["brand-secondary"],
42
+ borderColor: varsThemeBase.colors.surface["brand-secondary"],
43
+ color: varsThemeBase.colors.content["on-brand-secondary"],
44
+ },
45
+ danger: {
46
+ backgroundColor: varsThemeBase.colors.surface.error,
47
+ borderColor: varsThemeBase.colors.surface.error,
48
+ color: varsThemeBase.colors.content["on-error"],
49
+ },
50
+ success: {
51
+ backgroundColor: varsThemeBase.colors.surface.success,
52
+ borderColor: varsThemeBase.colors.surface.success,
53
+ color: varsThemeBase.colors.content["on-success"],
54
+ },
55
+ warning: {
56
+ backgroundColor: varsThemeBase.colors.surface.warning,
57
+ borderColor: varsThemeBase.colors.surface.warning,
58
+ color: varsThemeBase.colors.content["on-warning"],
59
+ },
60
+ neutral: {
61
+ backgroundColor: varsThemeBase.colors.surface.invert,
62
+ borderColor: varsThemeBase.colors.surface.invert,
63
+ color: varsThemeBase.colors.content.invert,
64
+ },
65
+ inverted: {
66
+ backgroundColor: varsThemeBase.colors.surface.primary,
67
+ borderColor: varsThemeBase.colors.surface.primary,
68
+ color: varsThemeBase.colors.content.primary,
69
+ },
70
+ },
71
+ size: {
72
+ large: {
73
+ padding: varsThemeBase.spacing.xs,
74
+ height: "3rem",
75
+ fontSize: varsThemeBase.fontSize.button.l,
76
+ },
77
+ medium: {
78
+ padding: varsThemeBase.spacing.xs,
79
+ height: "2.75rem",
80
+ fontSize: varsThemeBase.fontSize.button.m,
81
+ },
82
+ small: {
83
+ padding: varsThemeBase.spacing["3xs"],
84
+ height: "2rem",
85
+ fontSize: varsThemeBase.fontSize.button.s,
86
+ },
87
+ },
88
+ variant: {
89
+ solid: {},
90
+ outlined: {
91
+ backgroundColor: "transparent",
92
+ },
93
+ text: {
94
+ backgroundColor: "transparent",
95
+ textDecoration: "underline",
96
+ border: "none",
97
+ borderRadius: varsThemeBase.shape.border.radius.button,
98
+ ":hover": {
99
+ borderRadius: varsThemeBase.shape.border.radius.button,
100
+ },
101
+ ":active": {
102
+ borderRadius: varsThemeBase.shape.border.radius.button,
103
+ },
104
+ },
105
+ tonal: {
106
+ border: "none",
107
+ borderRadius: varsThemeBase.shape.border.radius.button,
108
+ },
109
+ },
110
+ },
111
+ compoundVariants: [
112
+ // variant outlined
113
+ {
114
+ variants: {
115
+ appearance: "brand",
116
+ variant: "outlined",
117
+ },
118
+ style: {
119
+ ...buttonVariants.outlined.brand,
120
+ borderColor: varsThemeBase.colors.border.brand,
121
+ },
122
+ },
123
+ {
124
+ variants: {
125
+ appearance: "brand-secondary",
126
+ variant: "outlined",
127
+ },
128
+ style: {
129
+ ...buttonVariants.outlined["brand-secondary"],
130
+ borderColor: varsThemeBase.colors.border["brand-secondary"],
131
+ },
132
+ },
133
+ {
134
+ variants: {
135
+ appearance: "danger",
136
+ variant: "outlined",
137
+ },
138
+ style: {
139
+ ...buttonVariants.outlined.danger,
140
+ borderColor: varsThemeBase.colors.border.error,
141
+ },
142
+ },
143
+ {
144
+ variants: {
145
+ appearance: "success",
146
+ variant: "outlined",
147
+ },
148
+ style: {
149
+ ...buttonVariants.outlined.success,
150
+ borderColor: varsThemeBase.colors.border.success,
151
+ },
152
+ },
153
+ {
154
+ variants: {
155
+ appearance: "warning",
156
+ variant: "outlined",
157
+ },
158
+ style: {
159
+ ...buttonVariants.outlined.warning,
160
+ borderColor: varsThemeBase.colors.border.warning,
161
+ },
162
+ },
163
+ {
164
+ variants: {
165
+ appearance: "neutral",
166
+ variant: "outlined",
167
+ },
168
+ style: {
169
+ ...buttonVariants.outlined.neutral,
170
+ borderColor: varsThemeBase.colors.border.secondary,
171
+ },
172
+ },
173
+ {
174
+ variants: {
175
+ appearance: "inverted",
176
+ variant: "outlined",
177
+ },
178
+ style: {
179
+ ...buttonVariants.outlined.inverted,
180
+ borderColor: varsThemeBase.colors.border.invert,
181
+ },
182
+ },
183
+ // variant text
184
+ {
185
+ variants: {
186
+ appearance: "brand",
187
+ variant: "text",
188
+ },
189
+ style: buttonVariants.text.brand,
190
+ },
191
+ {
192
+ variants: {
193
+ appearance: "brand-secondary",
194
+ variant: "text",
195
+ },
196
+ style: buttonVariants.text["brand-secondary"],
197
+ },
198
+ {
199
+ variants: {
200
+ appearance: "danger",
201
+ variant: "text",
202
+ },
203
+ style: buttonVariants.text.danger,
204
+ },
205
+ {
206
+ variants: {
207
+ appearance: "success",
208
+ variant: "text",
209
+ },
210
+ style: buttonVariants.text.success,
211
+ },
212
+ {
213
+ variants: {
214
+ appearance: "warning",
215
+ variant: "text",
216
+ },
217
+ style: buttonVariants.text.warning,
218
+ },
219
+ {
220
+ variants: {
221
+ appearance: "neutral",
222
+ variant: "text",
223
+ },
224
+ style: {
225
+ ...buttonVariants.text.neutral,
226
+ },
227
+ },
228
+ {
229
+ variants: {
230
+ appearance: "inverted",
231
+ variant: "text",
232
+ },
233
+ style: buttonVariants.text.inverted,
234
+ },
235
+ // variant tonal
236
+ {
237
+ variants: {
238
+ appearance: "brand",
239
+ variant: "tonal",
240
+ },
241
+ style: {
242
+ ...buttonVariants.text.brand,
243
+ backgroundColor: varsThemeBase.colors.surface["brand-subdued"],
244
+ },
245
+ },
246
+ {
247
+ variants: {
248
+ appearance: "brand-secondary",
249
+ variant: "tonal",
250
+ },
251
+ style: {
252
+ ...buttonVariants.text["brand-secondary"],
253
+ backgroundColor:
254
+ varsThemeBase.colors.surface["brand-secondary-subdued"],
255
+ },
256
+ },
257
+ {
258
+ variants: {
259
+ appearance: "danger",
260
+ variant: "tonal",
261
+ },
262
+ style: {
263
+ ...buttonVariants.text.danger,
264
+ backgroundColor: varsThemeBase.colors.surface["error-subdued"],
265
+ },
266
+ },
267
+ {
268
+ variants: {
269
+ appearance: "success",
270
+ variant: "tonal",
271
+ },
272
+ style: {
273
+ ...buttonVariants.text.success,
274
+ backgroundColor: varsThemeBase.colors.surface["success-subdued"],
275
+ },
276
+ },
277
+ {
278
+ variants: {
279
+ appearance: "warning",
280
+ variant: "tonal",
281
+ },
282
+ style: {
283
+ ...buttonVariants.text.warning,
284
+ backgroundColor: varsThemeBase.colors.surface["warning-subdued"],
285
+ },
286
+ },
287
+ {
288
+ variants: {
289
+ appearance: "neutral",
290
+ variant: "tonal",
291
+ },
292
+ style: {
293
+ ...buttonVariants.text.neutral,
294
+ backgroundColor: varsThemeBase.colors.surface.secondary,
295
+ },
296
+ },
297
+ {
298
+ variants: {
299
+ appearance: "brand",
300
+ variant: "tonal",
301
+ },
302
+ style: {
303
+ ...buttonVariants.text.brand,
304
+ backgroundColor: varsThemeBase.colors.surface["invert-secondary"],
305
+ },
306
+ },
307
+ ],
308
+ });
309
+
310
+ export const overlay = style({
311
+ position: "absolute",
312
+ top: -1,
313
+ left: -1,
314
+ bottom: -1,
315
+ right: -1,
316
+ pointerEvents: "none",
317
+ opacity: 0,
318
+ borderRadius: varsThemeBase.shape.border.radius["2xs"],
319
+ });
320
+
321
+ globalStyle(`${button()}:hover ${overlay}`, {
322
+ opacity: 1,
323
+ backgroundColor: varsThemeBase.colors.surface["on-brand-hover"],
324
+ borderColor: varsThemeBase.colors.surface["on-brand-hover"],
325
+ });
326
+
327
+ globalStyle(`${button()}:active ${overlay}`, {
328
+ opacity: 1,
329
+ backgroundColor: varsThemeBase.colors.surface["on-brand-press"],
330
+ borderColor: varsThemeBase.colors.surface["on-brand-press"],
331
+ });
@@ -0,0 +1,4 @@
1
+ import { RecipeVariants } from "@vanilla-extract/recipes";
2
+ import { button } from "./rarui-button.css";
3
+
4
+ export type ButtonVariants = RecipeVariants<typeof button>;