@latte-macchiat-io/latte-vanilla-components 0.0.219 → 0.0.221

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.219",
3
+ "version": "0.0.221",
4
4
  "description": "Beautiful components for amazing projects, with a touch of Vanilla 🥤",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -1,28 +1,21 @@
1
1
  import { clsx } from 'clsx';
2
2
 
3
- import { columnItem, columnsRecipe, ColumnsVariants } from './styles.css';
3
+ import { columnsRecipe, ColumnsVariants } from './styles.css';
4
4
 
5
5
  export type ColumnsProps = React.HTMLAttributes<HTMLDivElement> &
6
6
  ColumnsVariants & {
7
- columns: number[];
7
+ columns: number[]; // ex: [50, 50] ou [25, 75]
8
8
  children: React.ReactNode;
9
9
  };
10
10
 
11
11
  export const Columns = ({ align, vAlign, columns, children, className }: ColumnsProps) => {
12
12
  return (
13
- <div className={clsx(columnsRecipe({ align, vAlign }), className)}>
14
- {Array.isArray(children) &&
15
- children.map((child, index) => (
16
- <div
17
- key={index}
18
- className={columnItem}
19
- style={{
20
- flex: columns[index],
21
- maxWidth: `${columns[index]}%`,
22
- }}>
23
- {child}
24
- </div>
25
- ))}
13
+ <div
14
+ className={clsx(columnsRecipe({ align, vAlign }), className)}
15
+ style={{
16
+ gridTemplateColumns: columns.map((c) => `${c}%`).join(' '), // ex: "50% 50%"
17
+ }}>
18
+ {children}
26
19
  </div>
27
20
  );
28
21
  };
@@ -0,0 +1,34 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import React from 'react';
3
+
4
+ import { Columns } from '.';
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
7
+ const meta: Meta<typeof Columns> = {
8
+ title: 'Latte Components / 1. Global / Columns',
9
+ component: Columns,
10
+ parameters: {
11
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
+ layout: 'centered',
13
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ['autodocs'],
16
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
+ argTypes: {},
18
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
19
+ };
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
25
+ export const Default: Story = {
26
+ args: {
27
+ children: (
28
+ <>
29
+ <div>Col 1</div>
30
+ <div>Col 2</div>
31
+ </>
32
+ ),
33
+ },
34
+ };
@@ -1,4 +1,3 @@
1
- import { style } from '@vanilla-extract/css';
2
1
  import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
3
2
  import { queries } from '../../styles/mediaqueries';
4
3
  import { themeContract } from '../../theme/contract.css';
@@ -7,10 +6,9 @@ import { generateResponsiveMedia } from '../../utils/generateResponsiveMedia';
7
6
  export const columnsRecipe = recipe({
8
7
  base: [
9
8
  {
9
+ display: 'grid',
10
10
  width: '100%',
11
- display: 'flex',
12
- flexWrap: 'wrap',
13
- flexDirection: 'column',
11
+ gridTemplateColumns: '1fr', // Mobile : une seule colonne
14
12
 
15
13
  '@media': {
16
14
  ...generateResponsiveMedia({
@@ -18,7 +16,7 @@ export const columnsRecipe = recipe({
18
16
  }),
19
17
 
20
18
  [queries.sm]: {
21
- flexDirection: 'row',
19
+ gridAutoFlow: 'row',
22
20
  },
23
21
  },
24
22
  },
@@ -26,29 +24,14 @@ export const columnsRecipe = recipe({
26
24
 
27
25
  variants: {
28
26
  align: {
29
- left: {
30
- textAlign: 'left',
31
- },
32
- center: {
33
- textAlign: 'center',
34
- },
35
- right: {
36
- textAlign: 'right',
37
- },
27
+ left: { textAlign: 'left' },
28
+ center: { textAlign: 'center' },
29
+ right: { textAlign: 'right' },
38
30
  },
39
31
  vAlign: {
40
- top: {
41
- alignItems: 'flex-start',
42
- justifyContent: 'flex-start',
43
- },
44
- center: {
45
- alignItems: 'center',
46
- justifyContent: 'center',
47
- },
48
- bottom: {
49
- alignItems: 'flex-end',
50
- justifyContent: 'flex-end',
51
- },
32
+ top: { alignItems: 'start' },
33
+ center: { alignItems: 'center' },
34
+ bottom: { alignItems: 'end' },
52
35
  },
53
36
  },
54
37
 
@@ -57,16 +40,4 @@ export const columnsRecipe = recipe({
57
40
  },
58
41
  });
59
42
 
60
- export const columnItem = style({
61
- minWidth: 0,
62
- flex: '0 0 100%',
63
- position: 'relative',
64
-
65
- '@media': {
66
- [queries.md]: {
67
- flex: 'unset',
68
- },
69
- },
70
- });
71
-
72
43
  export type ColumnsVariants = RecipeVariants<typeof columnsRecipe>;