@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.
- package/AnimatedRow/index.tsx +6 -3
- package/ApolloError/ApolloErrorAlert.tsx +20 -21
- package/ApolloError/ApolloErrorFullPage.tsx +3 -4
- package/ApolloError/ApolloErrorSnackbar.tsx +3 -3
- package/Blog/BlogAuthor/index.tsx +42 -48
- package/Blog/BlogContent/index.tsx +6 -23
- package/Blog/BlogHeader/index.tsx +26 -23
- package/Blog/BlogList/index.tsx +7 -25
- package/Blog/BlogListItem/index.tsx +63 -52
- package/Blog/BlogTags/BlogTag.tsx +27 -0
- package/Blog/BlogTags/index.tsx +7 -32
- package/Blog/BlogTitle/index.tsx +7 -21
- package/Button/Button.tsx +5 -0
- package/Button/LinkOrButton.tsx +80 -0
- package/Button/index.tsx +2 -177
- package/CHANGELOG.md +507 -642
- package/ChipMenu/index.tsx +71 -77
- package/ContainerWithHeader/index.tsx +33 -30
- package/FlagAvatar/index.tsx +2 -12
- package/Footer/Footer.tsx +105 -88
- package/Footer/index.ts +0 -1
- package/Form/Form.tsx +35 -0
- package/Form/FormActions.tsx +9 -14
- package/Form/FormDivider.tsx +8 -13
- package/Form/FormHeader.tsx +5 -26
- package/Form/FormRow.tsx +8 -13
- package/Form/InputCheckmark.tsx +9 -22
- package/FramerScroller/SidebarGallery.tsx +340 -0
- package/FramerScroller/SidebarSlider.tsx +107 -0
- package/FramerScroller/index.ts +2 -0
- package/FullPageMessage/index.tsx +52 -48
- package/Highlight/index.tsx +1 -1
- package/IconHeader/index.tsx +63 -58
- package/JsonLd/index.tsx +3 -2
- package/Layout/components/LayoutHeader.tsx +75 -82
- package/Layout/components/LayoutHeaderBack.tsx +21 -12
- package/Layout/components/LayoutHeaderClose.tsx +9 -22
- package/Layout/components/LayoutHeaderContent.tsx +190 -154
- package/Layout/components/LayoutHeadertypes.ts +1 -1
- package/Layout/components/LayoutTitle.tsx +60 -55
- package/LayoutDefault/components/LayoutDefault.tsx +96 -85
- package/LayoutOverlay/components/LayoutOverlay.tsx +2 -8
- package/LayoutOverlay/components/LayoutOverlayBase.tsx +233 -239
- package/LayoutOverlay/test/LayoutOverlayDemo.tsx +1 -1
- package/LayoutParts/DesktopHeaderBadge.tsx +28 -0
- package/LayoutParts/DesktopNavActions.tsx +15 -0
- package/LayoutParts/DesktopNavBar.tsx +113 -0
- package/LayoutParts/DesktopNavBarItem.tsx +44 -0
- package/{AppShell → LayoutParts}/GlobalHead.tsx +1 -2
- package/LayoutParts/Logo.tsx +77 -0
- package/LayoutParts/MenuFab.tsx +131 -0
- package/LayoutParts/MenuFabItem.tsx +25 -0
- package/LayoutParts/MenuFabSecondaryItem.tsx +37 -0
- package/{AppShell/PlaceholderFab/index.tsx → LayoutParts/PlaceholderFab.tsx} +1 -1
- package/LayoutParts/StickyBelowHeader.tsx +25 -0
- package/LayoutParts/index.ts +12 -0
- package/{AppShell → LayoutParts}/useFabAnimation.ts +0 -0
- package/Page/CssAndFramerMotionProvider.tsx +21 -0
- package/Page/index.ts +2 -0
- package/Page/types.ts +2 -8
- package/PageLoadIndicator/index.tsx +25 -30
- package/PageMeta/index.tsx +1 -1
- package/Pagination/index.tsx +37 -54
- package/RenderType/index.tsx +1 -1
- package/Row/ButtonLinkList/ButtonLinkList.tsx +35 -37
- package/Row/ButtonLinkList/ButtonLinkListItem.tsx +16 -33
- package/Row/ColumnOne/index.tsx +5 -10
- package/Row/ColumnOneBoxed/index.tsx +18 -19
- package/Row/ColumnOneCentered/index.tsx +3 -4
- package/Row/ColumnThree/index.tsx +62 -57
- package/Row/ColumnTwo/index.tsx +37 -35
- package/Row/ColumnTwoSpread/index.tsx +28 -37
- package/Row/ColumnTwoWithTop/index.tsx +37 -43
- package/Row/ContentLinks/index.tsx +24 -25
- package/Row/HeroBanner/index.tsx +98 -82
- package/Row/IconBlocks/IconBlock/index.tsx +45 -37
- package/Row/IconBlocks/index.tsx +29 -44
- package/Row/ImageText/index.tsx +71 -67
- package/Row/ImageTextBoxed/index.tsx +66 -65
- package/Row/ParagraphWithSidebarSlide/index.tsx +80 -76
- package/Row/Quote/index.tsx +3 -3
- package/Row/SpecialBanner/index.tsx +97 -97
- package/Row/index.tsx +4 -9
- package/SectionContainer/index.tsx +32 -31
- package/SectionHeader/index.tsx +41 -43
- package/Separator/index.tsx +19 -18
- package/Snackbar/MessageSnackbar.tsx +1 -2
- package/Snackbar/MessageSnackbarImpl.tsx +68 -115
- package/StarRatingField/index.tsx +24 -25
- package/Stepper/Stepper.tsx +34 -32
- package/Styles/EmotionProvider.tsx +14 -0
- package/Styles/breakpointVal.tsx +16 -10
- package/Styles/extendableComponent.ts +70 -0
- package/Styles/index.tsx +9 -2
- package/Styles/withEmotionCache.tsx +36 -0
- package/Styles/withTheme.tsx +15 -24
- package/SvgIcon/SvgIcon.tsx +60 -0
- package/TextInputNumber/index.tsx +49 -50
- package/Theme/MuiButton.ts +128 -0
- package/Theme/MuiSlider.ts +28 -0
- package/Theme/MuiSnackbar.ts +31 -0
- package/Theme/{types.ts → createTheme.ts} +8 -2
- package/Theme/index.ts +4 -0
- package/Theme/themeDefaults.ts +51 -0
- package/TimeAgo/index.tsx +1 -1
- package/ToggleButton/index.tsx +43 -49
- package/ToggleButtonGroup/index.tsx +39 -39
- package/UspList/UspListItem.tsx +56 -46
- package/UspList/index.tsx +29 -26
- package/docs/building-components.mdx +3 -0
- package/docs/components/ComponentBasic.tsx +26 -0
- package/docs/components/ComponentChild.tsx +48 -0
- package/docs/components/ComponentChildVariant.tsx +54 -0
- package/docs/components/ComponentChildVariantExtendable.tsx +62 -0
- package/docs/components/ComponentStylable.tsx +32 -0
- package/docs/pages/building-components.tsx +62 -0
- package/index.ts +27 -81
- package/package.json +27 -27
- package/types.d.ts +1 -1
- package/AppShell/AppShellSticky/index.tsx +0 -38
- package/AppShell/DesktopNavActions.tsx +0 -32
- package/AppShell/DesktopNavBar.tsx +0 -158
- package/AppShell/Logo.tsx +0 -46
- package/AppShell/Menu.tsx +0 -7
- package/AppShell/MenuFab.tsx +0 -162
- package/AppShell/MenuFabSecondaryItem.tsx +0 -32
- package/AppShell/index.ts +0 -15
- package/AspectRatioContainer/index.tsx +0 -27
- package/Footer/SocialIcon.tsx +0 -23
- package/Form/index.tsx +0 -67
- package/FramerScroller/components/SidebarGallery.tsx +0 -317
- package/FramerScroller/components/SidebarSlider.tsx +0 -97
- package/Page/App.tsx +0 -17
- package/Page/Document.tsx +0 -24
- package/StyledBadge/index.tsx +0 -20
- package/Styles/classesPicker.ts +0 -41
- package/SvgImage/SvgImageSimple.tsx +0 -100
- package/SvgImage/index.tsx +0 -74
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Scroller,
|
|
3
|
-
ScrollerButton,
|
|
4
|
-
ScrollerPageCounter,
|
|
5
|
-
ScrollerProvider,
|
|
6
|
-
} from '@graphcommerce/framer-scroller'
|
|
7
|
-
import { Theme, makeStyles } from '@material-ui/core'
|
|
8
|
-
import React, { ReactNode } from 'react'
|
|
9
|
-
import Row from '../../Row'
|
|
10
|
-
import { UseStyles } from '../../Styles'
|
|
11
|
-
import { responsiveVal } from '../../Styles/responsiveVal'
|
|
12
|
-
import SvgImageSimple from '../../SvgImage/SvgImageSimple'
|
|
13
|
-
import { iconChevronLeft, iconChevronRight } from '../../icons'
|
|
14
|
-
|
|
15
|
-
const useStyles = makeStyles(
|
|
16
|
-
(theme: Theme) => ({
|
|
17
|
-
root: {
|
|
18
|
-
display: 'grid',
|
|
19
|
-
gridTemplateColumns: 'minmax(150px, 25%) 1fr',
|
|
20
|
-
maxWidth: '100%',
|
|
21
|
-
},
|
|
22
|
-
sidebar: {
|
|
23
|
-
display: 'grid',
|
|
24
|
-
alignContent: 'space-between',
|
|
25
|
-
padding: `0 ${theme.spacings.lg} 0 ${theme.page.horizontal}`,
|
|
26
|
-
},
|
|
27
|
-
scrollerContainer: {
|
|
28
|
-
position: 'relative',
|
|
29
|
-
minWidth: 1,
|
|
30
|
-
},
|
|
31
|
-
scroller: {
|
|
32
|
-
gridColumnGap: theme.spacings.md,
|
|
33
|
-
gridRowGap: theme.spacings.lg,
|
|
34
|
-
paddingRight: theme.page.horizontal,
|
|
35
|
-
gridAutoColumns: responsiveVal(200, 400),
|
|
36
|
-
},
|
|
37
|
-
sliderButtons: {
|
|
38
|
-
[theme.breakpoints.down('sm')]: {
|
|
39
|
-
display: 'none',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
centerLeft: {
|
|
43
|
-
display: 'grid',
|
|
44
|
-
gridAutoFlow: 'row',
|
|
45
|
-
gap: theme.spacings.xxs,
|
|
46
|
-
position: 'absolute',
|
|
47
|
-
left: theme.spacings.sm,
|
|
48
|
-
top: `calc(50% - 28px)`,
|
|
49
|
-
},
|
|
50
|
-
centerRight: {
|
|
51
|
-
display: 'grid',
|
|
52
|
-
gap: theme.spacings.xxs,
|
|
53
|
-
position: 'absolute',
|
|
54
|
-
right: theme.spacings.sm,
|
|
55
|
-
top: `calc(50% - 28px)`,
|
|
56
|
-
},
|
|
57
|
-
}),
|
|
58
|
-
{ name: 'SidebarSlider' },
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
export type SidebarSliderProps = { children: ReactNode; sidebar: ReactNode } & UseStyles<
|
|
62
|
-
typeof useStyles
|
|
63
|
-
>
|
|
64
|
-
|
|
65
|
-
export default function SidebarSlider(props: SidebarSliderProps) {
|
|
66
|
-
const { children, sidebar } = props
|
|
67
|
-
const classes = useStyles(props)
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<Row maxWidth={false} disableGutters>
|
|
71
|
-
<ScrollerProvider scrollSnapAlign='start'>
|
|
72
|
-
<div className={classes.root}>
|
|
73
|
-
<div className={classes.sidebar}>
|
|
74
|
-
<div>{sidebar}</div>
|
|
75
|
-
<ScrollerPageCounter />
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<div className={classes.scrollerContainer}>
|
|
79
|
-
<Scroller className={classes.scroller} hideScrollbar>
|
|
80
|
-
{children}
|
|
81
|
-
</Scroller>
|
|
82
|
-
<div className={classes.centerLeft}>
|
|
83
|
-
<ScrollerButton direction='left' className={classes.sliderButtons}>
|
|
84
|
-
<SvgImageSimple src={iconChevronLeft} />
|
|
85
|
-
</ScrollerButton>
|
|
86
|
-
</div>
|
|
87
|
-
<div className={classes.centerRight}>
|
|
88
|
-
<ScrollerButton direction='right' className={classes.sliderButtons}>
|
|
89
|
-
<SvgImageSimple src={iconChevronRight} />
|
|
90
|
-
</ScrollerButton>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</ScrollerProvider>
|
|
95
|
-
</Row>
|
|
96
|
-
)
|
|
97
|
-
}
|
package/Page/App.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FramerNextPages } from '@graphcommerce/framer-next-pages'
|
|
2
|
-
import { LazyMotion } from 'framer-motion'
|
|
3
|
-
import { AppPropsType } from 'next/dist/shared/lib/utils'
|
|
4
|
-
import React, { useEffect } from 'react'
|
|
5
|
-
import PageLoadIndicator from '../PageLoadIndicator'
|
|
6
|
-
import { AppProps } from './types'
|
|
7
|
-
|
|
8
|
-
export default function App(props: AppProps & AppPropsType) {
|
|
9
|
-
useEffect(() => document.getElementById('jss-server-side')?.remove())
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<LazyMotion features={async () => (await import('./framerFeatures')).default} strict>
|
|
13
|
-
<PageLoadIndicator />
|
|
14
|
-
<FramerNextPages {...props} />
|
|
15
|
-
</LazyMotion>
|
|
16
|
-
)
|
|
17
|
-
}
|
package/Page/Document.tsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ServerStyleSheets } from '@material-ui/core/styles'
|
|
2
|
-
// eslint-disable-next-line @next/next/no-document-import-in-page
|
|
3
|
-
import NextDocument, { DocumentContext, DocumentInitialProps } from 'next/document'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
export default class Document extends NextDocument {
|
|
7
|
-
static getInitialProps = async (ctx: DocumentContext): Promise<DocumentInitialProps> => {
|
|
8
|
-
const sheets = new ServerStyleSheets()
|
|
9
|
-
const originalRenderPage = ctx.renderPage
|
|
10
|
-
|
|
11
|
-
ctx.renderPage = () =>
|
|
12
|
-
originalRenderPage({
|
|
13
|
-
enhanceApp: (App) => (props) => sheets.collect(<App {...props} />),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const initialProps = await NextDocument.getInitialProps(ctx)
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
...initialProps,
|
|
20
|
-
// Styles fragment is rendered after the app and page rendering finish.
|
|
21
|
-
styles: [...React.Children.toArray(initialProps.styles), sheets.getStyleElement()],
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
package/StyledBadge/index.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Badge, withStyles } from '@material-ui/core'
|
|
2
|
-
|
|
3
|
-
const StyledBadge = withStyles((theme) => ({
|
|
4
|
-
colorError: {},
|
|
5
|
-
badge: {
|
|
6
|
-
...theme.typography.caption,
|
|
7
|
-
right: 6,
|
|
8
|
-
top: 6,
|
|
9
|
-
padding: 3,
|
|
10
|
-
color: '#FFF',
|
|
11
|
-
borderRadius: '100%',
|
|
12
|
-
[theme.breakpoints.up('md')]: {
|
|
13
|
-
padding: 6,
|
|
14
|
-
right: 8,
|
|
15
|
-
top: 8,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
}))(Badge)
|
|
19
|
-
|
|
20
|
-
export default StyledBadge
|
package/Styles/classesPicker.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { capitalize } from '@material-ui/core'
|
|
2
|
-
import clsx from 'clsx'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This will pick classNames from the classes object based on the given value object.sf
|
|
6
|
-
*
|
|
7
|
-
* Example:
|
|
8
|
-
*
|
|
9
|
-
* ```tsx
|
|
10
|
-
* const classes = makeStyles({
|
|
11
|
-
* root: {},
|
|
12
|
-
* rootColorRed: { color: 'red' }
|
|
13
|
-
* rootFloating: { display: 'inline-block' }
|
|
14
|
-
* })
|
|
15
|
-
*
|
|
16
|
-
* function MyComponent() {
|
|
17
|
-
* const classes = useStyles(props)
|
|
18
|
-
* const classNames = pickClasses(classes, { color: 'red', floating: true })
|
|
19
|
-
*
|
|
20
|
-
* return <div {...className('root')}>Hello</div>
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function classesPicker<K extends string>(
|
|
25
|
-
classes: Record<string, string>,
|
|
26
|
-
values: Record<string, boolean | string | undefined>,
|
|
27
|
-
) {
|
|
28
|
-
return (className: K, addClassName?: string) => {
|
|
29
|
-
const mapped: Record<string, string> = Object.fromEntries(
|
|
30
|
-
Object.entries(values)
|
|
31
|
-
.map(([key, value]) =>
|
|
32
|
-
typeof value === 'boolean' || typeof value === 'undefined'
|
|
33
|
-
? [classes[`${className}${capitalize(key)}`], !!value]
|
|
34
|
-
: [classes[`${className}${capitalize(key)}${capitalize(value)}`], true],
|
|
35
|
-
)
|
|
36
|
-
.filter((v) => !!v[0] && v[1]),
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
return { className: clsx(classes[className], mapped, addClassName) }
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { ImageProps, isStaticImport, isStaticRequire } from '@graphcommerce/image'
|
|
2
|
-
import { makeStyles, capitalize } from '@material-ui/core'
|
|
3
|
-
import clsx from 'clsx'
|
|
4
|
-
import { forwardRef } from 'react'
|
|
5
|
-
import { responsiveVal } from '../Styles/responsiveVal'
|
|
6
|
-
|
|
7
|
-
export type SvgImageShade = 'muted' | 'default' | 'inverted'
|
|
8
|
-
|
|
9
|
-
const useStyles = makeStyles(
|
|
10
|
-
{
|
|
11
|
-
image: {
|
|
12
|
-
userSelect: 'none',
|
|
13
|
-
width: responsiveVal(22, 24),
|
|
14
|
-
height: responsiveVal(22, 24),
|
|
15
|
-
strokeWidth: 1.8,
|
|
16
|
-
strokeLinecap: 'square',
|
|
17
|
-
strokeLinejoin: 'miter',
|
|
18
|
-
fill: 'none',
|
|
19
|
-
stroke: 'currentColor',
|
|
20
|
-
},
|
|
21
|
-
sizeInherit: {
|
|
22
|
-
fontSize: 'inherit',
|
|
23
|
-
},
|
|
24
|
-
sizeXs: {
|
|
25
|
-
width: responsiveVal(11, 13),
|
|
26
|
-
height: responsiveVal(11, 13),
|
|
27
|
-
strokeWidth: 2.1,
|
|
28
|
-
},
|
|
29
|
-
sizeSmall: {
|
|
30
|
-
width: responsiveVal(12, 16),
|
|
31
|
-
height: responsiveVal(12, 16),
|
|
32
|
-
strokeWidth: 2.1,
|
|
33
|
-
},
|
|
34
|
-
sizeLarge: {
|
|
35
|
-
width: responsiveVal(24, 28),
|
|
36
|
-
height: responsiveVal(24, 28),
|
|
37
|
-
strokeWidth: 1.4,
|
|
38
|
-
},
|
|
39
|
-
sizeXl: {
|
|
40
|
-
width: responsiveVal(38, 62),
|
|
41
|
-
height: responsiveVal(38, 62),
|
|
42
|
-
strokeWidth: 1.4,
|
|
43
|
-
},
|
|
44
|
-
sizeXxl: {
|
|
45
|
-
width: responsiveVal(96, 148),
|
|
46
|
-
height: responsiveVal(96, 148),
|
|
47
|
-
strokeWidth: 0.8,
|
|
48
|
-
},
|
|
49
|
-
muted: {},
|
|
50
|
-
inverted: {},
|
|
51
|
-
},
|
|
52
|
-
{ name: 'SvgImageSimple' },
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
type SvgImageSimpleProps = Omit<ImageProps, 'fixed'> & {
|
|
56
|
-
/** The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. */
|
|
57
|
-
size?: 'default' | 'inherit' | 'xxl' | 'xl' | 'large' | 'medium' | 'small' | 'xs'
|
|
58
|
-
fill?: boolean
|
|
59
|
-
muted?: boolean
|
|
60
|
-
inverted?: boolean
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const SvgImageSimple = forwardRef<SVGSVGElement, SvgImageSimpleProps>((props, ref) => {
|
|
64
|
-
const {
|
|
65
|
-
style,
|
|
66
|
-
className,
|
|
67
|
-
size = 'medium',
|
|
68
|
-
muted,
|
|
69
|
-
inverted,
|
|
70
|
-
fill,
|
|
71
|
-
layout = 'fixed',
|
|
72
|
-
...imageProps
|
|
73
|
-
} = props
|
|
74
|
-
const classes = useStyles()
|
|
75
|
-
|
|
76
|
-
let { src } = imageProps
|
|
77
|
-
let staticSrc = ''
|
|
78
|
-
if (isStaticImport(src)) staticSrc = (isStaticRequire(src) ? src.default : src).src
|
|
79
|
-
src = typeof src === 'string' ? src : staticSrc
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<svg
|
|
83
|
-
ref={ref}
|
|
84
|
-
className={clsx(
|
|
85
|
-
className,
|
|
86
|
-
classes.image,
|
|
87
|
-
classes?.[`size${capitalize(size)}`],
|
|
88
|
-
muted && classes.muted,
|
|
89
|
-
inverted && classes.inverted,
|
|
90
|
-
)}
|
|
91
|
-
aria-hidden='true'
|
|
92
|
-
style={style}
|
|
93
|
-
>
|
|
94
|
-
<use href={`${src}#icon`} />
|
|
95
|
-
</svg>
|
|
96
|
-
)
|
|
97
|
-
})
|
|
98
|
-
SvgImageSimple.displayName = 'SvgImageSimple'
|
|
99
|
-
|
|
100
|
-
export default SvgImageSimple
|
package/SvgImage/index.tsx
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Image, ImageProps } from '@graphcommerce/image'
|
|
2
|
-
import { makeStyles, Theme } from '@material-ui/core'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { UseStyles } from '../Styles'
|
|
5
|
-
|
|
6
|
-
// TODO: fix hot reloading issues when modifying implementations of this component
|
|
7
|
-
export type SvgImageSize = 'small' | 'medium' | 'large' | 'extralarge'
|
|
8
|
-
|
|
9
|
-
export type SvgImageProps = ImageProps & {
|
|
10
|
-
size?: SvgImageSize | number
|
|
11
|
-
mobileSize?: SvgImageSize | number
|
|
12
|
-
shade?: SvgImageShade
|
|
13
|
-
} & UseStyles<typeof useStyles>
|
|
14
|
-
|
|
15
|
-
export type SvgImageShade = 'muted' | 'default' | 'inverted'
|
|
16
|
-
|
|
17
|
-
export const SvgImageShades: Record<SvgImageShade, number> = {
|
|
18
|
-
muted: 75,
|
|
19
|
-
default: 0,
|
|
20
|
-
inverted: 100,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type UseStylesProps = { shade: number; baseSize: number; mobileSize: number }
|
|
24
|
-
|
|
25
|
-
const useStyles = makeStyles(
|
|
26
|
-
(theme: Theme) => ({
|
|
27
|
-
root: ({ shade, baseSize, mobileSize }: UseStylesProps) => ({
|
|
28
|
-
filter: shade > 0 ? `invert(${shade}%)` : undefined,
|
|
29
|
-
objectFit: 'contain',
|
|
30
|
-
width: mobileSize ?? Math.round(baseSize * 0.75),
|
|
31
|
-
height: mobileSize ?? Math.round(baseSize * 0.75),
|
|
32
|
-
[theme.breakpoints.up('md')]: {
|
|
33
|
-
width: baseSize,
|
|
34
|
-
height: baseSize,
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
}),
|
|
38
|
-
{ name: 'SvgImage' },
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
export default function SvgImage(props: SvgImageProps) {
|
|
42
|
-
const { src, size = 'medium', mobileSize, shade = 'default', ...imageProps } = props
|
|
43
|
-
|
|
44
|
-
// if (isStaticImageData(src)) {
|
|
45
|
-
// console.log(src.height)
|
|
46
|
-
// console.log(src.width)
|
|
47
|
-
// }
|
|
48
|
-
|
|
49
|
-
const baseSizes = {
|
|
50
|
-
small: 24,
|
|
51
|
-
medium: 32,
|
|
52
|
-
large: 48,
|
|
53
|
-
extralarge: 64,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const classes = useStyles({
|
|
57
|
-
...props,
|
|
58
|
-
mobileSize: baseSizes[mobileSize ?? ''] ?? mobileSize,
|
|
59
|
-
baseSize: baseSizes[size ?? ''] ?? size,
|
|
60
|
-
shade: SvgImageShades[shade],
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Image
|
|
65
|
-
layout='fixed'
|
|
66
|
-
unoptimized
|
|
67
|
-
src={src}
|
|
68
|
-
className={classes.root}
|
|
69
|
-
// height={24}
|
|
70
|
-
// width={24}
|
|
71
|
-
{...imageProps}
|
|
72
|
-
/>
|
|
73
|
-
)
|
|
74
|
-
}
|