@graphcommerce/next-ui 3.25.2 → 4.0.1

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 (138) 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 +507 -642
  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 +21 -12
  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 +131 -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 -35
  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/MuiButton.ts +128 -0
  100. package/Theme/MuiSlider.ts +28 -0
  101. package/Theme/MuiSnackbar.ts +31 -0
  102. package/Theme/{types.ts → createTheme.ts} +8 -2
  103. package/Theme/index.ts +4 -0
  104. package/Theme/themeDefaults.ts +51 -0
  105. package/TimeAgo/index.tsx +1 -1
  106. package/ToggleButton/index.tsx +43 -49
  107. package/ToggleButtonGroup/index.tsx +39 -39
  108. package/UspList/UspListItem.tsx +56 -46
  109. package/UspList/index.tsx +29 -26
  110. package/docs/building-components.mdx +3 -0
  111. package/docs/components/ComponentBasic.tsx +26 -0
  112. package/docs/components/ComponentChild.tsx +48 -0
  113. package/docs/components/ComponentChildVariant.tsx +54 -0
  114. package/docs/components/ComponentChildVariantExtendable.tsx +62 -0
  115. package/docs/components/ComponentStylable.tsx +32 -0
  116. package/docs/pages/building-components.tsx +62 -0
  117. package/index.ts +27 -81
  118. package/package.json +27 -27
  119. package/types.d.ts +1 -1
  120. package/AppShell/AppShellSticky/index.tsx +0 -38
  121. package/AppShell/DesktopNavActions.tsx +0 -32
  122. package/AppShell/DesktopNavBar.tsx +0 -158
  123. package/AppShell/Logo.tsx +0 -46
  124. package/AppShell/Menu.tsx +0 -7
  125. package/AppShell/MenuFab.tsx +0 -162
  126. package/AppShell/MenuFabSecondaryItem.tsx +0 -32
  127. package/AppShell/index.ts +0 -15
  128. package/AspectRatioContainer/index.tsx +0 -27
  129. package/Footer/SocialIcon.tsx +0 -23
  130. package/Form/index.tsx +0 -67
  131. package/FramerScroller/components/SidebarGallery.tsx +0 -317
  132. package/FramerScroller/components/SidebarSlider.tsx +0 -97
  133. package/Page/App.tsx +0 -17
  134. package/Page/Document.tsx +0 -24
  135. package/StyledBadge/index.tsx +0 -20
  136. package/Styles/classesPicker.ts +0 -41
  137. package/SvgImage/SvgImageSimple.tsx +0 -100
  138. package/SvgImage/index.tsx +0 -74
@@ -0,0 +1,80 @@
1
+ import { Link, LinkProps, useForkRef } from '@mui/material'
2
+ import React, { useRef } from 'react'
3
+ import { ConditionalExcept } from 'type-fest'
4
+ import { Button, ButtonProps } from './Button'
5
+
6
+ type OmitNever<T extends Record<string, unknown>> = {
7
+ [K in keyof T as T[K] extends never ? never : K]: T[K]
8
+ }
9
+ type SharedProperties<A, B> = OmitNever<
10
+ ConditionalExcept<Pick<A & B, keyof A & keyof B>, Record<string, unknown> | undefined>
11
+ >
12
+
13
+ export type LinkOrButtonProps = {
14
+ button?: ButtonProps
15
+ link?: LinkProps
16
+ breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
17
+ } & SharedProperties<
18
+ Omit<ButtonProps, 'sx'>,
19
+ Omit<LinkProps, 'color' | 'sx'> & Pick<ButtonProps, 'endIcon' | 'startIcon' | 'color' | 'loading'>
20
+ >
21
+
22
+ /** Renders a Link until the breakpoint is reached and will then render a button. */
23
+ export const LinkOrButton = React.forwardRef<
24
+ HTMLButtonElement & HTMLAnchorElement,
25
+ LinkOrButtonProps
26
+ >((props, ref) => {
27
+ const {
28
+ // Own created props
29
+ breakpoint = 'md',
30
+ button,
31
+ link,
32
+
33
+ // Shared props
34
+ loading,
35
+ children,
36
+ startIcon,
37
+ endIcon,
38
+ color,
39
+ ...sharedProps
40
+ } = props
41
+
42
+ const buttonRef = useForkRef(ref, useRef(null))
43
+ const linkRef = useForkRef(ref, useRef(null))
44
+
45
+ return (
46
+ <>
47
+ <Button
48
+ sx={{ display: { xs: 'none', [breakpoint]: 'inline-flex' }, ...button?.sx }}
49
+ ref={buttonRef}
50
+ startIcon={startIcon}
51
+ endIcon={endIcon}
52
+ color={color}
53
+ loading={loading}
54
+ {...sharedProps}
55
+ {...button}
56
+ >
57
+ {children}
58
+ </Button>
59
+
60
+ <Link
61
+ sx={{
62
+ display: { xs: 'inline-flex', [breakpoint]: 'none' },
63
+ alignItems: 'center',
64
+ ...link?.sx,
65
+ }}
66
+ ref={linkRef}
67
+ color={loading ? 'text.disabled' : color}
68
+ underline='none'
69
+ aria-disabled={loading}
70
+ variant='body2'
71
+ {...sharedProps}
72
+ {...link}
73
+ >
74
+ {startIcon}
75
+ <span>{children}</span>
76
+ {endIcon}
77
+ </Link>
78
+ </>
79
+ )
80
+ })
package/Button/index.tsx CHANGED
@@ -1,177 +1,2 @@
1
- import {
2
- Button as MuiButton,
3
- ButtonClassKey as MuiButtonClassKey,
4
- Theme,
5
- makeStyles,
6
- } from '@material-ui/core'
7
- import clsx from 'clsx'
8
- import React from 'react'
9
-
10
- type BaseButtonProps = Omit<Parameters<typeof MuiButton>['0'], 'variant' | 'classes'> & {
11
- variant?: 'text' | 'outlined' | 'contained' | 'pill' | 'pill-link'
12
- }
13
-
14
- type ButtonClassKey =
15
- | 'pill'
16
- | 'pillLink'
17
- | 'pillPrimary'
18
- | 'pillSecondary'
19
- | 'pillSizeLarge'
20
- | 'pillSizeSmall'
21
- | 'pillNoElevation'
22
- | 'withStartIcon'
23
- | 'startIconText'
24
- | 'loading'
25
-
26
- type ClassKeys = ButtonClassKey | MuiButtonClassKey
27
-
28
- export type ButtonProps = BaseButtonProps & {
29
- classes?: { [index in ClassKeys]?: string }
30
- loading?: boolean
31
- text?: Text
32
- }
33
-
34
- const useStyles = makeStyles<
35
- Theme,
36
- BaseButtonProps & { classes?: { [index in ButtonClassKey]?: string } },
37
- ButtonClassKey
38
- >(
39
- (theme: Theme) => ({
40
- root: {},
41
- label: {},
42
- disabled: {},
43
- withStartIcon: {
44
- [theme.breakpoints.down('sm')]: {
45
- height: 40,
46
- width: 40,
47
- textAlign: 'center',
48
- minWidth: 'unset',
49
- borderRadius: 99,
50
- '& > span > .MuiButton-startIcon': {
51
- margin: 'unset',
52
- },
53
- },
54
- },
55
- pill: {
56
- borderRadius: '99em',
57
- },
58
- pillLink: {
59
- [theme.breakpoints.up('md')]: {
60
- // manually match MuiButton and containedPrimary styles
61
- textTransform: 'none',
62
- ...theme.typography.body2,
63
- fontWeight: 400,
64
- borderRadius: '99em',
65
- boxShadow: theme.shadows[6],
66
- backgroundColor: theme.palette.background.paper,
67
- color: theme.palette.text.primary,
68
- '&:hover': {
69
- background: theme.palette.background.paper,
70
- },
71
- },
72
- },
73
- pillPrimary: {
74
- [theme.breakpoints.up('md')]: {
75
- backgroundColor: theme.palette.primary.main,
76
- color: theme.palette.primary.contrastText,
77
- '&:hover': {
78
- background: theme.palette.primary.dark,
79
- },
80
- },
81
- },
82
- pillSecondary: {
83
- [theme.breakpoints.up('md')]: {
84
- backgroundColor: theme.palette.secondary.main,
85
- color: theme.palette.secondary.contrastText,
86
- '&:hover': {
87
- background: theme.palette.secondary.dark,
88
- },
89
- },
90
- },
91
- pillSizeLarge: {},
92
- pillSizeSmall: {},
93
- pillNoElevation: {
94
- /* disableElevation does not stop adding box shadow on active... ?! */
95
- '&:active': {
96
- boxShadow: 'none',
97
- },
98
- },
99
- startIconText: {
100
- display: 'none',
101
- [theme.breakpoints.up('md')]: {
102
- display: 'unset',
103
- },
104
- },
105
- loading: {
106
- '& svg': {
107
- stroke: theme.palette.text.disabled,
108
- },
109
- },
110
- }),
111
- { name: 'MuiPillButton' },
112
- )
113
-
114
- export default React.forwardRef<any, ButtonProps>((props, ref) => {
115
- const { classes = {}, ...baseProps } = props
116
- const { variant, color, size, className, children, loading, disabled, text, ...buttonProps } =
117
- baseProps
118
- const {
119
- pill,
120
- pillPrimary,
121
- pillSecondary,
122
- pillSizeLarge,
123
- pillSizeSmall,
124
- pillLink,
125
- ...buttonClasses
126
- } = classes
127
-
128
- const pillClasses = useStyles({
129
- ...baseProps,
130
- classes: {
131
- pill,
132
- pillPrimary,
133
- pillSecondary,
134
- pillSizeLarge,
135
- pillSizeSmall,
136
- pillLink,
137
- ...buttonClasses,
138
- },
139
- })
140
-
141
- const variantMap = {
142
- pill: 'contained',
143
- 'pill-link': 'text',
144
- }
145
-
146
- const withIcon = typeof buttonProps.startIcon !== 'undefined'
147
- const content = <>{loading ? <>Loading</> : children}</>
148
-
149
- return (
150
- <MuiButton
151
- {...buttonProps}
152
- classes={buttonClasses}
153
- color={color}
154
- variant={variantMap[variant ?? ''] ?? variant}
155
- size={size}
156
- ref={ref}
157
- disabled={loading || disabled}
158
- className={clsx(
159
- {
160
- [pillClasses.pill]: variant?.startsWith('pill'),
161
- [pillClasses.pillLink]: variant === 'pill-link',
162
- [pillClasses.pillPrimary]: variant?.startsWith('pill') && color === 'primary',
163
- [pillClasses.pillSecondary]: variant?.startsWith('pill') && color === 'secondary',
164
- [pillClasses.pillSizeLarge]: variant?.startsWith('pill') && size === 'large',
165
- [pillClasses.pillSizeSmall]: variant?.startsWith('pill') && size === 'small',
166
- [pillClasses.pillNoElevation]: buttonProps.disableElevation,
167
- [pillClasses.loading]: loading,
168
- [pillClasses.withStartIcon]: withIcon,
169
- },
170
- className,
171
- )}
172
- >
173
- {withIcon && <span className={pillClasses.startIconText}>{content}</span>}
174
- {!withIcon && content}
175
- </MuiButton>
176
- )
177
- })
1
+ export * from './Button'
2
+ export * from './LinkOrButton'