Skip to content

Commit

Permalink
✨ feat: 新增全局控制 padding props
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Nov 28, 2021
1 parent 20629c2 commit 7f9ad2e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/asset-gallery/demos/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Demo = () => {
}}
data={images}
darkBackground={'black'}
coverPadding={24}
/>
);
};
Expand Down
9 changes: 5 additions & 4 deletions packages/asset-gallery/demos/YAMLDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { yml } from './yml';

const YAMLDemo = () => {
return (
<div
<AssetGallery
data={yml}
darkBackground={'black'}
coverPadding={24}
style={{
background: '#fafafa',
padding: 24,
}}
>
<AssetGallery data={yml} darkBackground={'black'} />
</div>
/>
);
};

Expand Down
3 changes: 2 additions & 1 deletion packages/asset-gallery/src/AssetGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const AssetGallery: FC<AssetGalleryProps> = ({
defaultColumns,
onColumnsChange,
style,
coverPadding,
}) => {
const [columns, setColumn] = useMergeValue(4, {
value: columnsProps,
Expand Down Expand Up @@ -56,7 +57,7 @@ const AssetGallery: FC<AssetGalleryProps> = ({
return (
<AssetCard
key={index}
padding={padding}
padding={padding || coverPadding}
url={url}
dark={dark}
darkBackground={backgroundColor}
Expand Down
2 changes: 1 addition & 1 deletion packages/asset-gallery/src/components/AssetCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { Asset } from '../types';
import { copySketch } from '../utils/sketch';

const AssetCard: FC<Asset> = ({
padding,
padding = 12,
url,
title,
darkBackground,
Expand Down
1 change: 0 additions & 1 deletion packages/asset-gallery/src/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

&-ctn {
position: relative;
padding: 24px;
}

&-type {
Expand Down
7 changes: 5 additions & 2 deletions packages/asset-gallery/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ export interface AssetGalleryProps {
* @enumOptions [{ label: '显示', value: true }, { label: '隐藏', value: false }]
*/
showSlider?: boolean;

/**
* 样式
* @title 全局图片的内边距
*/
coverPadding?: number | string;
/**
* @title 样式
*/
style?: CSSProperties;
}

1 comment on commit 7f9ad2e

@vercel
Copy link

@vercel vercel bot commented on 7f9ad2e 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.