This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Page Templates - Add Page.Content component (#79)
* WIP * WIP * Update snaps
- Loading branch information
Showing
14 changed files
with
800 additions
and
21 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
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,58 @@ | ||
import * as React from 'react'; | ||
import * as PropTypes from 'prop-types'; | ||
// @ts-ignore | ||
import _get from 'lodash/get'; | ||
|
||
import { Box } from '../primitives'; | ||
import { withTheme } from '../styled'; | ||
import { ContainerProps, LocalContainerProps, containerPropTypes, containerDefaultProps } from '../Container/Container'; | ||
import { PageContent as _PageContent } from './styled'; | ||
|
||
export type LocalPageContentProps = LocalContainerProps & { | ||
children: React.ReactNode; | ||
theme?: Object; | ||
wrapperProps?: Object; | ||
}; | ||
export type PageContentProps = ContainerProps & LocalPageContentProps; | ||
|
||
export const PageContent: React.FunctionComponent<LocalPageContentProps> = ({ | ||
breakpoint, | ||
children, | ||
isFluid, | ||
isLayout, | ||
theme, | ||
wrapperProps, | ||
...props | ||
}) => ( | ||
<Box {...wrapperProps}> | ||
<_PageContent | ||
breakpoint={breakpoint} | ||
isFluid={isFluid || !breakpoint} | ||
isLayout={isLayout} | ||
{...props} | ||
{..._get(theme, 'fannypack.Page.PageContent.defaultProps', {})} | ||
> | ||
{children} | ||
</_PageContent> | ||
</Box> | ||
); | ||
|
||
export const PageContentPropTypes = { | ||
...containerPropTypes, | ||
children: PropTypes.node.isRequired, | ||
theme: PropTypes.object, | ||
wrapperProps: PropTypes.object | ||
}; | ||
PageContent.propTypes = PageContentPropTypes; | ||
|
||
export const PageContentDefaultProps = { | ||
...containerDefaultProps, | ||
breakpoint: 'tablet' as 'tablet', | ||
isLayout: true, | ||
theme: {}, | ||
wrapperProps: {} | ||
}; | ||
PageContent.defaultProps = PageContentDefaultProps; | ||
|
||
const C: React.FunctionComponent<PageContentProps> = withTheme(PageContent); | ||
export default C; |
23 changes: 23 additions & 0 deletions
23
packages/fannypack/src/Page/__tests__/PageContent.test.tsx
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,23 @@ | ||
import * as React from 'react'; | ||
import render from '../../_utils/tests/render'; | ||
import PageContent from '../PageContent'; | ||
|
||
it('renders correctly for a basic PageContent', () => { | ||
const { container } = render(<PageContent>test</PageContent>); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly for a PageContent with breakpoint', () => { | ||
const { container } = render(<PageContent breakpoint="desktop">test</PageContent>); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly for a PageContent with a fluid container', () => { | ||
const { container } = render(<PageContent isFluid>test</PageContent>); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly for a PageContent with wrapper props', () => { | ||
const { container } = render(<PageContent wrapperProps={{ backgroundColor: 'red' }}>test</PageContent>); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); |
231 changes: 231 additions & 0 deletions
231
packages/fannypack/src/Page/__tests__/__snapshots__/PageContent.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,231 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders correctly for a PageContent with a fluid container 1`] = ` | ||
.c0 { | ||
margin: unset; | ||
padding: unset; | ||
border: unset; | ||
background: unset; | ||
font: unset; | ||
font-family: inherit; | ||
font-size: 100%; | ||
box-sizing: border-box; | ||
background-color: unset; | ||
color: inherit; | ||
} | ||
.c0:focus:not(:focus-visible) { | ||
outline: none; | ||
} | ||
.c2 { | ||
width: 100%; | ||
padding-left: 2rem; | ||
padding-right: 2rem; | ||
} | ||
.c1 { | ||
padding: 2rem 1rem; | ||
padding-top: 1rem; | ||
padding-bottom: 1rem; | ||
} | ||
@media (max-width:768px) { | ||
.c2 { | ||
padding-left: 1rem; | ||
padding-right: 1rem; | ||
} | ||
} | ||
@media (max-width:768px) { | ||
.c1 { | ||
padding-top: 1rem; | ||
padding-bottom: 1rem; | ||
} | ||
} | ||
<div | ||
class="c0" | ||
> | ||
<div | ||
class="c1 c2 c0" | ||
> | ||
test | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`renders correctly for a PageContent with breakpoint 1`] = ` | ||
.c0 { | ||
margin: unset; | ||
padding: unset; | ||
border: unset; | ||
background: unset; | ||
font: unset; | ||
font-family: inherit; | ||
font-size: 100%; | ||
box-sizing: border-box; | ||
background-color: unset; | ||
color: inherit; | ||
} | ||
.c0:focus:not(:focus-visible) { | ||
outline: none; | ||
} | ||
.c2 { | ||
width: 100%; | ||
max-width: 1440px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
.c2 { | ||
max-width: 1024px; | ||
} | ||
.c1 { | ||
padding: 2rem 1rem; | ||
} | ||
@media (max-width:768px) { | ||
.c2 { | ||
padding-left: 1rem; | ||
padding-right: 1rem; | ||
} | ||
} | ||
@media (max-width:768px) { | ||
.c1 { | ||
padding-top: 1rem; | ||
padding-bottom: 1rem; | ||
} | ||
} | ||
<div | ||
class="c0" | ||
> | ||
<div | ||
class="c1 c2 c0" | ||
> | ||
test | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`renders correctly for a PageContent with wrapper props 1`] = ` | ||
.c0 { | ||
margin: unset; | ||
padding: unset; | ||
border: unset; | ||
background: unset; | ||
font: unset; | ||
font-family: inherit; | ||
font-size: 100%; | ||
box-sizing: border-box; | ||
background-color: unset; | ||
color: inherit; | ||
} | ||
.c0:focus:not(:focus-visible) { | ||
outline: none; | ||
} | ||
.c2 { | ||
width: 100%; | ||
max-width: 1440px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
.c2 { | ||
max-width: 768px; | ||
} | ||
.c1 { | ||
padding: 2rem 1rem; | ||
} | ||
@media (max-width:768px) { | ||
.c2 { | ||
padding-left: 1rem; | ||
padding-right: 1rem; | ||
} | ||
} | ||
@media (max-width:768px) { | ||
.c1 { | ||
padding-top: 1rem; | ||
padding-bottom: 1rem; | ||
} | ||
} | ||
<div | ||
class="c0" | ||
style="background-color: red;" | ||
> | ||
<div | ||
class="c1 c2 c0" | ||
> | ||
test | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`renders correctly for a basic PageContent 1`] = ` | ||
.c0 { | ||
margin: unset; | ||
padding: unset; | ||
border: unset; | ||
background: unset; | ||
font: unset; | ||
font-family: inherit; | ||
font-size: 100%; | ||
box-sizing: border-box; | ||
background-color: unset; | ||
color: inherit; | ||
} | ||
.c0:focus:not(:focus-visible) { | ||
outline: none; | ||
} | ||
.c2 { | ||
width: 100%; | ||
max-width: 1440px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
.c2 { | ||
max-width: 768px; | ||
} | ||
.c1 { | ||
padding: 2rem 1rem; | ||
} | ||
@media (max-width:768px) { | ||
.c2 { | ||
padding-left: 1rem; | ||
padding-right: 1rem; | ||
} | ||
} | ||
@media (max-width:768px) { | ||
.c1 { | ||
padding-top: 1rem; | ||
padding-bottom: 1rem; | ||
} | ||
} | ||
<div | ||
class="c0" | ||
> | ||
<div | ||
class="c1 c2 c0" | ||
> | ||
test | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import PageContent from './PageContent'; | ||
|
||
export default { Content: PageContent }; | ||
|
||
export * from './PageContent'; | ||
export { default as PageContent } from './PageContent'; |
Oops, something went wrong.