-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8461f8b
commit d4cb9b8
Showing
6 changed files
with
61 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createVar, style } from '@vanilla-extract/css'; | ||
|
||
export const sizeVar = createVar(); | ||
export const directionVar = createVar(); | ||
|
||
export const spacingStyle = style({ | ||
display: 'flex', | ||
flexDirection: directionVar, | ||
width: sizeVar, | ||
height: sizeVar, | ||
}); |
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,37 @@ | ||
import { FC } from 'react'; | ||
import { tokens } from '@repo/theme'; | ||
import { directionVar, sizeVar, spacingStyle } from './Spacing.css'; | ||
import { assignInlineVars } from '@vanilla-extract/dynamic'; | ||
|
||
interface SpacingProps extends React.HTMLAttributes<HTMLDivElement> { | ||
direction?: 'row' | 'column'; | ||
size: keyof typeof tokens.spacing; | ||
} | ||
|
||
export const Spacing: FC<SpacingProps> = ({ | ||
direction = 'column', | ||
size, | ||
...rest | ||
}: SpacingProps) => { | ||
const sizeValue = | ||
direction === 'row' | ||
? tokens.spacing[size] | ||
: direction === 'column' | ||
? tokens.spacing[size] | ||
: 'auto'; | ||
|
||
return ( | ||
<div | ||
className={spacingStyle} | ||
style={JSON.parse( | ||
JSON.stringify( | ||
assignInlineVars({ | ||
[directionVar]: direction, | ||
[sizeVar]: sizeValue, | ||
}) | ||
) | ||
)} | ||
{...rest} | ||
/> | ||
); | ||
}; |
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 +1 @@ | ||
//export * from './TestComponent'; | ||
export * from './Spacing/Spacing'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.