Skip to content

Commit

Permalink
✨ feat: add create classname variant function #38
Browse files Browse the repository at this point in the history
  • Loading branch information
yondo123 committed Apr 7, 2023
1 parent 206d67d commit f529173
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
5 changes: 0 additions & 5 deletions packages/theme/index.ts

This file was deleted.

10 changes: 10 additions & 0 deletions packages/theme/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**types */
export * from './types/color';
export * from './types/spacings';
export * from './types/classVariants';
/**token constants */
export * from './token/colors';
export * from './token/spacings';
/**utils */
export * from './utils/getColorbyToken';
export * from './utils/createClassVariant';
37 changes: 37 additions & 0 deletions packages/theme/src/types/classVariants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export type JDesignSystemComponent =
| 'box'
| 'checkbox'
| 'flex'
| 'modal'
| 'tabs'
| 'tooltip'
| 'button'
| 'drawer'
| 'select'
| 'popover'
| 'textarea'
| 'card'
| 'dopdown'
| 'input'
| 'radio'
| 'stack';

export type JDesignSystemElementRoles =
| 'overlay'
| 'wrapper'
| 'content'
| 'lavel'
| 'ul'
| 'ol'
| 'item'
| 'footer'
| 'header'
| 'trigger'
| 'message'
| 'article'
| 'button'
| 'input';

export type CssVariant =
| `j-${JDesignSystemComponent}__${string}-${JDesignSystemElementRoles}`
| `j-${JDesignSystemComponent}__${JDesignSystemElementRoles}`;
9 changes: 9 additions & 0 deletions packages/theme/src/utils/createClassVariant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { JDesignSystemComponent, JDesignSystemElementRoles, CssVariant } from '../types/classVariants';

export const createClassVariant = (
component: JDesignSystemComponent,
element: JDesignSystemElementRoles,
modifier?: string
): CssVariant => {
return modifier ? `j-${component}__${modifier}-${element}` : `j-${component}__${element}`;
};

0 comments on commit f529173

Please sign in to comment.