-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
5 changed files
with
126 additions
and
0 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,25 @@ | ||
import { StoryBook, useControls, useCreateStore } from '@lobehub/ui'; | ||
import { CollapseGroup, CollapseGroupProps } from '@yuntijs/ui'; | ||
import { VariableIcon } from 'lucide-react'; | ||
|
||
export default () => { | ||
const store = useCreateStore(); | ||
const control: CollapseGroupProps | any = useControls( | ||
{ | ||
title: '输出变量', | ||
defaultActive: true, | ||
variant: { | ||
options: ['default', 'block', 'ghost', 'pure'], | ||
value: 'default', | ||
}, | ||
}, | ||
{ store } | ||
); | ||
return ( | ||
<StoryBook levaStore={store} style={{ width: '100%' }}> | ||
<CollapseGroup icon={VariableIcon} style={{ width: '100%' }} {...control}> | ||
我是收起来的内容 | ||
</CollapseGroup> | ||
</StoryBook> | ||
); | ||
}; |
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,10 @@ | ||
import { CollapseGroup } from '@yuntijs/ui'; | ||
import { VariableIcon } from 'lucide-react'; | ||
|
||
export default () => { | ||
return ( | ||
<CollapseGroup icon={VariableIcon} style={{ width: '100%' }} title="输出变量"> | ||
我是收起来的内容 | ||
</CollapseGroup> | ||
); | ||
}; |
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,32 @@ | ||
--- | ||
nav: Components | ||
group: Data Display | ||
title: CollapseGroup | ||
--- | ||
|
||
## Usage | ||
|
||
Based on [lobehub ui FormGroup](https://github.com/lobehub/lobe-ui/blob/master/src/Form/components/FormGroup.tsx). | ||
|
||
```tsx | pure | ||
import { CollapseGroup } from '@yuntijs/ui'; | ||
import { VariableIcon } from 'lucide-react'; | ||
|
||
export default () => { | ||
return ( | ||
<CollapseGroup icon={VariableIcon} title="输出变量"> | ||
我是收起来的内容 | ||
</CollapseGroup> | ||
); | ||
}; | ||
``` | ||
|
||
<code src="./demos/index.tsx" center></code> | ||
|
||
## Playground | ||
|
||
<code src="./demos/Playground.tsx" center></code> | ||
|
||
## APIs | ||
|
||
<API></API> |
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 { FormGroupProps, Form as LobeForm } from '@lobehub/ui'; | ||
import React from 'react'; | ||
|
||
import { useStyles } from './style'; | ||
|
||
const FormGroup = LobeForm.Group; | ||
|
||
export type CollapseGroupProps = Omit< | ||
FormGroupProps, | ||
'items' | 'activeKey' | 'defaultActiveKey' | 'accordion' | 'expandIconPosition' | ||
>; | ||
|
||
export const CollapseGroup: React.FC<CollapseGroupProps> = ({ | ||
className, | ||
variant, | ||
...otherProps | ||
}) => { | ||
const { styles, cx } = useStyles(); | ||
|
||
return ( | ||
<FormGroup | ||
className={cx(styles.root, className)} | ||
collapsible={variant === 'pure' ? 'icon' : 'header'} | ||
variant={variant} | ||
{...otherProps} | ||
/> | ||
); | ||
}; |
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,31 @@ | ||
import { createStyles } from 'antd-style'; | ||
|
||
export const useStyles = createStyles(({ css, token, prefixCls }) => { | ||
return { | ||
root: css` | ||
margin-bottom: ${token.margin}px; | ||
.${prefixCls}-collapse { | ||
&-header { | ||
padding: 0 !important; | ||
&-text { | ||
padding: ${token.paddingSM}px ${token.paddingSM}px ${token.paddingSM}px 0; | ||
& > * { | ||
font-size: ${token.fontSize}px; | ||
/* font-weight: unset; */ | ||
} | ||
} | ||
} | ||
&-expand-icon { | ||
padding: ${token.padding}px 0 ${token.padding}px ${token.paddingSM}px; | ||
} | ||
&-extra { | ||
padding-right: ${token.paddingSM}px; | ||
} | ||
&-content { | ||
padding: ${token.paddingXS}px 0; | ||
background-color: ${token.colorBgContainer}; | ||
} | ||
} | ||
`, | ||
}; | ||
}); |