Skip to content

Commit

Permalink
🐛 fix: 修正 grid 布局问题
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Feb 2, 2022
1 parent 8434793 commit a80939d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
9 changes: 3 additions & 6 deletions packages/asset-gallery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@
},
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@bedrock-layout/columns": "^2.1.11",
"@bedrock-layout/inline": "^2.0.15",
"@bedrock-layout/masonry-grid": "^2.0.14",
"antd": "^4.14.0",
"antd": "^4.18.5",
"copy-to-clipboard": "^3.3.1",
"classnames": "^2.3.1",
"js-yaml": "^4.1.0",
"use-merge-value": "^1.0.2",
"styled-components": "^5.3.0"
"use-merge-value": "^1.0.2"
}
}
22 changes: 13 additions & 9 deletions packages/asset-gallery/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { FC } from 'react';
import React from 'react';
import { Columns } from '@bedrock-layout/columns';
import cls from 'classnames';

import Header from './Header';

import type { AssetGalleryProps } from '../types';
Expand Down Expand Up @@ -36,18 +37,21 @@ const Layout: FC<LayoutProps> = ({
onLayoutChange={onLayoutChange}
showSlider={showSlider}
/>
{layout === 'grid' ? (
<Columns gutter={''} columns={columns}>
{children}
</Columns>
) : (
{
<div
className={'avx-asset-gallery-container avx-asset-gallery-masonry'}
style={{ columnCount: columns }}
className={cls(
'avx-asset-gallery-container',
`avx-asset-gallery-${layout}`,
)}
style={{
columnCount: layout === 'masonry' ? columns : undefined,
gridTemplateColumns:
layout === 'grid' ? `repeat(${columns}, 1fr)` : undefined,
}}
>
{children}
</div>
)}
}
</div>
);
};
Expand Down
4 changes: 4 additions & 0 deletions packages/asset-gallery/src/style.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.avx-asset-gallery {
&-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
&-masonry {
column-count: 4;
column-gap: 0;
Expand Down

0 comments on commit a80939d

Please sign in to comment.