Skip to content

Commit

Permalink
fix: update columns (#1030)
Browse files Browse the repository at this point in the history
[![PR App][icn]][demo] | Fix RM-11030
:-------------------:|:----------:

## 🧰 Changes
- Remove columns prop (calculate number of child elements instead)
- Add media query for responsiveness

## 🧬 QA & Testing

- [Broken on production][prod].
- [Working in this PR app][demo].


[demo]: https://markdown-pr-PR_NUMBER.herokuapp.com
[prod]: https://SUBDOMAIN.readme.io
[icn]:
https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg
  • Loading branch information
trishaprile authored Nov 9, 2024
1 parent d0564ea commit c33dc82
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 c33dc82

Please sign in to comment.