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

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.322",
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
  },
@@ -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
- }