@graphcommerce/next-ui 3.25.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/AnimatedRow/index.tsx +6 -3
  2. package/ApolloError/ApolloErrorAlert.tsx +20 -21
  3. package/ApolloError/ApolloErrorFullPage.tsx +3 -4
  4. package/ApolloError/ApolloErrorSnackbar.tsx +3 -3
  5. package/Blog/BlogAuthor/index.tsx +42 -48
  6. package/Blog/BlogContent/index.tsx +6 -23
  7. package/Blog/BlogHeader/index.tsx +26 -23
  8. package/Blog/BlogList/index.tsx +7 -25
  9. package/Blog/BlogListItem/index.tsx +63 -52
  10. package/Blog/BlogTags/BlogTag.tsx +27 -0
  11. package/Blog/BlogTags/index.tsx +7 -32
  12. package/Blog/BlogTitle/index.tsx +7 -21
  13. package/Button/Button.tsx +5 -0
  14. package/Button/LinkOrButton.tsx +80 -0
  15. package/Button/index.tsx +2 -177
  16. package/CHANGELOG.md +524 -645
  17. package/ChipMenu/index.tsx +71 -77
  18. package/ContainerWithHeader/index.tsx +33 -30
  19. package/FlagAvatar/index.tsx +2 -12
  20. package/Footer/Footer.tsx +105 -88
  21. package/Footer/index.ts +0 -1
  22. package/Form/Form.tsx +35 -0
  23. package/Form/FormActions.tsx +9 -14
  24. package/Form/FormDivider.tsx +8 -13
  25. package/Form/FormHeader.tsx +5 -26
  26. package/Form/FormRow.tsx +8 -13
  27. package/Form/InputCheckmark.tsx +9 -22
  28. package/FramerScroller/SidebarGallery.tsx +340 -0
  29. package/FramerScroller/SidebarSlider.tsx +107 -0
  30. package/FramerScroller/index.ts +2 -0
  31. package/FullPageMessage/index.tsx +52 -48
  32. package/Highlight/index.tsx +1 -1
  33. package/IconHeader/index.tsx +63 -58
  34. package/JsonLd/index.tsx +3 -2
  35. package/Layout/components/LayoutHeader.tsx +75 -82
  36. package/Layout/components/LayoutHeaderBack.tsx +26 -18
  37. package/Layout/components/LayoutHeaderClose.tsx +9 -22
  38. package/Layout/components/LayoutHeaderContent.tsx +190 -154
  39. package/Layout/components/LayoutHeadertypes.ts +1 -1
  40. package/Layout/components/LayoutTitle.tsx +60 -55
  41. package/LayoutDefault/components/LayoutDefault.tsx +96 -85
  42. package/LayoutOverlay/components/LayoutOverlay.tsx +2 -8
  43. package/LayoutOverlay/components/LayoutOverlayBase.tsx +233 -239
  44. package/LayoutOverlay/test/LayoutOverlayDemo.tsx +1 -1
  45. package/LayoutParts/DesktopHeaderBadge.tsx +28 -0
  46. package/LayoutParts/DesktopNavActions.tsx +15 -0
  47. package/LayoutParts/DesktopNavBar.tsx +113 -0
  48. package/LayoutParts/DesktopNavBarItem.tsx +44 -0
  49. package/{AppShell → LayoutParts}/GlobalHead.tsx +1 -2
  50. package/LayoutParts/Logo.tsx +77 -0
  51. package/LayoutParts/MenuFab.tsx +132 -0
  52. package/LayoutParts/MenuFabItem.tsx +25 -0
  53. package/LayoutParts/MenuFabSecondaryItem.tsx +37 -0
  54. package/{AppShell/PlaceholderFab/index.tsx → LayoutParts/PlaceholderFab.tsx} +1 -1
  55. package/LayoutParts/StickyBelowHeader.tsx +25 -0
  56. package/LayoutParts/index.ts +12 -0
  57. package/{AppShell → LayoutParts}/useFabAnimation.ts +0 -0
  58. package/Page/CssAndFramerMotionProvider.tsx +21 -0
  59. package/Page/index.ts +2 -0
  60. package/Page/types.ts +2 -8
  61. package/PageLoadIndicator/index.tsx +25 -30
  62. package/PageMeta/index.tsx +1 -1
  63. package/Pagination/index.tsx +37 -54
  64. package/RenderType/index.tsx +1 -1
  65. package/Row/ButtonLinkList/ButtonLinkList.tsx +35 -37
  66. package/Row/ButtonLinkList/ButtonLinkListItem.tsx +16 -33
  67. package/Row/ColumnOne/index.tsx +5 -10
  68. package/Row/ColumnOneBoxed/index.tsx +18 -19
  69. package/Row/ColumnOneCentered/index.tsx +3 -4
  70. package/Row/ColumnThree/index.tsx +62 -57
  71. package/Row/ColumnTwo/index.tsx +37 -32
  72. package/Row/ColumnTwoSpread/index.tsx +28 -37
  73. package/Row/ColumnTwoWithTop/index.tsx +37 -43
  74. package/Row/ContentLinks/index.tsx +24 -25
  75. package/Row/HeroBanner/index.tsx +98 -82
  76. package/Row/IconBlocks/IconBlock/index.tsx +45 -37
  77. package/Row/IconBlocks/index.tsx +29 -44
  78. package/Row/ImageText/index.tsx +71 -67
  79. package/Row/ImageTextBoxed/index.tsx +66 -65
  80. package/Row/ParagraphWithSidebarSlide/index.tsx +80 -76
  81. package/Row/Quote/index.tsx +3 -3
  82. package/Row/SpecialBanner/index.tsx +97 -97
  83. package/Row/index.tsx +4 -9
  84. package/SectionContainer/index.tsx +32 -31
  85. package/SectionHeader/index.tsx +41 -43
  86. package/Separator/index.tsx +19 -18
  87. package/Snackbar/MessageSnackbar.tsx +1 -2
  88. package/Snackbar/MessageSnackbarImpl.tsx +68 -115
  89. package/StarRatingField/index.tsx +24 -25
  90. package/Stepper/Stepper.tsx +34 -32
  91. package/Styles/EmotionProvider.tsx +14 -0
  92. package/Styles/breakpointVal.tsx +16 -10
  93. package/Styles/extendableComponent.ts +70 -0
  94. package/Styles/index.tsx +9 -2
  95. package/Styles/withEmotionCache.tsx +36 -0
  96. package/Styles/withTheme.tsx +15 -24
  97. package/SvgIcon/SvgIcon.tsx +60 -0
  98. package/TextInputNumber/index.tsx +49 -50
  99. package/Theme/DarkLightModeThemeProvider.tsx +119 -0
  100. package/Theme/MuiButton.ts +128 -0
  101. package/Theme/MuiSlider.ts +28 -0
  102. package/Theme/MuiSnackbar.ts +31 -0
  103. package/Theme/{types.ts → createTheme.ts} +8 -2
  104. package/Theme/index.ts +5 -0
  105. package/Theme/themeDefaults.ts +51 -0
  106. package/TimeAgo/index.tsx +1 -1
  107. package/ToggleButton/index.tsx +43 -49
  108. package/ToggleButtonGroup/index.tsx +39 -39
  109. package/UspList/UspListItem.tsx +56 -46
  110. package/UspList/index.tsx +29 -26
  111. package/docs/building-components.mdx +3 -0
  112. package/docs/components/ComponentBasic.tsx +26 -0
  113. package/docs/components/ComponentChild.tsx +48 -0
  114. package/docs/components/ComponentChildVariant.tsx +54 -0
  115. package/docs/components/ComponentChildVariantExtendable.tsx +62 -0
  116. package/docs/components/ComponentStylable.tsx +32 -0
  117. package/docs/pages/building-components.tsx +62 -0
  118. package/icons/index.tsx +2 -0
  119. package/index.ts +27 -81
  120. package/package.json +27 -27
  121. package/types.d.ts +1 -1
  122. package/AppShell/AppShellSticky/index.tsx +0 -38
  123. package/AppShell/DesktopNavActions.tsx +0 -32
  124. package/AppShell/DesktopNavBar.tsx +0 -158
  125. package/AppShell/Logo.tsx +0 -46
  126. package/AppShell/Menu.tsx +0 -7
  127. package/AppShell/MenuFab.tsx +0 -162
  128. package/AppShell/MenuFabSecondaryItem.tsx +0 -32
  129. package/AppShell/index.ts +0 -15
  130. package/AspectRatioContainer/index.tsx +0 -27
  131. package/Footer/SocialIcon.tsx +0 -23
  132. package/Form/index.tsx +0 -67
  133. package/FramerScroller/components/SidebarGallery.tsx +0 -317
  134. package/FramerScroller/components/SidebarSlider.tsx +0 -97
  135. package/Page/App.tsx +0 -17
  136. package/Page/Document.tsx +0 -24
  137. package/StyledBadge/index.tsx +0 -20
  138. package/Styles/classesPicker.ts +0 -41
  139. package/SvgImage/SvgImageSimple.tsx +0 -100
  140. package/SvgImage/index.tsx +0 -74
@@ -1,59 +1,28 @@
1
- import { Fab, makeStyles, Theme, Typography } from '@material-ui/core'
2
- import { PaginationProps, usePagination } from '@material-ui/lab'
1
+ import { PaginationProps, Box, SxProps, Theme, IconButton } from '@mui/material'
2
+ import usePagination, { UsePaginationItem } from '@mui/material/usePagination'
3
3
  import React from 'react'
4
- import { UseStyles } from '../Styles'
5
- import SvgImageSimple from '../SvgImage/SvgImageSimple'
4
+ import { extendableComponent } from '../Styles'
5
+ import { SvgIcon } from '../SvgIcon/SvgIcon'
6
6
  import { iconChevronLeft, iconChevronRight } from '../icons'
7
7
 
8
- const useStyles = makeStyles((theme: Theme) => ({
9
- root: {
10
- margin: '0 auto',
11
- marginTop: theme.spacings.lg,
12
- marginBottom: theme.spacings.lg,
13
- display: 'flex',
14
- alignItems: 'center',
15
- justifyContent: 'center',
16
- gap: 6,
17
- '& .Mui-disabled': {
18
- background: 'none',
19
- },
20
- },
21
- pagination: {
22
- gridArea: 'pagination',
23
- justifyContent: 'center',
24
- display: 'grid',
25
- gridAutoFlow: 'column',
26
- alignItems: 'center',
27
- marginBottom: theme.spacings.xxl,
28
- [theme.breakpoints.up('md')]: {
29
- marginBottom: theme.spacings.lg,
30
- },
31
- ...theme.typography.body1,
32
- '& > *': {
33
- whiteSpace: 'nowrap',
34
- boxShadow: 'none',
35
- },
36
- },
37
- fab: {
38
- color: theme.palette.text.primary,
39
- },
40
- }))
41
-
42
8
  export type PagePaginationProps = {
43
9
  count: number
44
10
  page: number
45
- renderLink: (page: number, icon: React.ReactNode, btnProps: any) => React.ReactNode
46
- } & Omit<PaginationProps, 'count' | 'defaultPage' | 'page' | 'renderItem'> &
47
- UseStyles<typeof useStyles>
11
+ renderLink: (page: number, icon: React.ReactNode, btnProps: UsePaginationItem) => React.ReactNode
12
+ sx?: SxProps<Theme>
13
+ } & Omit<PaginationProps, 'count' | 'defaultPage' | 'page' | 'renderItem'>
14
+
15
+ const parts = ['root', 'button', 'icon'] as const
16
+ const { classes } = extendableComponent('Pagination', parts)
48
17
 
49
18
  /**
50
19
  * Rel="prev" and rel="next" are deprecated by Google.
51
20
  *
52
21
  * Read more: https://ahrefs.com/blog/rel-prev-next-pagination/
53
22
  */
54
- export default function Pagination(props: PagePaginationProps) {
23
+ export function Pagination(props: PagePaginationProps) {
55
24
  const { count, page, renderLink, classes: styles, ...paginationProps } = props
56
- const classes = useStyles(props)
25
+
57
26
  const { items } = usePagination({
58
27
  count,
59
28
  defaultPage: 1,
@@ -65,36 +34,50 @@ export default function Pagination(props: PagePaginationProps) {
65
34
  const nextBtnProps = items[items.length - 1]
66
35
 
67
36
  const chevronLeft = (
68
- <Fab
37
+ <IconButton
69
38
  size='medium'
70
39
  disabled={page === 1}
71
40
  color='inherit'
72
41
  aria-label='Previous page'
73
- className={classes.fab}
42
+ className={classes.button}
74
43
  >
75
- <SvgImageSimple src={iconChevronLeft} />
76
- </Fab>
44
+ <SvgIcon src={iconChevronLeft} className={classes.icon} size='medium' />
45
+ </IconButton>
77
46
  )
78
47
 
79
48
  const chevronRight = (
80
- <Fab
49
+ <IconButton
81
50
  size='medium'
82
51
  disabled={page === count}
83
52
  color='inherit'
84
53
  aria-label='Next page'
85
- className={classes.fab}
54
+ className={classes.button}
86
55
  >
87
- <SvgImageSimple src={iconChevronRight} />
88
- </Fab>
56
+ <SvgIcon src={iconChevronRight} className={classes.icon} size='medium' />
57
+ </IconButton>
89
58
  )
90
59
 
91
60
  return (
92
- <div className={classes.root}>
61
+ <Box
62
+ className={classes.root}
63
+ sx={(theme) => ({
64
+ margin: '0 auto',
65
+ marginTop: theme.spacings.lg,
66
+ marginBottom: theme.spacings.lg,
67
+ display: 'flex',
68
+ alignItems: 'center',
69
+ justifyContent: 'center',
70
+ gap: '6px',
71
+ '& .Mui-disabled': {
72
+ background: 'none',
73
+ },
74
+ })}
75
+ >
93
76
  {page === 1 ? chevronLeft : renderLink(page - 1, chevronLeft, prevBtnProps)}
94
77
 
95
- <Typography variant='body1'>Page {`${page} of ${Math.max(1, count)}`}</Typography>
78
+ <Box typography='body1'>Page {`${page} of ${Math.max(1, count)}`}</Box>
96
79
 
97
80
  {page === count ? chevronRight : renderLink(page + 1, chevronRight, nextBtnProps)}
98
- </div>
81
+ </Box>
99
82
  )
100
83
  }
@@ -27,7 +27,7 @@ export type TypeRenderer<
27
27
  * A simple array with renderers but with strict typing that validates of the provided Renderer is
28
28
  * actually able to render the Type
29
29
  */
30
- export default function RenderType<
30
+ export function RenderType<
31
31
  T extends TypeObject,
32
32
  A extends Record<string, unknown> = Record<string, unknown>,
33
33
  >(props: { renderer: TypeRenderer<T, A> } & FilterTypeByTypename<T, T['__typename']> & A) {
@@ -1,51 +1,49 @@
1
- import { Theme, makeStyles } from '@material-ui/core'
1
+ import { Box, SxProps, Theme } from '@mui/material'
2
2
  import React from 'react'
3
- import Row from '..'
4
- import SectionContainer from '../../SectionContainer'
5
- import { UseStyles } from '../../Styles'
3
+ import { Row } from '..'
4
+ import { SectionContainer } from '../../SectionContainer'
5
+ import { extendableComponent } from '../../Styles'
6
6
  import { responsiveVal } from '../../Styles/responsiveVal'
7
7
 
8
- const useStyles = makeStyles(
9
- (theme: Theme) => ({
10
- container: {
11
- maxWidth: 820,
12
- },
13
- h1: {
14
- textAlign: 'center',
15
- ...theme.typography.h2,
16
- },
17
- overline: {
18
- display: 'block',
19
- padding: `${theme.spacings.xs} 0`,
20
- borderBottom: `1px solid ${theme.palette.divider}`,
21
- },
22
- links: ({ containsBigLinks }: ButtonLinkListPropsBase) => ({
23
- display: 'grid',
24
- gridTemplateColumns: containsBigLinks
25
- ? undefined
26
- : `repeat(auto-fill, minmax(${responsiveVal(210, 350)}, 1fr))`,
27
- columnGap: theme.spacings.sm,
28
- }),
29
- }),
30
- { name: 'ButtonLinkList' },
31
- )
32
-
33
- type ButtonLinkListPropsBase = {
8
+ export type ButtonLinkListProps = {
34
9
  title: string
35
10
  children: React.ReactNode
36
- containsBigLinks: boolean
37
- }
11
+ sx?: SxProps<Theme>
12
+ } & OwnerState
38
13
 
39
- export type ButtonLinkListProps = UseStyles<typeof useStyles> & ButtonLinkListPropsBase
14
+ type OwnerState = { containsBigLinks: boolean }
15
+
16
+ const compName = 'ButtonLinkList' as const
17
+ const parts = ['root', 'links'] as const
18
+ const { withState } = extendableComponent<OwnerState, typeof compName, typeof parts>(
19
+ compName,
20
+ parts,
21
+ )
40
22
 
41
23
  export function ButtonLinkList(props: ButtonLinkListProps) {
42
- const { title, children } = props
43
- const classes = useStyles(props)
24
+ const { title, children, containsBigLinks, sx = [] } = props
25
+
26
+ const classes = withState({ containsBigLinks })
44
27
 
45
28
  return (
46
- <Row maxWidth='md' className={classes.container}>
29
+ <Row
30
+ maxWidth='md'
31
+ className={classes.root}
32
+ sx={[{ maxWidth: 820 }, ...(Array.isArray(sx) ? sx : [sx])]}
33
+ >
47
34
  <SectionContainer labelLeft={title}>
48
- <div className={classes.links}>{children}</div>
35
+ <Box
36
+ className={classes.links}
37
+ sx={(theme) => ({
38
+ display: 'grid',
39
+ columnGap: theme.spacings.sm,
40
+ '&:not(.containsBigLinks)': {
41
+ gridTemplateColumns: `repeat(auto-fill, minmax(${responsiveVal(210, 350)}, 1fr))`,
42
+ },
43
+ })}
44
+ >
45
+ {children}
46
+ </Box>
49
47
  </SectionContainer>
50
48
  </Row>
51
49
  )
@@ -1,46 +1,29 @@
1
- import { makeStyles, Theme } from '@material-ui/core'
2
- import clsx from 'clsx'
1
+ import { Button, ButtonProps, styled } from '@mui/material'
3
2
  import PageLink from 'next/link'
4
3
  import React from 'react'
5
- import Button, { ButtonProps } from '../../Button'
6
- import { UseStyles } from '../../Styles'
7
- import SvgImageSimple from '../../SvgImage/SvgImageSimple'
4
+ import { SvgIcon } from '../../SvgIcon/SvgIcon'
8
5
  import { iconChevronRight } from '../../icons'
9
6
 
10
- const useStyles = makeStyles((theme: Theme) => ({
11
- buttonLink: {
12
- color: theme.palette.text.primary,
13
- textDecoration: 'none',
14
- padding: `${theme.spacings.xs} 0`,
15
- borderBottom: `1px solid ${theme.palette.divider}`,
16
- borderRadius: 0,
17
- ...theme.typography.body1,
18
- '& > *': {
19
- display: 'grid',
20
- gridAutoFlow: 'column',
21
- justifyContent: 'space-between',
22
- gap: `${theme.spacings.xs}`,
23
- },
24
- },
25
- }))
7
+ export type ButtonLinkProps = { url: string; endIcon?: React.ReactNode } & ButtonProps
26
8
 
27
- export type ButtonLinkProps = {
28
- children: React.ReactNode
29
- url: string
30
- endIcon?: React.ReactNode
31
- } & ButtonProps &
32
- UseStyles<typeof useStyles>
9
+ const ButtonItem = styled(Button)(({ theme }) => ({
10
+ color: theme.palette.text.primary,
11
+ textDecoration: 'none',
12
+ padding: `${theme.spacings.xs} 0`,
13
+ borderBottom: `1px solid ${theme.palette.divider}`,
14
+ borderRadius: 0,
15
+ justifyContent: 'space-between',
16
+ ...theme.typography.body1,
17
+ }))
33
18
 
34
19
  export function ButtonLinkListItem(props: ButtonLinkProps) {
35
- const { children, url, endIcon, className, ...buttonProps } = props
36
- const classes = useStyles(props)
20
+ const { children, url, endIcon = <SvgIcon src={iconChevronRight} />, ...buttonProps } = props
37
21
 
38
22
  return (
39
23
  <PageLink href={url} passHref>
40
- <Button {...buttonProps} className={clsx(classes.buttonLink, className)}>
41
- <span>{children}</span>
42
- {endIcon ?? <SvgImageSimple src={iconChevronRight} />}
43
- </Button>
24
+ <ButtonItem {...buttonProps} endIcon={endIcon}>
25
+ {children}
26
+ </ButtonItem>
44
27
  </PageLink>
45
28
  )
46
29
  }
@@ -1,11 +1,6 @@
1
- import { Container, styled } from '@material-ui/core'
1
+ import { Container, styled } from '@mui/material'
2
2
 
3
- const ColumnOne = styled(Container)(
4
- ({ theme }) => ({
5
- maxWidth: 820,
6
- marginBottom: theme.spacings.lg,
7
- }),
8
- { name: 'ColumnOne' },
9
- )
10
-
11
- export default ColumnOne
3
+ export const ColumnOne = styled(Container, { name: 'ColumnOne' })(({ theme }) => ({
4
+ maxWidth: 820,
5
+ marginBottom: theme.spacings.lg,
6
+ }))
@@ -1,27 +1,26 @@
1
- import { ContainerProps, makeStyles, Theme } from '@material-ui/core'
2
- import React from 'react'
3
- import Row from '..'
1
+ import { Box, ContainerProps } from '@mui/material'
2
+ import { Row } from '..'
3
+ import { extendableComponent } from '../../Styles'
4
4
 
5
- const useStyles = makeStyles(
6
- (theme: Theme) => ({
7
- boxed: {
8
- padding: theme.spacings.lg,
9
- boxShadow: theme.shadows[24],
10
- '& h1, & h2, & h3': {
11
- marginTop: 0,
12
- },
13
- },
14
- }),
15
- { name: 'ColumnOneBoxed' },
16
- )
5
+ const compName = 'ColumnOneBoxed' as const
6
+ const parts = ['root', 'boxed'] as const
7
+ const { classes } = extendableComponent(compName, parts)
17
8
 
18
- export default function ColumnOneBoxed(props: ContainerProps) {
9
+ export function ColumnOneBoxed(props: ContainerProps) {
19
10
  const { children } = props
20
- const classes = useStyles(props)
21
11
 
22
12
  return (
23
- <Row {...props}>
24
- <div className={classes.boxed}>{children}</div>
13
+ <Row {...props} className={classes.root}>
14
+ <Box
15
+ className={classes.boxed}
16
+ sx={(theme) => ({
17
+ padding: theme.spacings.lg,
18
+ boxShadow: theme.shadows[24],
19
+ '& h1, & h2, & h3': { marginTop: 0 },
20
+ })}
21
+ >
22
+ {children}
23
+ </Box>
25
24
  </Row>
26
25
  )
27
26
  }
@@ -1,6 +1,5 @@
1
- import { ContainerProps, styled } from '@material-ui/core'
2
- import React from 'react'
3
- import ColumnOne from '../ColumnOne'
1
+ import { ContainerProps, styled } from '@mui/material'
2
+ import { ColumnOne } from '../ColumnOne'
4
3
 
5
4
  const Wrapper = styled('div')(({ theme }) => ({
6
5
  marginBottom: theme.spacings.lg,
@@ -11,7 +10,7 @@ const Wrapper = styled('div')(({ theme }) => ({
11
10
  position: 'relative',
12
11
  }))
13
12
 
14
- export default function ColumnOneCentered(props: ContainerProps) {
13
+ export function ColumnOneCentered(props: ContainerProps) {
15
14
  const { children } = props
16
15
 
17
16
  return (
@@ -1,66 +1,71 @@
1
- import { ContainerProps, makeStyles, Theme } from '@material-ui/core'
1
+ import { Box, ContainerProps } from '@mui/material'
2
2
  import React from 'react'
3
- import Row from '..'
4
- import { UseStyles } from '../../Styles'
3
+ import { Row } from '..'
4
+ import { extendableComponent } from '../../Styles'
5
5
 
6
- const useStyles = makeStyles(
7
- (theme: Theme) => ({
8
- root: {
9
- display: 'grid',
10
- gridColumnGap: theme.spacings.md,
11
- gridRowGap: theme.spacings.lg,
12
- gridTemplateColumns: `1fr`,
13
- gridTemplateAreas: `
14
- "one"
15
- "two"
16
- "three"
17
- `,
18
- '& h2, & h3': {
19
- ...theme.typography.h4,
20
- [theme.breakpoints.up('md')]: {
21
- marginBottom: '-25px',
22
- },
23
- },
24
- '& p': {
25
- [theme.breakpoints.up('md')]: {
26
- marginTop: '65px',
27
- },
28
- },
29
- [theme.breakpoints.up('sm')]: {
30
- gridTemplateColumns: `1fr 1fr`,
31
- gridTemplateAreas: `
32
- "one two"
33
- "three three"
34
- `,
35
- },
36
- [theme.breakpoints.up('md')]: {
37
- gridTemplateColumns: `1fr 1fr 1fr`,
38
- gridTemplateAreas: '"one two three"',
39
- },
40
- },
41
- colOne: { gridArea: 'one', zIndex: 2 },
42
- colTwo: { gridArea: 'two', zIndex: 2 },
43
- colThree: { gridArea: 'three', zIndex: 2 },
44
- }),
45
- { name: 'ColumnThree' },
46
- )
6
+ const compName = 'ColumnThree' as const
7
+ const parts = ['root', 'colOne', 'colTwo', 'colThree'] as const
8
+ const { classes } = extendableComponent(compName, parts)
47
9
 
48
- export type ColumnThreeProps = UseStyles<typeof useStyles> &
49
- Omit<ContainerProps, 'children'> & {
50
- colOneContent: React.ReactNode
51
- colTwoContent: React.ReactNode
52
- colThreeContent: React.ReactNode
53
- }
10
+ export type ColumnThreeProps = Omit<ContainerProps, 'children'> & {
11
+ colOneContent: React.ReactNode
12
+ colTwoContent: React.ReactNode
13
+ colThreeContent: React.ReactNode
14
+ }
54
15
 
55
- export default function ColumnThree(props: ColumnThreeProps) {
56
- const { colOneContent, colTwoContent, colThreeContent, ...containerProps } = props
57
- const classes = useStyles(props)
16
+ export function ColumnThree(props: ColumnThreeProps) {
17
+ const { colOneContent, colTwoContent, colThreeContent, sx = [], ...containerProps } = props
58
18
 
59
19
  return (
60
- <Row className={classes.root} {...containerProps}>
61
- <div className={classes.colOne}>{colOneContent}</div>
62
- <div className={classes.colTwo}>{colTwoContent}</div>
63
- <div className={classes.colThree}>{colThreeContent}</div>
20
+ <Row
21
+ className={classes.root}
22
+ {...containerProps}
23
+ sx={[
24
+ (theme) => ({
25
+ display: 'grid',
26
+ gridColumnGap: theme.spacings.md,
27
+ gridRowGap: theme.spacings.lg,
28
+ gridTemplateColumns: `1fr`,
29
+ gridTemplateAreas: `
30
+ "one"
31
+ "two"
32
+ "three"
33
+ `,
34
+ '& h2, & h3': {
35
+ typography: 'h4',
36
+ [theme.breakpoints.up('md')]: {
37
+ marginBottom: '-25px',
38
+ },
39
+ },
40
+ '& p': {
41
+ [theme.breakpoints.up('md')]: {
42
+ marginTop: '65px',
43
+ },
44
+ },
45
+ [theme.breakpoints.up('sm')]: {
46
+ gridTemplateColumns: `1fr 1fr`,
47
+ gridTemplateAreas: `
48
+ "one two"
49
+ "three three"
50
+ `,
51
+ },
52
+ [theme.breakpoints.up('md')]: {
53
+ gridTemplateColumns: `1fr 1fr 1fr`,
54
+ gridTemplateAreas: '"one two three"',
55
+ },
56
+ }),
57
+ ...(Array.isArray(sx) ? sx : [sx]),
58
+ ]}
59
+ >
60
+ <Box className={classes.colOne} sx={{ gridArea: 'one' }}>
61
+ {colOneContent}
62
+ </Box>
63
+ <Box className={classes.colTwo} sx={{ gridArea: 'two' }}>
64
+ {colTwoContent}
65
+ </Box>
66
+ <Box className={classes.colThree} sx={{ gridArea: 'three' }}>
67
+ {colThreeContent}
68
+ </Box>
64
69
  </Row>
65
70
  )
66
71
  }
@@ -1,41 +1,46 @@
1
- import { ContainerProps, makeStyles, Theme } from '@material-ui/core'
1
+ import { Box, ContainerProps } from '@mui/material'
2
2
  import React from 'react'
3
- import Row from '..'
4
- import { UseStyles } from '../../Styles'
3
+ import { Row } from '..'
4
+ import { extendableComponent } from '../../Styles'
5
5
 
6
- const useStyles = makeStyles(
7
- (theme: Theme) => ({
8
- root: {
9
- gridColumnGap: theme.spacings.md,
10
- gridRowGap: theme.spacings.lg,
11
- display: `grid`,
12
- gridTemplateColumns: `1fr`,
13
- gridTemplateAreas: `"one" "two"`,
14
- [theme.breakpoints.up('sm')]: {
15
- gridTemplateColumns: `1fr 1fr`,
16
- gridTemplateAreas: `"one two"`,
17
- },
18
- },
19
- colOne: { gridArea: 'one' },
20
- colTwo: { gridArea: 'two' },
21
- }),
22
- { name: 'ColumnTwo' },
23
- )
6
+ export type ColumnTwoProps = Omit<ContainerProps, 'children'> & {
7
+ colOneContent: React.ReactNode
8
+ colTwoContent: React.ReactNode
9
+ }
24
10
 
25
- export type ColumnTwoProps = UseStyles<typeof useStyles> &
26
- Omit<ContainerProps, 'children'> & {
27
- colOneContent: React.ReactNode
28
- colTwoContent: React.ReactNode
29
- }
11
+ const compName = 'ColumnTwo' as const
12
+ const parts = ['root', 'colOne', 'colTwo'] as const
13
+ const { classes } = extendableComponent(compName, parts)
30
14
 
31
- export default function ColumnTwo(props: ColumnTwoProps) {
32
- const { colOneContent, colTwoContent, ...containerProps } = props
33
- const classes = useStyles(props)
15
+ export function ColumnTwo(props: ColumnTwoProps) {
16
+ const { colOneContent, colTwoContent, sx = [], ...containerProps } = props
34
17
 
35
18
  return (
36
- <Row maxWidth='lg' {...containerProps} className={classes.root}>
37
- <div className={classes.colOne}>{colOneContent}</div>
38
- <div className={classes.colTwo}>{colTwoContent}</div>
19
+ <Row
20
+ maxWidth='lg'
21
+ {...containerProps}
22
+ className={classes.root}
23
+ sx={[
24
+ (theme) => ({
25
+ gridColumnGap: theme.spacings.md,
26
+ gridRowGap: theme.spacings.lg,
27
+ display: `grid`,
28
+ gridTemplateColumns: `1fr`,
29
+ gridTemplateAreas: `"one" "two"`,
30
+ [theme.breakpoints.up('sm')]: {
31
+ gridTemplateColumns: `1fr 1fr`,
32
+ gridTemplateAreas: `"one two"`,
33
+ },
34
+ }),
35
+ ...(Array.isArray(sx) ? sx : [sx]),
36
+ ]}
37
+ >
38
+ <Box className={classes.colOne} gridArea='one'>
39
+ {colOneContent}
40
+ </Box>
41
+ <Box className={classes.colTwo} gridArea='two'>
42
+ {colTwoContent}
43
+ </Box>
39
44
  </Row>
40
45
  )
41
46
  }
@@ -1,41 +1,32 @@
1
- import { ContainerProps, makeStyles, Theme } from '@material-ui/core'
2
- import React from 'react'
3
- import { UseStyles } from '../../Styles'
4
- import ColumnTwo from '../ColumnTwo'
1
+ import { ColumnTwo, ColumnTwoProps } from '../ColumnTwo'
5
2
 
6
- const useStyles = makeStyles(
7
- ({ breakpoints }: Theme) => ({
8
- root: {
9
- [breakpoints.up('md')]: {
10
- gridTemplateColumns: `1fr 1fr 1fr`,
11
- gridTemplateAreas: ({ somethingWithNodeLength }: any) =>
12
- somethingWithNodeLength ? `"one one two"` : `"one two two"`,
13
- '& h2, & h3': {
14
- '&:empty': {
15
- display: 'block',
16
- minHeight: 30,
17
- },
18
- },
19
- },
20
- gridTemplateColumns: `1fr`,
21
- gridTemplateAreas: `
22
- "one"
23
- "two"
24
- `,
25
- },
26
- }),
27
- { name: 'ColumnTwoSpread' },
28
- )
29
-
30
- export type ColumnTwoSpreadProps = Omit<ContainerProps, 'children'> &
31
- UseStyles<typeof useStyles> & {
32
- nodeLength: boolean
33
- colOneContent: React.ReactNode
34
- colTwoContent: React.ReactNode
35
- }
3
+ type StyleProps = { nodeLength: boolean }
36
4
 
37
- export default function ColumnTwoSpread(props: ColumnTwoSpreadProps) {
38
- const classes = useStyles(props)
5
+ export type ColumnTwoSpreadProps = StyleProps & ColumnTwoProps
39
6
 
40
- return <ColumnTwo {...props} classes={classes} />
7
+ export function ColumnTwoSpread(props: ColumnTwoSpreadProps) {
8
+ const { nodeLength, sx = [], ...colProps } = props
9
+ return (
10
+ <ColumnTwo
11
+ {...colProps}
12
+ className='ColumnTwoSpread'
13
+ sx={[
14
+ (theme) => ({
15
+ [theme.breakpoints.up('md')]: {
16
+ gridTemplateColumns: `1fr 1fr 1fr`,
17
+ gridTemplateAreas: nodeLength ? `"one one two"` : `"one two two"`,
18
+ '& h2, & h3': {
19
+ '&:empty': {
20
+ display: 'block',
21
+ minHeight: 30,
22
+ },
23
+ },
24
+ },
25
+ gridTemplateColumns: `1fr`,
26
+ gridTemplateAreas: `"one" "two"`,
27
+ }),
28
+ ...(Array.isArray(sx) ? sx : [sx]),
29
+ ]}
30
+ />
31
+ )
41
32
  }