@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,78 +1,8 @@
1
1
  import { useScrollOffset } from '@graphcommerce/framer-next-pages'
2
- import { makeStyles, Theme } from '@material-ui/core'
3
- import clsx from 'clsx'
2
+ import { Box, SxProps, Theme } from '@mui/material'
4
3
  import { useTransform, useViewportScroll } from 'framer-motion'
5
- import React from 'react'
6
4
  import LayoutProvider from '../../Layout/components/LayoutProvider'
7
- import { responsiveVal, UseStyles } from '../../Styles'
8
-
9
- const useStyles = makeStyles(
10
- (theme: Theme) => ({
11
- root: {
12
- minHeight: '100vh',
13
- '@supports (-webkit-touch-callout: none)': {
14
- minHeight: '-webkit-fill-available',
15
- },
16
- display: 'grid',
17
- gridTemplateRows: `auto 1fr auto`,
18
- gridTemplateColumns: '100%',
19
- background: theme.palette.background.default,
20
- },
21
- hideFabsOnVirtualKeyboardOpen: {
22
- display: 'flex',
23
- justifyContent: 'space-between',
24
- width: '100%',
25
- height: 0,
26
- zIndex: 2,
27
- [theme.breakpoints.up('sm')]: {
28
- padding: `0 ${theme.page.horizontal}`,
29
- position: 'sticky',
30
- marginTop: `calc(${theme.appShell.headerHeightMd} * -1 + calc(${responsiveVal(
31
- 42,
32
- 56,
33
- )} / 2))`,
34
- top: `calc(${theme.appShell.headerHeightMd} / 2 - 28px)`,
35
- },
36
- [theme.breakpoints.down('sm')]: {
37
- position: 'fixed',
38
- top: 'unset',
39
- bottom: `calc(20px + ${responsiveVal(42, 56)})`,
40
- padding: `0 20px`,
41
- '@media (max-height: 530px)': {
42
- display: 'none',
43
- },
44
- },
45
- },
46
-
47
- header: {
48
- zIndex: theme.zIndex.appBar - 1,
49
- display: 'flex',
50
- alignItems: 'center',
51
- justifyContent: 'center',
52
- height: theme.appShell.headerHeightSm,
53
- pointerEvents: 'none',
54
- '& > *': {
55
- pointerEvents: 'all',
56
- },
57
- [theme.breakpoints.up('md')]: {
58
- height: theme.appShell.headerHeightMd,
59
- padding: `0 ${theme.page.horizontal} 0`,
60
- top: 0,
61
- display: 'flex',
62
- justifyContent: 'left',
63
- width: '100%',
64
- },
65
- },
66
-
67
- headerSticky: {
68
- [theme.breakpoints.down('sm')]: {
69
- position: 'sticky',
70
- top: 0,
71
- },
72
- },
73
- }),
74
- { name: 'LayoutDefault' },
75
- )
5
+ import { extendableComponent, responsiveVal } from '../../Styles'
76
6
 
77
7
  export type LayoutDefaultProps = {
78
8
  className?: string
@@ -83,29 +13,110 @@ export type LayoutDefaultProps = {
83
13
  cartFab?: React.ReactNode
84
14
  children?: React.ReactNode
85
15
  noSticky?: boolean
86
- } & UseStyles<typeof useStyles>
16
+ sx?: SxProps<Theme>
17
+ } & OwnerState
18
+
19
+ type OwnerState = {
20
+ noSticky?: boolean
21
+ }
22
+ const parts = ['root', 'fabs', 'header', 'children', 'footer'] as const
23
+ const { withState } = extendableComponent<OwnerState, 'LayoutDefault', typeof parts>(
24
+ 'LayoutDefault',
25
+ parts,
26
+ )
87
27
 
88
28
  export function LayoutDefault(props: LayoutDefaultProps) {
89
- const { children, header, beforeHeader, footer, menuFab, cartFab, noSticky, className } = props
90
- const classes = useStyles(props)
29
+ const { children, header, beforeHeader, footer, menuFab, cartFab, noSticky, sx = [] } = props
91
30
 
92
31
  const offset = useScrollOffset().y
93
32
  const scrollWithOffset = useTransform(useViewportScroll().scrollY, (y) => y + offset)
94
33
 
34
+ const classes = withState({ noSticky })
35
+ const fabIconSize = responsiveVal(42, 56) // @todo generalize this
36
+
95
37
  return (
96
- <div className={clsx(classes.root, className)}>
38
+ <Box
39
+ className={classes.root}
40
+ sx={[
41
+ (theme) => ({
42
+ minHeight: '100vh',
43
+ '@supports (-webkit-touch-callout: none)': {
44
+ minHeight: '-webkit-fill-available',
45
+ },
46
+ display: 'grid',
47
+ gridTemplateRows: `auto auto 1fr auto`,
48
+ gridTemplateColumns: '100%',
49
+ background: theme.palette.background.default,
50
+ }),
51
+ ...(Array.isArray(sx) ? sx : [sx]),
52
+ ]}
53
+ >
97
54
  <LayoutProvider scroll={scrollWithOffset}>
98
55
  {beforeHeader}
99
- <header className={clsx(classes.header, !noSticky && classes.headerSticky)}>
56
+ <Box
57
+ component='header'
58
+ className={classes.header}
59
+ sx={(theme) => ({
60
+ zIndex: theme.zIndex.appBar - 1,
61
+ display: 'flex',
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ height: theme.appShell.headerHeightSm,
65
+ pointerEvents: 'none',
66
+ '& > *': {
67
+ pointerEvents: 'all',
68
+ },
69
+ [theme.breakpoints.up('md')]: {
70
+ height: theme.appShell.headerHeightMd,
71
+ padding: `0 ${theme.page.horizontal} 0`,
72
+ top: 0,
73
+ display: 'flex',
74
+ justifyContent: 'left',
75
+ width: '100%',
76
+ },
77
+ '&.sticky': {
78
+ [theme.breakpoints.down('md')]: {
79
+ position: 'sticky',
80
+ top: 0,
81
+ },
82
+ },
83
+ })}
84
+ >
100
85
  {header}
101
- </header>
102
- <div className={classes.hideFabsOnVirtualKeyboardOpen}>
103
- {menuFab}
104
- {cartFab}
105
- </div>
106
- <div>{children}</div>
107
- <div>{footer}</div>
86
+ </Box>
87
+ {(menuFab || cartFab) && (
88
+ <Box
89
+ className={classes.fabs}
90
+ sx={(theme) => ({
91
+ display: 'flex',
92
+ justifyContent: 'space-between',
93
+ width: '100%',
94
+ height: 0,
95
+ zIndex: 2,
96
+ [theme.breakpoints.up('sm')]: {
97
+ padding: `0 ${theme.page.horizontal}`,
98
+ position: 'sticky',
99
+ marginTop: `calc(${theme.appShell.headerHeightMd} * -1 + calc(${fabIconSize} / 2))`,
100
+ top: `calc(${theme.appShell.headerHeightMd} / 2 - 28px)`,
101
+ },
102
+ [theme.breakpoints.down('md')]: {
103
+ position: 'fixed',
104
+ top: 'unset',
105
+ bottom: `calc(20px + ${fabIconSize})`,
106
+ padding: `0 20px`,
107
+ '@media (max-height: 530px)': {
108
+ display: 'none',
109
+ },
110
+ },
111
+ })}
112
+ >
113
+ {menuFab}
114
+ {cartFab}
115
+ </Box>
116
+ )}
117
+ <div className={classes.children}>{children}</div>
118
+ <div className={classes.footer}>{footer}</div>
108
119
  </LayoutProvider>
109
- </div>
120
+ </Box>
110
121
  )
111
122
  }
@@ -1,5 +1,4 @@
1
1
  import { ScrollerProvider, ScrollSnapType } from '@graphcommerce/framer-scroller'
2
- import React from 'react'
3
2
  import { SetOptional } from 'type-fest'
4
3
  import { LayoutOverlayBase, LayoutOverlayBaseProps } from './LayoutOverlayBase'
5
4
 
@@ -8,7 +7,7 @@ export type { LayoutOverlayVariant } from './LayoutOverlayBase'
8
7
  export type LayoutOverlayProps = SetOptional<LayoutOverlayBaseProps, 'variantSm' | 'variantMd'>
9
8
 
10
9
  export function LayoutOverlay(props: LayoutOverlayProps) {
11
- const { children, variantSm = 'bottom', variantMd = 'right', classes, ...otherProps } = props
10
+ const { children, variantSm = 'bottom', variantMd = 'right', ...otherProps } = props
12
11
 
13
12
  const scrollSnapTypeSm: ScrollSnapType =
14
13
  variantSm === 'left' || variantSm === 'right' ? 'inline mandatory' : 'block proximity'
@@ -17,12 +16,7 @@ export function LayoutOverlay(props: LayoutOverlayProps) {
17
16
 
18
17
  return (
19
18
  <ScrollerProvider scrollSnapTypeSm={scrollSnapTypeSm} scrollSnapTypeMd={scrollSnapTypeMd}>
20
- <LayoutOverlayBase
21
- variantMd={variantMd}
22
- variantSm={variantSm}
23
- classes={classes}
24
- {...otherProps}
25
- >
19
+ <LayoutOverlayBase variantMd={variantMd} variantSm={variantSm} {...otherProps}>
26
20
  {children}
27
21
  </LayoutOverlayBase>
28
22
  </ScrollerProvider>