Skip to content

Commit

Permalink
✨ feat: 新增 default Props
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Nov 28, 2021
1 parent cca4137 commit e674058
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/asset-gallery/src/AssetGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ const AssetGallery: FC<AssetGalleryProps> = ({
data,
darkBackground,
layout: layoutProps,
defaultLayout,
logo,
showSlider = true,
onLayoutChange,
columns: columnsProps,
defaultColumns,
onColumnsChange,
style,
}) => {
const [columns, setColumn] = useMergeValue(4, {
value: columnsProps,
defaultValue: defaultColumns,
onChange: onColumnsChange,
});
const [layout, setLayout] = useMergeValue('masonry', {
value: layoutProps,
defaultValue: defaultLayout,
onChange: onLayoutChange,
});

Expand Down
9 changes: 5 additions & 4 deletions packages/asset-gallery/src/asset-gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,25 @@ nav:
### 使用 JSON

组件库的 Logo 物料
<code src='./demos/Demo.tsx' />

<code src='../demos/Demo.tsx' />

### 使用 YML

`v2.0.0` 开始支持使用 YAML 语法

<code src='./demos/YAMLDemo.tsx' />
<code src='../demos/YAMLDemo.tsx' />

### Png 图片

图片源为 Png

<code src='./demos/PngDemo.tsx' />
<code src='../demos/PngDemo.tsx' />

## Sketch 素材

复制 Sketch 文件, 使用 [sketch-json](https://github.com/arvinxx/sketch-json) 粘贴到 sketch 中

<code src='./demos/SketchDemo.tsx' />
<code src='../demos/SketchDemo.tsx' />

<API src='./index.tsx'></API>
12 changes: 12 additions & 0 deletions packages/asset-gallery/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ export interface AssetGalleryProps {
* @default grid
*/
layout?: LayoutType;
/**
* @title 布局方式
* @enum ['grid','masonry']
* @enumOptions [{ label: '网格', value: 'grid' }, { label: '瀑布流', value: 'masonry' }]
* @default grid
*/
defaultLayout?: LayoutType;
/**
* 布局切换时的回调
* @ignore
Expand All @@ -87,6 +94,11 @@ export interface AssetGalleryProps {
* @default 1
*/
columns?: number;
/**
* @title 初始列数
* @default 1
*/
defaultColumns?: number;
/**
* 列数改变时的回调
* @param columns
Expand Down

1 comment on commit e674058

@vercel
Copy link

@vercel vercel bot commented on e674058 Nov 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.