Skip to content

Commit

Permalink
refactor(design-system): update grid variants to use string literals (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gwansikk committed May 12, 2024
1 parent 0fef7f9 commit 58ca686
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
24 changes: 12 additions & 12 deletions packages/design-system/src/Grid/Grid.styles.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { cva } from 'class-variance-authority';

export const gridVariants = cva('gird', {
export const gridVariants = cva('grid', {
variants: {
col: {
1: 'grid-cols-1',
2: 'grid-cols-2',
3: 'grid-cols-3',
4: 'grid-cols-4',
5: 'grid-cols-5',
6: 'grid-cols-6',
7: 'grid-cols-7',
8: 'grid-cols-8',
9: 'grid-cols-9',
10: 'grid-cols-10',
'1': 'grid-cols-1',
'2': 'grid-cols-2',
'3': 'grid-cols-3',
'4': 'grid-cols-4',
'5': 'grid-cols-5',
'6': 'grid-cols-6',
'7': 'grid-cols-7',
'8': 'grid-cols-8',
'9': 'grid-cols-9',
'10': 'grid-cols-10',
},
gap: {
none: 'gap-0',
Expand All @@ -22,7 +22,7 @@ export const gridVariants = cva('gird', {
},
},
defaultVariants: {
col: 1,
col: '1',
gap: 'none',
},
});
12 changes: 6 additions & 6 deletions packages/design-system/src/Grid/Grid.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { type HTMLAttributes, forwardRef } from 'react';

import { type VariantProps } from 'class-variance-authority';

import { cn } from '../utils';
import { gridVariants } from './Grid.styles';
import { GridColVariant, GridGapVariant } from './Grid.types';
import type {
GridColVariant,
GridGapVariant,
GridVariantProps,
} from './Grid.types';

interface GridProps
extends HTMLAttributes<HTMLDivElement>,
VariantProps<typeof gridVariants> {
interface GridProps extends HTMLAttributes<HTMLDivElement>, GridVariantProps {
col?: GridColVariant;
gap?: GridGapVariant;
}
Expand Down
17 changes: 16 additions & 1 deletion packages/design-system/src/Grid/Grid.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import { type VariantProps } from 'class-variance-authority';

import type { DesignSystemSizeVariant } from '../types';
import { gridVariants } from './Grid.styles';

export type GridVariantProps = VariantProps<typeof gridVariants>;

export type GridColVariant = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
export type GridColVariant =
| '1'
| '2'
| '3'
| '4'
| '5'
| '6'
| '7'
| '8'
| '9'
| '10';
export type GridGapVariant = DesignSystemSizeVariant<'none'>;

0 comments on commit 58ca686

Please sign in to comment.