@latte-macchiat-io/latte-vanilla-components 0.0.188 → 0.0.190
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 +54 -39
- package/package.json +1 -1
- package/src/components/Button/stories.tsx +1 -1
- package/src/components/Logo/stories.tsx +1 -1
- package/src/components/Modal/stories.tsx +1 -2
- package/src/components/Section/stories.tsx +1 -1
- package/src/index.ts +1 -5
- package/src/themes/{createTheme.css.ts → createTheme.ts} +9 -9
- package/src/themes/dark.css.ts +0 -20
- package/src/themes/light.css.ts +0 -19
package/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# 🥤 Latte Vanilla Components
|
2
2
|
|
3
|
-
Beautiful, type-safe React components powered by Vanilla Extract CSS. Build modern interfaces with a professional design
|
3
|
+
Beautiful, type-safe React components powered by Vanilla Extract CSS. Build modern interfaces with a professional design
|
4
|
+
system that's both powerful and easy to use.
|
4
5
|
|
5
6
|
## ✨ Features
|
6
7
|
|
@@ -8,7 +9,7 @@ Beautiful, type-safe React components powered by Vanilla Extract CSS. Build mode
|
|
8
9
|
- 🚀 **Zero Runtime CSS-in-JS** - Vanilla Extract for optimal performance
|
9
10
|
- 📱 **Responsive Design** - Mobile-first, accessible components
|
10
11
|
- 🔒 **Type Safety** - Full TypeScript support throughout
|
11
|
-
- ⚡ **Developer Experience** - Hot reloading, IntelliSense,
|
12
|
+
- ⚡ **Developer Experience** - Hot reloading, IntelliSense, documentation
|
12
13
|
- 🎯 **Production Ready** - Optimized builds, minimal bundle size
|
13
14
|
|
14
15
|
## 📦 Installation
|
@@ -25,36 +26,57 @@ yarn add @latte-macchiat-io/latte-vanilla-components
|
|
25
26
|
|
26
27
|
### 1. Set up your theme (choose one approach):
|
27
28
|
|
28
|
-
**Option A:
|
29
|
+
**Option A: Reuse default theme**
|
29
30
|
|
30
31
|
```typescript
|
31
32
|
// src/styles/theme.css.ts
|
32
|
-
import {
|
33
|
-
|
33
|
+
import {createDarkTheme, createLightTheme} from "@latte-macchiat-io/latte-vanilla-components";
|
34
|
+
|
35
|
+
// Create and apply the default light theme (minimal setup)
|
36
|
+
createLightTheme();
|
37
|
+
|
38
|
+
// Optional: enable dark theme support
|
39
|
+
createDarkTheme();
|
34
40
|
```
|
35
41
|
|
36
|
-
**Option B:
|
42
|
+
**Option B: Customize partially themes**
|
37
43
|
|
38
44
|
```typescript
|
39
45
|
// src/styles/theme.css.ts
|
40
|
-
import {
|
46
|
+
import { createDarkTheme, createLightTheme } from '@latte-macchiat-io/latte-vanilla-components';
|
47
|
+
|
48
|
+
// Override only specific properties in light and dark themes
|
49
|
+
createLightTheme({
|
50
|
+
colors: {
|
51
|
+
background: '#f0f0f0', // Custom light background color
|
52
|
+
text: '#333333', // Custom light text color
|
53
|
+
},
|
54
|
+
fonts: {
|
55
|
+
body: 'Arial, sans-serif', // Custom font for body
|
56
|
+
},
|
57
|
+
fontSizes: {
|
58
|
+
md: '18px', // Custom medium font size
|
59
|
+
},
|
60
|
+
});
|
41
61
|
|
42
|
-
|
62
|
+
// Optional: customize dark theme as well
|
63
|
+
createDarkTheme({
|
43
64
|
colors: {
|
44
|
-
|
45
|
-
|
65
|
+
background: '#121212', // Custom dark background color
|
66
|
+
text: '#e0e0e0', // Custom dark text color
|
46
67
|
},
|
68
|
+
|
47
69
|
});
|
48
70
|
```
|
49
71
|
|
50
|
-
**Option C:
|
72
|
+
**Option C: Full Custom Theme (= contract redefinition)**
|
51
73
|
|
52
74
|
```typescript
|
53
75
|
// src/styles/theme.css.ts
|
54
76
|
import { createGlobalTheme } from '@vanilla-extract/css';
|
55
77
|
import { themeContract } from '@latte-macchiat-io/latte-vanilla-components';
|
56
78
|
|
57
|
-
|
79
|
+
createGlobalTheme(':root', themeContract, {
|
58
80
|
colors: {
|
59
81
|
primary: '#FF7377',
|
60
82
|
background: '#ffffff',
|
@@ -70,7 +92,7 @@ export const lightTheme = createGlobalTheme(':root', themeContract, {
|
|
70
92
|
// ... define all theme properties
|
71
93
|
});
|
72
94
|
|
73
|
-
|
95
|
+
createGlobalTheme('html[data-theme="dark"]', themeContract, {
|
74
96
|
colors: {
|
75
97
|
primary: '#FF7377',
|
76
98
|
background: '#1a1a1a',
|
@@ -81,7 +103,7 @@ export const darkTheme = createGlobalTheme('html[data-theme="dark"]', themeContr
|
|
81
103
|
});
|
82
104
|
```
|
83
105
|
|
84
|
-
### 2. Import your theme:
|
106
|
+
### 2. Import your theme globally:
|
85
107
|
|
86
108
|
```typescript
|
87
109
|
// src/app/layout.tsx (Next.js)
|
@@ -119,25 +141,7 @@ export default function App() {
|
|
119
141
|
|
120
142
|
### Available Theme Properties
|
121
143
|
|
122
|
-
|
123
|
-
{
|
124
|
-
colors: {
|
125
|
-
primary, secondary, accent, background, surface, text,
|
126
|
-
textSecondary, textLight, border, error, warning, success, info
|
127
|
-
},
|
128
|
-
space: { none, xs, sm, md, lg, xl, '2xl' }, // 0px to 128px
|
129
|
-
radii: { none, sm, md, lg, xl, full }, // Border radius
|
130
|
-
fonts: { body, heading, mono }, // Font families
|
131
|
-
fontSizes: { xs, sm, md, lg, xl, '2xl', '3xl', '4xl' }, // 12px to 40px
|
132
|
-
fontWeights: { light, normal, medium, semibold, bold },
|
133
|
-
lineHeights: { tight, normal, relaxed },
|
134
|
-
shadows: { none, sm, md, lg, xl }, // Box shadows
|
135
|
-
maxWidth: string, // Container width
|
136
|
-
section: { paddingTop, paddingBottom }, // Section spacing
|
137
|
-
header: { height }, // Header height
|
138
|
-
footer: { height }, // Footer height
|
139
|
-
}
|
140
|
-
```
|
144
|
+
- [ ] TODO @Gaelle
|
141
145
|
|
142
146
|
### Theme Switching
|
143
147
|
|
@@ -217,12 +221,20 @@ All components are mobile-first and responsive:
|
|
217
221
|
|
218
222
|
```typescript
|
219
223
|
// next.config.js
|
220
|
-
|
221
|
-
|
224
|
+
import type {NextConfig} from "next";
|
225
|
+
import {createVanillaExtractPlugin} from "@vanilla-extract/next-plugin";
|
222
226
|
|
223
|
-
|
224
|
-
|
227
|
+
const nextConfig: NextConfig = {
|
228
|
+
/* config options here */
|
229
|
+
transpilePackages: ['@latte-macchiat-io/latte-vanilla-components']
|
230
|
+
};
|
231
|
+
|
232
|
+
const withVanillaExtract = createVanillaExtractPlugin({
|
233
|
+
identifiers: process.env.NODE_ENV === 'production' ? 'short' : 'debug',
|
225
234
|
});
|
235
|
+
|
236
|
+
export default withVanillaExtract(nextConfig);
|
237
|
+
|
226
238
|
```
|
227
239
|
|
228
240
|
### Using with Vite
|
@@ -233,6 +245,9 @@ import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
|
233
245
|
|
234
246
|
export default {
|
235
247
|
plugins: [vanillaExtractPlugin()],
|
248
|
+
optimizeDeps: {
|
249
|
+
exclude: ['@latte-macchiat-io/latte-vanilla-components'],
|
250
|
+
},
|
236
251
|
};
|
237
252
|
```
|
238
253
|
|
@@ -279,7 +294,7 @@ const customButton = style({
|
|
279
294
|
|
280
295
|
---
|
281
296
|
|
282
|
-
## 🛠 Development &
|
297
|
+
## 🛠 Development & storybook testing
|
283
298
|
|
284
299
|
### Run Storybook
|
285
300
|
|
@@ -295,4 +310,4 @@ Push changes to `main` branch and GitHub Actions will automatically publish to N
|
|
295
310
|
|
296
311
|
---
|
297
312
|
|
298
|
-
Made with
|
313
|
+
Made with ❤️ by the Latte team 🥤
|
package/package.json
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import React from 'react';
|
2
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
3
|
-
import { useState } from 'react';
|
2
|
+
import React, { useState } from 'react';
|
4
3
|
import { Modal } from './Modal';
|
5
4
|
import { Button } from '../Button/Button';
|
6
5
|
import { Section } from '../Section/Section';
|
package/src/index.ts
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
// Theme system - Import this first to apply global styles
|
2
2
|
export { themeContract } from './themes/contract.css';
|
3
3
|
export { baseLightTheme, baseDarkTheme } from './themes/baseThemeValues';
|
4
|
-
export { createLightTheme, createDarkTheme, type ThemeOverrides } from './themes/createTheme
|
5
|
-
|
6
|
-
// Available themes
|
7
|
-
export { lightTheme } from './themes/light.css';
|
8
|
-
export { darkTheme } from './themes/dark.css';
|
4
|
+
export { createLightTheme, createDarkTheme, type ThemeOverrides } from './themes/createTheme';
|
9
5
|
|
10
6
|
// Styles utilities (sprinkles, media queries, etc.)
|
11
7
|
export { sprinkles, responsiveProperties, type Sprinkles } from './styles/sprinkles.css';
|
@@ -10,12 +10,12 @@ export type ThemeOverrides = {
|
|
10
10
|
fonts?: Partial<typeof baseLightTheme.fonts>;
|
11
11
|
maxWidth?: Partial<typeof baseLightTheme.maxWidth>;
|
12
12
|
fontSizes?: Partial<typeof baseLightTheme.fontSizes>;
|
13
|
-
fontWeights?: Partial<typeof baseLightTheme.
|
14
|
-
lineHeights?: Partial<typeof baseLightTheme.
|
15
|
-
shadows?: Partial<typeof baseLightTheme.
|
16
|
-
section?: Partial<typeof baseLightTheme.
|
17
|
-
header?: Partial<typeof baseLightTheme.
|
18
|
-
footer?: Partial<typeof baseLightTheme.
|
13
|
+
fontWeights?: Partial<typeof baseLightTheme.fontWeights>;
|
14
|
+
lineHeights?: Partial<typeof baseLightTheme.lineHeights>;
|
15
|
+
shadows?: Partial<typeof baseLightTheme.shadows>;
|
16
|
+
section?: Partial<typeof baseLightTheme.section>;
|
17
|
+
header?: Partial<typeof baseLightTheme.header>;
|
18
|
+
footer?: Partial<typeof baseLightTheme.footer>;
|
19
19
|
};
|
20
20
|
|
21
21
|
// Utility to create a theme with partial overrides over light theme base
|
@@ -25,7 +25,7 @@ const createAppTheme = (selector: string, overrides: ThemeOverrides = {}) => {
|
|
25
25
|
space: { ...baseLightTheme.space, ...overrides.space },
|
26
26
|
radii: { ...baseLightTheme.radii, ...overrides.radii },
|
27
27
|
fonts: { ...baseLightTheme.fonts, ...overrides.fonts },
|
28
|
-
maxWidth: `${
|
28
|
+
maxWidth: `${overrides.maxWidth || baseLightTheme.maxWidth}`,
|
29
29
|
fontSizes: { ...baseLightTheme.fontSizes, ...overrides.fontSizes },
|
30
30
|
fontWeights: { ...baseLightTheme.fontWeights, ...overrides.fontWeights },
|
31
31
|
lineHeights: { ...baseLightTheme.lineHeights, ...overrides.lineHeights },
|
@@ -43,7 +43,7 @@ const createAppDarkTheme = (selector: string, overrides: ThemeOverrides = {}) =>
|
|
43
43
|
space: { ...baseDarkTheme.space, ...overrides.space },
|
44
44
|
radii: { ...baseDarkTheme.radii, ...overrides.radii },
|
45
45
|
fonts: { ...baseDarkTheme.fonts, ...overrides.fonts },
|
46
|
-
maxWidth: overrides.maxWidth ||
|
46
|
+
maxWidth: `${overrides.maxWidth || baseDarkTheme.maxWidth}`,
|
47
47
|
fontSizes: { ...baseDarkTheme.fontSizes, ...overrides.fontSizes },
|
48
48
|
fontWeights: { ...baseDarkTheme.fontWeights, ...overrides.fontWeights },
|
49
49
|
lineHeights: { ...baseDarkTheme.lineHeights, ...overrides.lineHeights },
|
@@ -62,4 +62,4 @@ export const createLightTheme = (overrides: ThemeOverrides = {}) => {
|
|
62
62
|
// Convenience function for dark theme (extends base dark theme)
|
63
63
|
export const createDarkTheme = (overrides: ThemeOverrides = {}) => {
|
64
64
|
return createAppDarkTheme('html[data-theme="dark"]', overrides);
|
65
|
-
};
|
65
|
+
};
|
package/src/themes/dark.css.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import { createGlobalTheme } from '@vanilla-extract/css';
|
2
|
-
import { baseDarkTheme } from './baseThemeValues';
|
3
|
-
import { themeContract } from './contract.css';
|
4
|
-
|
5
|
-
// Create the dark theme at module level so Vanilla Extract can process it
|
6
|
-
// The dark theme will only be applied when the html element has a data-theme="dark" attribute
|
7
|
-
export const darkTheme = createGlobalTheme('html[data-theme="dark"]', themeContract, {
|
8
|
-
colors: baseDarkTheme.colors,
|
9
|
-
space: baseDarkTheme.space,
|
10
|
-
radii: baseDarkTheme.radii,
|
11
|
-
fonts: baseDarkTheme.fonts,
|
12
|
-
maxWidth: baseDarkTheme.maxWidth,
|
13
|
-
fontSizes: baseDarkTheme.fontSizes,
|
14
|
-
fontWeights: baseDarkTheme.fontWeights,
|
15
|
-
lineHeights: baseDarkTheme.lineHeights,
|
16
|
-
shadows: baseDarkTheme.shadows,
|
17
|
-
section: baseDarkTheme.section,
|
18
|
-
header: baseDarkTheme.header,
|
19
|
-
footer: baseDarkTheme.footer,
|
20
|
-
});
|
package/src/themes/light.css.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import { createGlobalTheme } from '@vanilla-extract/css';
|
2
|
-
import { themeContract } from './/contract.css';
|
3
|
-
import { baseLightTheme } from './/baseThemeValues';
|
4
|
-
|
5
|
-
// Create the light theme at module level so Vanilla Extract can process it
|
6
|
-
export const lightTheme = createGlobalTheme(':root', themeContract, {
|
7
|
-
colors: baseLightTheme.colors,
|
8
|
-
space: baseLightTheme.space,
|
9
|
-
radii: baseLightTheme.radii,
|
10
|
-
fonts: baseLightTheme.fonts,
|
11
|
-
maxWidth: baseLightTheme.maxWidth,
|
12
|
-
fontSizes: baseLightTheme.fontSizes,
|
13
|
-
fontWeights: baseLightTheme.fontWeights,
|
14
|
-
lineHeights: baseLightTheme.lineHeights,
|
15
|
-
shadows: baseLightTheme.shadows,
|
16
|
-
section: baseLightTheme.section,
|
17
|
-
header: baseLightTheme.header,
|
18
|
-
footer: baseLightTheme.footer,
|
19
|
-
});
|