@latte-macchiat-io/latte-vanilla-components 0.0.321 → 0.0.323

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.321",
3
+ "version": "0.0.323",
4
4
  "description": "Beautiful components for amazing projects, with a touch of Vanilla 🥤",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -5,8 +5,8 @@ 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 { combineResponsive } from '../../utils/combineResponsive';
9
8
  import { generateResponsiveMedia } from '../../utils/generateResponsiveMedia';
9
+ import { generateResponsiveMediaCalc } from '../../utils/generateResponsiveMediaCalc';
10
10
 
11
11
  export const carouselRecipe = recipe(
12
12
  {
@@ -120,33 +120,14 @@ export const carouselNav = recipe(
120
120
 
121
121
  navPositionVertical: {
122
122
  top: {
123
- '@media': {
124
- [queries.mobile]: {
125
- bottom: `calc(100% + ${themeContract.carousel.nav.positionVerticalOffset.mobile})`,
126
- },
127
- [queries.sm]: {
128
- bottom: `calc(100% + ${themeContract.carousel.nav.positionVerticalOffset.sm})`,
129
- },
130
- [queries.md]: {
131
- bottom: `calc(100% + ${themeContract.carousel.nav.positionVerticalOffset.md})`,
132
- },
133
- [queries.lg]: {
134
- bottom: `calc(100% + ${themeContract.carousel.nav.positionVerticalOffset.lg})`,
135
- },
136
- [queries.xl]: {
137
- bottom: `calc(100% + ${themeContract.carousel.nav.positionVerticalOffset.xl})`,
138
- },
139
- [queries['2xl']]: {
140
- bottom: `calc(100% + ${themeContract.carousel.nav.positionVerticalOffset['2xl']})`,
141
- },
142
- },
123
+ '@media': generateResponsiveMediaCalc('bottom', '100%', themeContract.carousel.nav.positionVerticalOffset, '+'),
143
124
  },
144
125
  center: {
145
126
  top: '50%',
146
127
  transform: 'translate(0%, -50%)',
147
128
  },
148
129
  bottom: {
149
- top: '100%',
130
+ '@media': generateResponsiveMediaCalc('top', '100%', themeContract.carousel.nav.positionVerticalOffset, '+'),
150
131
  },
151
132
  },
152
133
  },
@@ -207,8 +188,7 @@ export const carouselBullets = style({
207
188
  ...generateResponsiveMedia({
208
189
  gap: themeContract.carousel.bullet.gap,
209
190
  }),
210
-
211
- [queries.lg]: {},
191
+ ...generateResponsiveMediaCalc('top', '100%', themeContract.carousel.bullet.positionVerticalOffset, '+'),
212
192
  },
213
193
  });
214
194
 
@@ -37,6 +37,14 @@ const themeCarouselBase = {
37
37
  },
38
38
  bullet: {
39
39
  borderRadius: '1000px',
40
+ positionVerticalOffset: {
41
+ mobile: '15',
42
+ sm: '15',
43
+ md: '30',
44
+ lg: '30',
45
+ xl: '50',
46
+ '2xl': '50',
47
+ },
40
48
  bottom: {
41
49
  mobile: '15px',
42
50
  sm: '15px',
@@ -851,6 +851,14 @@ export const themeContract = createGlobalThemeContract({
851
851
  borderRadius: 'latte-carousel-bullet-borderRadius',
852
852
  backgroundColor: 'latte-carousel-bullet-backgroundColor',
853
853
  activeBackgroundColor: 'latte-carousel-bullet-active-backgroundColor',
854
+ positionVerticalOffset: {
855
+ mobile: 'latte-carousel-nav-positionVerticalOffset-mobile',
856
+ sm: 'latte-carousel-nav-positionVerticalOffset-sm',
857
+ md: 'latte-carousel-nav-positionVerticalOffset-md',
858
+ lg: 'latte-carousel-nav-positionVerticalOffset-lg',
859
+ xl: 'latte-carousel-nav-positionVerticalOffset-xl',
860
+ '2xl': 'latte-carousel-nav-positionVerticalOffset-2xl',
861
+ },
854
862
 
855
863
  gap: {
856
864
  mobile: 'latte-carousel-bullet-gap-mobile',
@@ -0,0 +1,32 @@
1
+ import { queries } from '../styles/mediaqueries';
2
+
3
+ /**
4
+ * Génère un objet @media pour Vanilla Extract avec des valeurs calculées (calc)
5
+ * Supporte les valeurs responsive issues du thème pour les deux opérandes.
6
+ *
7
+ * @param property - la propriété CSS (ex: 'top', 'bottom', 'marginTop'…)
8
+ * @param baseValue - soit une string, soit un objet responsive (themeContract.*)
9
+ * @param offsetValues - un objet responsive avec des offsets (ex: themeContract.carousel.nav.positionVerticalOffset)
10
+ * @param operator - opérateur de calcul ('+' ou '-') [par défaut '+']
11
+ * @returns Un objet directement utilisable dans `@media`
12
+ */
13
+ export function generateResponsiveMediaCalc(
14
+ property: string,
15
+ baseValue: string | Record<string, string>,
16
+ offsetValues: Record<string, string>,
17
+ operator: string = '+'
18
+ ) {
19
+ const result: Record<string, Record<string, string>> = {};
20
+
21
+ for (const [bp, query] of Object.entries(queries)) {
22
+ const base = typeof baseValue === 'string' ? baseValue : (baseValue[bp] ?? Object.values(baseValue)[0]); // fallback pour mobile
23
+ const offset = offsetValues[bp];
24
+ if (offset) {
25
+ result[query] = {
26
+ [property]: `calc(${base} ${operator} ${offset})`,
27
+ };
28
+ }
29
+ }
30
+
31
+ return result;
32
+ }
@@ -1,9 +0,0 @@
1
- export function combineResponsive(obj1: Record<string, string>, obj2: Record<string, string>, operator: string = '+'): Record<string, string> {
2
- const result: Record<string, string> = {};
3
- for (const bp in obj1) {
4
- if (obj2[bp]) {
5
- result[bp] = `calc(${obj1[bp]} ${operator} ${obj2[bp]})`;
6
- }
7
- }
8
- return result;
9
- }