Skip to content

Commit

Permalink
remove columns prop
Browse files Browse the repository at this point in the history
  • Loading branch information
trishaprile committed Nov 8, 2024
1 parent d0564ea commit 1f56f25
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions components/Columns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ export const Column = ({ children }) => {
)
}

const Columns = ({ children, columns = 2, layout = 'auto'}) => {
const Columns = ({ children, layout = 'auto'}) => {
layout = layout === 'fixed' ? '1fr' : 'auto';
const columnsCount = React.Children.count(children);

return (
<div className="Columns" style={{ gridTemplateColumns: `repeat(${columns}, ${layout})` }}>
<div className="Columns" style={{ gridTemplateColumns: `repeat(${columnsCount}, ${layout})` }}>
{children}
</div>
);
Expand Down
6 changes: 6 additions & 0 deletions components/Columns/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
$iphone-plus: 414px;

.Columns {
display: grid;
gap: var(--md, 20px);

@media (max-width: $iphone-plus) {
grid-template-columns: 1fr !important;
}
}
2 changes: 1 addition & 1 deletion docs/built-in-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

### Columns

<Columns columns={3} layout="auto">
<Columns layout="auto">
<Column>
Neque porro quisquam est qui dolorem ipsum quia
</Column>
Expand Down

0 comments on commit 1f56f25

Please sign in to comment.