-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add variant options with new colors (#2121)
In this PR I've updated the divider to support the new colors and have the options to choose which one to use. Different colors are being used when using the new variant prop.
- Loading branch information
Showing
4 changed files
with
70 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@kadena/react-ui": minor | ||
--- | ||
|
||
Added a new variant to apply different colors to the Divider component |
44 changes: 32 additions & 12 deletions
44
packages/libs/react-ui/src/components/Divider/Divider.css.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
import { recipe } from '@vanilla-extract/recipes'; | ||
import { token } from '../../styles'; | ||
import { atoms } from '../../styles/atoms.css'; | ||
import { tokens } from '../../styles/index'; | ||
|
||
export const dividerClass = style([ | ||
atoms({ | ||
width: '100%', | ||
marginBlock: 'lg', | ||
border: 'none', | ||
}), | ||
{ | ||
backgroundColor: tokens.kda.foundation.color.border.base.bold, | ||
height: tokens.kda.foundation.border.width.hairline, | ||
export const dividerClass = recipe({ | ||
base: [ | ||
atoms({ | ||
width: '100%', | ||
marginBlock: 'lg', | ||
border: 'none', | ||
}), | ||
{ | ||
height: token('border.width.hairline'), | ||
}, | ||
], | ||
variants: { | ||
variant: { | ||
subtle: { | ||
backgroundColor: token('color.border.base.subtle'), | ||
}, | ||
base: { | ||
backgroundColor: token('color.border.base.default'), | ||
}, | ||
bold: { | ||
backgroundColor: token('color.border.base.bold'), | ||
}, | ||
boldest: { | ||
backgroundColor: token('color.border.base.boldest'), | ||
}, | ||
highContrast: { | ||
backgroundColor: token('color.border.base.high-contrast'), | ||
}, | ||
}, | ||
}, | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
import type { RecipeVariants } from '@vanilla-extract/recipes'; | ||
import cn from 'classnames'; | ||
import type { ComponentPropsWithRef, FC } from 'react'; | ||
import React from 'react'; | ||
import { useSeparator } from 'react-aria'; | ||
import { dividerClass } from './Divider.css'; | ||
|
||
export interface IDividerProps extends ComponentPropsWithRef<'hr'> {} | ||
type Variants = NonNullable<RecipeVariants<typeof dividerClass>>; | ||
|
||
export const Divider: FC<IDividerProps> = ({ className, ...props }) => { | ||
export interface IDividerProps extends ComponentPropsWithRef<'hr'> { | ||
variant?: Variants['variant']; | ||
} | ||
|
||
export const Divider: FC<IDividerProps> = ({ | ||
className, | ||
variant = 'base', | ||
...props | ||
}) => { | ||
const { separatorProps } = useSeparator({ | ||
...props, | ||
elementType: 'hr', | ||
orientation: 'horizontal', | ||
}); | ||
return <hr className={cn(dividerClass, className)} {...separatorProps} />; | ||
|
||
return ( | ||
<hr | ||
className={cn(dividerClass({ variant }), className)} | ||
{...separatorProps} | ||
/> | ||
); | ||
}; |