-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(project): add card grid component
- Loading branch information
1 parent
6cad244
commit ca52c6b
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.cardGrid { | ||
display: grid; | ||
grid-gap: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import CardGrid from './CardGrid'; | ||
|
||
describe('<CardGrid>', () => { | ||
it('renders card grid and children', () => { | ||
const { getByText } = render((<CardGrid>aa</CardGrid>)); | ||
const cardGrid = getByText(/aa/i); | ||
expect(document.body.contains(cardGrid)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
|
||
import useBreakpoint from '../../hooks/useBreakpoint'; | ||
|
||
import styles from './CardGrid.module.scss'; | ||
|
||
// TEMP DATA | ||
const cols = { "xs": 2, "sm": 3, "md": 4, "lg": 5, "xl": 6 } | ||
|
||
type CardGridProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
function CardGrid({ | ||
children, | ||
}: CardGridProps) { | ||
const breakpoint = useBreakpoint(); | ||
|
||
return ( | ||
<div | ||
className={styles.cardGrid} | ||
style={{ gridTemplateColumns: `repeat(${cols[breakpoint]}, minmax(0,1fr))` }} | ||
> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
export default CardGrid; |