-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: created main components to configureation v2
- Loading branch information
1 parent
4c93b91
commit 854a17f
Showing
34 changed files
with
1,370 additions
and
411 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,38 @@ | ||
.foreground { | ||
background: var(--lido-color-foreground); | ||
color: var(--lido-color-text-secondary); | ||
} | ||
|
||
.background { | ||
background: var(--lido-color-background); | ||
color: var(--lido-color-text-secondary); | ||
} | ||
|
||
.accent { | ||
background: var(--lido-color-accent); | ||
color: var(--lido-color-accent-contrast); | ||
} | ||
|
||
.flat { | ||
box-shadow: none; | ||
} | ||
|
||
.shadow { | ||
box-shadow: var(--lido-shadows-lg) var(--lido-color-shadow-light); | ||
} | ||
|
||
.padding { | ||
padding: var(--lido-space-lg); | ||
|
||
@media (--lido-media-breakpoint-up-md) { | ||
padding: var(--lido-space-xxl); | ||
} | ||
} | ||
|
||
.block { | ||
font-weight: 400; | ||
font-size: var(--lido-font-size-xxs); | ||
line-height: 1.6em; | ||
border-radius: var(--lido-border-radius-xl); | ||
margin: 0; | ||
} |
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,28 @@ | ||
import { StoryFn, Meta } from '@storybook/react' | ||
import { Block, BlockProps, BlockColor, BlockVariant } from '.' | ||
|
||
const getOptions = (enumObject: Record<string, string | number>) => | ||
Object.values(enumObject).filter((value) => typeof value === 'string') | ||
|
||
export default { | ||
component: Block, | ||
title: 'Layout/Block', | ||
args: { | ||
children: 'Example content', | ||
variant: 'flat', | ||
color: 'foreground', | ||
paddingLess: false, | ||
}, | ||
argTypes: { | ||
variant: { | ||
options: getOptions(BlockVariant), | ||
control: 'inline-radio', | ||
}, | ||
color: { | ||
options: getOptions(BlockColor), | ||
control: 'inline-radio', | ||
}, | ||
}, | ||
} satisfies Meta | ||
|
||
export const Basic: StoryFn<BlockProps> = (props) => <Block {...props} /> |
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,51 @@ | ||
import { ComponentPropsWithoutRef, ForwardedRef, forwardRef } from 'react' | ||
import cn from 'classnames' | ||
import styles from './block.module.css' | ||
|
||
export enum BlockVariant { | ||
flat, | ||
shadow, | ||
} | ||
export type BlockVariants = keyof typeof BlockVariant | ||
|
||
export enum BlockColor { | ||
foreground, | ||
background, | ||
accent, | ||
} | ||
export type BlockColors = keyof typeof BlockColor | ||
|
||
export type BlockProps = ComponentPropsWithoutRef<'div'> & { | ||
color?: BlockColors | ||
variant?: BlockVariants | ||
paddingLess?: boolean | ||
} | ||
|
||
export const Block = forwardRef( | ||
( | ||
{ | ||
color = 'foreground', | ||
variant = 'flat', | ||
paddingLess = false, | ||
className, | ||
...rest | ||
}: BlockProps, | ||
ref?: ForwardedRef<HTMLDivElement>, | ||
) => { | ||
return ( | ||
<div | ||
className={cn(styles.block, className, { | ||
[styles.foreground]: color === 'foreground', | ||
[styles.background]: color === 'background', | ||
[styles.accent]: color === 'accent', | ||
[styles.flat]: variant === 'flat', | ||
[styles.shadow]: variant === 'shadow', | ||
[styles.padding]: !paddingLess, | ||
})} | ||
{...rest} | ||
ref={ref} | ||
/> | ||
) | ||
}, | ||
) | ||
Block.displayName = 'Block' | ||
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 @@ | ||
export * from './block' | ||
Check failure on line 1 in packages/block/index.ts
|
Oops, something went wrong.