@latte-macchiat-io/latte-vanilla-components 0.0.327 → 0.0.329

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latte-macchiat-io/latte-vanilla-components",
3
- "version": "0.0.327",
3
+ "version": "0.0.329",
4
4
  "description": "Beautiful components for amazing projects, with a touch of Vanilla 🥤",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -5,7 +5,7 @@ import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
5
5
  import { queries } from '../../styles/mediaqueries';
6
6
  import { themeContract } from '../../theme/contract.css';
7
7
 
8
- import { generateResponsive } from '../../utils/generateResponsive';
8
+ import { generateResponsiveMedia } from '../../utils/generateResponsiveMedia';
9
9
 
10
10
  export const carouselRecipe = recipe(
11
11
  {
@@ -95,7 +95,7 @@ export const carouselNav = recipe(
95
95
  pointerEvents: 'none',
96
96
  justifyContent: 'flex-end',
97
97
 
98
- '@media': generateResponsive({
98
+ '@media': generateResponsiveMedia({
99
99
  gap: themeContract.carousel.nav.gap,
100
100
  }),
101
101
  },
@@ -117,7 +117,7 @@ export const carouselNav = recipe(
117
117
 
118
118
  navPositionVertical: {
119
119
  top: {
120
- '@media': generateResponsive(
120
+ '@media': generateResponsiveMedia(
121
121
  {}, // pas de props "normales" ici
122
122
  [
123
123
  {
@@ -134,7 +134,7 @@ export const carouselNav = recipe(
134
134
  transform: 'translate(0%, -50%)',
135
135
  },
136
136
  bottom: {
137
- '@media': generateResponsive(
137
+ '@media': generateResponsiveMedia(
138
138
  {}, // pas de props "normales" ici non plus
139
139
  [
140
140
  {
@@ -172,8 +172,8 @@ export const carouselNavButton = style(
172
172
 
173
173
  ':hover': {
174
174
  transform: 'scale(1.1)',
175
- color: themeContract.colors.background,
176
- backgroundColor: themeContract.colors.primary,
175
+ border: themeContract.carousel.nav.borderHover,
176
+ backgroundColor: themeContract.carousel.nav.backgroundColorHover,
177
177
  },
178
178
 
179
179
  ':disabled': {
@@ -182,7 +182,7 @@ export const carouselNavButton = style(
182
182
  pointerEvents: 'none',
183
183
  },
184
184
 
185
- '@media': generateResponsive({
185
+ '@media': generateResponsiveMedia({
186
186
  width: themeContract.carousel.nav.width,
187
187
  height: themeContract.carousel.nav.height,
188
188
  }),
@@ -199,7 +199,7 @@ export const carouselBullets = style({
199
199
  position: 'absolute',
200
200
  justifyContent: 'center',
201
201
 
202
- '@media': generateResponsive(
202
+ '@media': generateResponsiveMedia(
203
203
  {
204
204
  gap: themeContract.carousel.bullet.gap,
205
205
  },
@@ -227,7 +227,7 @@ export const carouselBullet = style(
227
227
  transform: 'scale(1.2)',
228
228
  },
229
229
 
230
- '@media': generateResponsive({
230
+ '@media': generateResponsiveMedia({
231
231
  width: themeContract.carousel.bullet.width,
232
232
  height: themeContract.carousel.bullet.height,
233
233
  }),
@@ -90,6 +90,8 @@ export const themeCarouselLight = {
90
90
  ...themeCarouselBase.carousel.nav,
91
91
  border: '1px solid #000',
92
92
  backgroundColor: '#FF7377',
93
+ borderHover: '1px solid #000',
94
+ backgroundColorHover: '#FF7377',
93
95
  },
94
96
 
95
97
  bullet: {
@@ -109,6 +111,8 @@ export const themeCarouselDark = {
109
111
  ...themeCarouselBase.carousel.nav,
110
112
  border: '1px solid #000',
111
113
  backgroundColor: '#FF7377',
114
+ borderHover: '1px solid #000',
115
+ backgroundColorHover: '#FF7377',
112
116
  },
113
117
 
114
118
  bullet: {
@@ -811,8 +811,10 @@ export const themeContract = createGlobalThemeContract({
811
811
 
812
812
  nav: {
813
813
  border: 'latte-carousel-nav-border',
814
+ borderHover: 'latte-carousel-nav-borderHover',
814
815
  borderRadius: 'latte-carousel-nav-borderRadius',
815
816
  backgroundColor: 'latte-carousel-nav-backgroundColor',
817
+ backgroundColorHover: 'latte-carousel-nav-backgroundColorHover',
816
818
  positionVerticalOffset: {
817
819
  mobile: 'latte-carousel-nav-positionVerticalOffset-mobile',
818
820
  sm: 'latte-carousel-nav-positionVerticalOffset-sm',
@@ -1,46 +1,50 @@
1
- // utils/generateResponsiveMedia.ts
1
+ // utils/generateResponsive.ts
2
2
  import { queries } from '../styles/mediaqueries';
3
3
 
4
- /**
5
- * Breakpoint keys you support (should match your queries object).
6
- */
4
+ // Define the supported breakpoint keys
7
5
  type BreakpointKey = 'mobile' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
8
- const BPS: BreakpointKey[] = ['mobile', 'sm', 'md', 'lg', 'xl', '2xl'];
9
6
 
10
- /**
11
- * Responsive values can be a plain string/number or anything with a toString().
12
- */
7
+ // A responsive value can be a string, number, or anything with a toString method
13
8
  type ResponsiveValue = string | number | { toString(): string };
9
+
10
+ // Map of breakpoint keys to responsive values
14
11
  type BreakpointMap = Partial<Record<BreakpointKey, ResponsiveValue>>;
15
12
 
13
+ // Ordered list of breakpoints to iterate over
14
+ const BPS: BreakpointKey[] = ['mobile', 'sm', 'md', 'lg', 'xl', '2xl'];
15
+
16
16
  /**
17
- * Generate responsive media queries for a set of CSS properties.
17
+ * Generates a fully responsive CSS object for Vanilla Extract
18
18
  *
19
- * Example:
20
- * generateResponsiveMedia({
21
- * width: { mobile: '100%', md: '50%' },
22
- * padding: '20px'
23
- * })
24
- *
25
- * => {
26
- * '@media (min-width:...)': { width: '50%', padding: '20px' },
27
- * ...
28
- * }
19
+ * @param props - normal CSS properties, either a single value or responsive map
20
+ * @param calcProps - optional array of calc() rules for dynamic calculations
21
+ * @returns an object ready to use under `@media` in Vanilla Extract
29
22
  */
30
- export function generateResponsiveMedia(properties: Record<string, ResponsiveValue | BreakpointMap>) {
23
+ export function generateResponsiveMedia(
24
+ props: Record<string, ResponsiveValue | BreakpointMap>,
25
+ calcProps?: Array<{
26
+ property: string;
27
+ base: ResponsiveValue | BreakpointMap;
28
+ offset: ResponsiveValue | BreakpointMap;
29
+ operator?: string; // + - * / etc.
30
+ }>
31
+ ): Record<string, Record<string, string>> {
31
32
  const result: Record<string, Record<string, string>> = {};
32
33
 
34
+ // Helper to convert a value to a proper CSS string
33
35
  const toCssValue = (v: ResponsiveValue) => {
34
36
  const s = String(v);
35
- // if it's a CSS variable token, wrap with var(...)
37
+ // If the value is a CSS variable, wrap it with var()
36
38
  return s.startsWith('--') ? `var(${s})` : s;
37
39
  };
38
40
 
39
- for (const [cssProp, valOrMap] of Object.entries(properties)) {
41
+ // 1️⃣ Process normal CSS properties
42
+ for (const [cssProp, valOrMap] of Object.entries(props)) {
40
43
  const isMapLike =
41
44
  valOrMap && typeof valOrMap === 'object' && !Array.isArray(valOrMap) && Object.keys(valOrMap).some((k) => BPS.includes(k as BreakpointKey));
42
45
 
43
46
  if (isMapLike) {
47
+ // Responsive map provided
44
48
  const map = valOrMap as BreakpointMap;
45
49
  for (const bp of BPS) {
46
50
  const token = map[bp];
@@ -50,7 +54,7 @@ export function generateResponsiveMedia(properties: Record<string, ResponsiveVal
50
54
  result[media][cssProp] = toCssValue(token);
51
55
  }
52
56
  } else {
53
- // single value => apply to all breakpoints
57
+ // Single value, apply to all breakpoints
54
58
  const token = valOrMap as ResponsiveValue;
55
59
  for (const bp of BPS) {
56
60
  const media = queries[bp as keyof typeof queries];
@@ -60,6 +64,29 @@ export function generateResponsiveMedia(properties: Record<string, ResponsiveVal
60
64
  }
61
65
  }
62
66
 
67
+ // 2️⃣ Process calc() properties if provided
68
+ if (calcProps) {
69
+ for (const { property, base, offset, operator = '+' } of calcProps) {
70
+ for (const bp of BPS) {
71
+ const media = queries[bp as keyof typeof queries];
72
+
73
+ // Safely extract the base value for the current breakpoint
74
+ const baseValue =
75
+ typeof base === 'object' && !Array.isArray(base) ? ((base as BreakpointMap)[bp] ?? Object.values(base as BreakpointMap)[0]) : base;
76
+
77
+ // Safely extract the offset value for the current breakpoint
78
+ const offsetValue =
79
+ typeof offset === 'object' && !Array.isArray(offset)
80
+ ? ((offset as BreakpointMap)[bp] ?? Object.values(offset as BreakpointMap)[0])
81
+ : offset;
82
+
83
+ if (!result[media]) result[media] = {};
84
+ // Build the calc() CSS value
85
+ result[media][property] = `calc(${baseValue} ${operator} ${offsetValue})`;
86
+ }
87
+ }
88
+ }
89
+
63
90
  return result;
64
91
  }
65
92
 
@@ -1,91 +0,0 @@
1
- // utils/generateResponsive.ts
2
- import { queries } from '../styles/mediaqueries';
3
-
4
- // Define the supported breakpoint keys
5
- type BreakpointKey = 'mobile' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
6
-
7
- // A responsive value can be a string, number, or anything with a toString method
8
- type ResponsiveValue = string | number | { toString(): string };
9
-
10
- // Map of breakpoint keys to responsive values
11
- type BreakpointMap = Partial<Record<BreakpointKey, ResponsiveValue>>;
12
-
13
- // Ordered list of breakpoints to iterate over
14
- const BPS: BreakpointKey[] = ['mobile', 'sm', 'md', 'lg', 'xl', '2xl'];
15
-
16
- /**
17
- * Generates a fully responsive CSS object for Vanilla Extract
18
- *
19
- * @param props - normal CSS properties, either a single value or responsive map
20
- * @param calcProps - optional array of calc() rules for dynamic calculations
21
- * @returns an object ready to use under `@media` in Vanilla Extract
22
- */
23
- export function generateResponsive(
24
- props: Record<string, ResponsiveValue | BreakpointMap>,
25
- calcProps?: Array<{
26
- property: string;
27
- base: ResponsiveValue | BreakpointMap;
28
- offset: ResponsiveValue | BreakpointMap;
29
- operator?: string; // + - * / etc.
30
- }>
31
- ): Record<string, Record<string, string>> {
32
- const result: Record<string, Record<string, string>> = {};
33
-
34
- // Helper to convert a value to a proper CSS string
35
- const toCssValue = (v: ResponsiveValue) => {
36
- const s = String(v);
37
- // If the value is a CSS variable, wrap it with var()
38
- return s.startsWith('--') ? `var(${s})` : s;
39
- };
40
-
41
- // 1️⃣ Process normal CSS properties
42
- for (const [cssProp, valOrMap] of Object.entries(props)) {
43
- const isMapLike =
44
- valOrMap && typeof valOrMap === 'object' && !Array.isArray(valOrMap) && Object.keys(valOrMap).some((k) => BPS.includes(k as BreakpointKey));
45
-
46
- if (isMapLike) {
47
- // Responsive map provided
48
- const map = valOrMap as BreakpointMap;
49
- for (const bp of BPS) {
50
- const token = map[bp];
51
- if (token === undefined) continue;
52
- const media = queries[bp as keyof typeof queries];
53
- if (!result[media]) result[media] = {};
54
- result[media][cssProp] = toCssValue(token);
55
- }
56
- } else {
57
- // Single value, apply to all breakpoints
58
- const token = valOrMap as ResponsiveValue;
59
- for (const bp of BPS) {
60
- const media = queries[bp as keyof typeof queries];
61
- if (!result[media]) result[media] = {};
62
- result[media][cssProp] = toCssValue(token);
63
- }
64
- }
65
- }
66
-
67
- // 2️⃣ Process calc() properties if provided
68
- if (calcProps) {
69
- for (const { property, base, offset, operator = '+' } of calcProps) {
70
- for (const bp of BPS) {
71
- const media = queries[bp as keyof typeof queries];
72
-
73
- // Safely extract the base value for the current breakpoint
74
- const baseValue =
75
- typeof base === 'object' && !Array.isArray(base) ? ((base as BreakpointMap)[bp] ?? Object.values(base as BreakpointMap)[0]) : base;
76
-
77
- // Safely extract the offset value for the current breakpoint
78
- const offsetValue =
79
- typeof offset === 'object' && !Array.isArray(offset)
80
- ? ((offset as BreakpointMap)[bp] ?? Object.values(offset as BreakpointMap)[0])
81
- : offset;
82
-
83
- if (!result[media]) result[media] = {};
84
- // Build the calc() CSS value
85
- result[media][property] = `calc(${baseValue} ${operator} ${offsetValue})`;
86
- }
87
- }
88
- }
89
-
90
- return result;
91
- }