-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(grid): add container component (#128)
* fix(grid): remove container styles from grid column * feat(grid): draft changes for the grid container * docs(container): adds container to grid on storybook * test(grid): add test for container component * test: update screenshots * refactor(grid): make Container consistent with other components and remove dataTestId * refactor(grid): use consistent types and comments for the Component props * refactor(grid): use const assertion for Grid * refactor(grid): remove dataTestId and revert Component types * feat(grid): introduce TS support with generics to grid Strongly type polymorphic grid components — column, row and container which enables TypeScript help while creating a new component BREAKING CHANGE: `Component` prop is renamed as `component` for grid Row, Column and Container * docs(grid): add default value in docs * feat: adjust row widths * revert(grid): remove nested grid styles * test: update screenshot tests * chore: run npm install Co-authored-by: mwagdi <mahmoud.elawadi@hey.car>
- Loading branch information
1 parent
eca5c2f
commit 9eb07f3
Showing
81 changed files
with
195 additions
and
77 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
+3 Bytes
(100%)
...on/src/__tests__/__image_snapshots__/Button colors size=large sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4 Bytes
(100%)
...tton/src/__tests__/__image_snapshots__/Button colors size=large sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...rc/__tests__/__image_snapshots__/Button events tests Button click test-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2 Bytes
(100%)
...c/__tests__/__image_snapshots__/Button events tests Button hover event-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3 Bytes
(100%)
...c/__tests__/__image_snapshots__/Button sizes variant=outlined sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4 Bytes
(100%)
...src/__tests__/__image_snapshots__/Button sizes variant=outlined sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3 Bytes
(100%)
.../src/__tests__/__image_snapshots__/Button variants size=large sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
.../src/__tests__/__image_snapshots__/Button variants size=large sprite-3-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4 Bytes
(100%)
...on/src/__tests__/__image_snapshots__/Button variants size=large sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
..._tests__/__image_snapshots__/Whatsapp button colors size=middle sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip Component sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip Component sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip children sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip children sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
...ages/chip/src/__tests__/__image_snapshots__/Chip data-test-id sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip data-test-id sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip disabled sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip disabled sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip leftIcon sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip leftIcon sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-7 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip selected sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip selected sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip variants sprite-2-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
packages/chip/src/__tests__/__image_snapshots__/Chip variants sprite-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...src/__tests__/__image_snapshots__/Dropdown tests Dropdown default test-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...c/__tests__/__image_snapshots__/Dropdown tests Dropdown disabled event-snap.png
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,13 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import { FC } from 'react'; | ||
|
||
import Col from './components/Col'; | ||
import { ColProps } from './components/Col.types'; | ||
import Container from './components/Container'; | ||
import Row from './components/Row'; | ||
import { RowProps } from './components/Row.types'; | ||
|
||
const Grid: { | ||
Row: FC<RowProps>; | ||
Col: FC<ColProps>; | ||
displayName: string; | ||
} = { | ||
const Grid = { | ||
Row, | ||
Col, | ||
Container, | ||
displayName: 'Grid', | ||
}; | ||
} as const; | ||
|
||
export default Grid; |
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
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,22 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import Container from '../components/Container'; | ||
|
||
describe('Grid.Container', () => { | ||
describe('Snapshots tests', () => { | ||
it('should match snapshot', () => { | ||
const { container } = render(<Container>content</Container>); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
it('should set tag correctly', () => { | ||
const { getByText } = render( | ||
<Container component="section">hey</Container>, | ||
); | ||
|
||
expect(getByText('hey').tagName).toBe('SECTION'); | ||
}); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
packages/grid/src/__tests__/__snapshots__/Container.test.tsx.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Grid.Container Snapshots tests should match snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="container" | ||
> | ||
content | ||
</div> | ||
</div> | ||
`; |
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
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
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
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,38 @@ | ||
@import '../../../themes/src/default.css'; | ||
|
||
.container { | ||
width: 100%; | ||
margin: 0 auto; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
padding-left: var(--gap-l); | ||
padding-right: var(--gap-l); | ||
|
||
@media (--tablet) { | ||
padding-right: var(--gap-xl); | ||
padding-left: var(--gap-xl); | ||
} | ||
|
||
@media (--tablet-l) { | ||
padding-right: var(--gap-3xl); | ||
padding-left: var(--gap-3xl); | ||
} | ||
|
||
@media (--desktop) { | ||
padding-right: var(--gap-3xl); | ||
padding-left: var(--gap-3xl); | ||
} | ||
|
||
@media (--desktop-m) { | ||
padding-right: var(--gap-3xl); | ||
padding-left: var(--gap-3xl); | ||
} | ||
|
||
@media (--desktop-l) { | ||
max-width: 1440px; | ||
padding-right: var(--gap-9xl); | ||
padding-left: var(--gap-9xl); | ||
} | ||
} |
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,26 @@ | ||
import React from 'react'; | ||
import cn from 'classnames'; | ||
|
||
import { ContainerProps } from './Container.types'; | ||
|
||
import styles from './Container.module.css'; | ||
|
||
function Container<E extends React.ElementType = 'div'>({ | ||
className, | ||
children, | ||
component, | ||
...rest | ||
}: ContainerProps<E>) { | ||
const Component = component ?? 'div'; | ||
|
||
return React.createElement( | ||
Component, | ||
{ | ||
className: cn(styles.container, className), | ||
...rest, | ||
}, | ||
children, | ||
); | ||
} | ||
|
||
export default Container; |
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,13 @@ | ||
import React from 'react'; | ||
|
||
type ContainerBaseProps<E extends React.ElementType> = { | ||
/** | ||
* The component used for the root node. Either a string to use a HTML element or a component | ||
* @default "div" | ||
*/ | ||
component?: E; | ||
}; | ||
|
||
export type ContainerProps<E extends React.ElementType> = | ||
ContainerBaseProps<E> & | ||
Omit<React.ComponentProps<E>, keyof ContainerBaseProps<E>>; |
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
Oops, something went wrong.
9eb07f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report
Test suite run success
250 tests passing in 37 suites.
Report generated by 🧪jest coverage report action from 9eb07f3