@graphcommerce/next-ui 4.1.1 → 4.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1287](https://github.com/ho-nl/m2-pwa/pull/1287)
8
+ [`d17f97d3a`](https://github.com/ho-nl/m2-pwa/commit/d17f97d3a786c33a99a10e4e949251c52fdbbdac)
9
+ Thanks [@paales](https://github.com/paales)! - Allow passing sx prop to SidebarGallery and
10
+ ContentLinks
11
+
12
+ ## 4.1.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#1285](https://github.com/ho-nl/m2-pwa/pull/1285)
17
+ [`c85294ba6`](https://github.com/ho-nl/m2-pwa/commit/c85294ba6d742ce78c074559a1e95409b25a5017)
18
+ Thanks [@paales](https://github.com/paales)! - upgraded dependencies
19
+
20
+ - Updated dependencies
21
+ [[`16d77b280`](https://github.com/ho-nl/m2-pwa/commit/16d77b2806e49e376d06bc0d578d38eb724b0c17)]:
22
+ - @graphcommerce/framer-scroller@2.0.4
23
+
24
+ ## 4.1.2
25
+
26
+ ### Patch Changes
27
+
28
+ - [`973ff8645`](https://github.com/ho-nl/m2-pwa/commit/973ff86452a70ade9f4db13fdda6e963d7220e96)
29
+ Thanks [@paales](https://github.com/paales)! - made packages public
30
+
31
+ * [#1278](https://github.com/ho-nl/m2-pwa/pull/1278)
32
+ [`81ea406d5`](https://github.com/ho-nl/m2-pwa/commit/81ea406d54d6b5c662c030a7fea444abc4117a20)
33
+ Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Upgraded dependencies to the latest version
34
+
35
+ - [#1281](https://github.com/ho-nl/m2-pwa/pull/1281)
36
+ [`3a719c88c`](https://github.com/ho-nl/m2-pwa/commit/3a719c88cad1eab58602de28c41adc0fc4827e1d)
37
+ Thanks [@paales](https://github.com/paales)! - Make sure we're able to style the backdrop and the
38
+ regular overlay for LayoutOverlay
39
+
40
+ * [#1284](https://github.com/ho-nl/m2-pwa/pull/1284)
41
+ [`5ffcb56bf`](https://github.com/ho-nl/m2-pwa/commit/5ffcb56bfcbe49ebeaf24f9341e819a145ab9a14)
42
+ Thanks [@paales](https://github.com/paales)! - SvgIcon is now more extenable and flexible:
43
+
44
+ - It will automatically calculate the stroke-width of the SVG based on the rendered size, allowing
45
+ for a more flexible use for icons.
46
+
47
+ - Make SvgIcon themable in your own Theme.
48
+
49
+ - Create overrides for components that will be used throughout the app.
50
+
51
+ * Updated dependencies
52
+ [[`4bb963d75`](https://github.com/ho-nl/m2-pwa/commit/4bb963d7595b5ce6e3a4924cc2e3e8b0210cdcd6),
53
+ [`973ff8645`](https://github.com/ho-nl/m2-pwa/commit/973ff86452a70ade9f4db13fdda6e963d7220e96),
54
+ [`81ea406d5`](https://github.com/ho-nl/m2-pwa/commit/81ea406d54d6b5c662c030a7fea444abc4117a20),
55
+ [`5ffcb56bf`](https://github.com/ho-nl/m2-pwa/commit/5ffcb56bfcbe49ebeaf24f9341e819a145ab9a14)]:
56
+ - @graphcommerce/framer-next-pages@3.1.0
57
+ - @graphcommerce/framer-scroller@2.0.3
58
+ - @graphcommerce/framer-utils@3.0.3
59
+ - @graphcommerce/image@3.1.0
60
+
3
61
  ## 4.1.1
4
62
 
5
63
  ### Patch Changes
@@ -8,7 +8,7 @@ import {
8
8
  ScrollerProvider,
9
9
  } from '@graphcommerce/framer-scroller'
10
10
  import { clientSize, useMotionValueValue } from '@graphcommerce/framer-utils'
11
- import { Fab, useTheme, alpha, Box, styled } from '@mui/material'
11
+ import { Fab, useTheme, alpha, Box, styled, SxProps, Theme } from '@mui/material'
12
12
  import { m, useDomEvent, useMotionValue } from 'framer-motion'
13
13
  import { useRouter } from 'next/router'
14
14
  import React, { useEffect, useRef } from 'react'
@@ -47,10 +47,17 @@ export type SidebarGalleryProps = {
47
47
  images: MotionImageAspectProps[]
48
48
  aspectRatio?: [number, number]
49
49
  routeHash?: string
50
+ sx?: SxProps<Theme>
50
51
  }
51
52
 
52
53
  export function SidebarGallery(props: SidebarGalleryProps) {
53
- const { sidebar, images, aspectRatio: [width, height] = [1, 1], routeHash = 'gallery' } = props
54
+ const {
55
+ sidebar,
56
+ images,
57
+ aspectRatio: [width, height] = [1, 1],
58
+ sx,
59
+ routeHash = 'gallery',
60
+ } = props
54
61
 
55
62
  const router = useRouter()
56
63
  const prevRoute = usePrevPageRouter()
@@ -109,7 +116,7 @@ export function SidebarGallery(props: SidebarGalleryProps) {
109
116
 
110
117
  return (
111
118
  <ScrollerProvider scrollSnapAlign='center'>
112
- <Row maxWidth={false} disableGutters className={classes.row}>
119
+ <Row maxWidth={false} disableGutters className={classes.row} sx={sx}>
113
120
  <MotionBox
114
121
  layout
115
122
  className={classes.root}
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  Scroller,
3
3
  ScrollerButton,
4
+ ScrollerButtonProps as ScrollerButtonPropsType,
4
5
  ScrollerPageCounter,
5
6
  ScrollerProvider,
6
7
  } from '@graphcommerce/framer-scroller'
@@ -23,10 +24,15 @@ const { classes, selectors } = extendableComponent('SidebarSlider', [
23
24
  'centerRight',
24
25
  ] as const)
25
26
 
26
- export type SidebarSliderProps = { children: ReactNode; sidebar: ReactNode; sx?: SxProps<Theme> }
27
+ export type SidebarSliderProps = {
28
+ children: ReactNode
29
+ sidebar: ReactNode
30
+ sx?: SxProps<Theme>
31
+ buttonSize?: ScrollerButtonPropsType['size']
32
+ }
27
33
 
28
34
  export function SidebarSlider(props: SidebarSliderProps) {
29
- const { children, sidebar, sx } = props
35
+ const { children, sidebar, sx, buttonSize } = props
30
36
 
31
37
  return (
32
38
  <Row maxWidth={false} disableGutters className={classes.root} sx={sx}>
@@ -79,6 +85,7 @@ export function SidebarSlider(props: SidebarSliderProps) {
79
85
  direction='left'
80
86
  className={classes.sliderButtons}
81
87
  sx={{ display: { xs: 'none', md: 'flex' } }}
88
+ size={buttonSize}
82
89
  >
83
90
  <SvgIcon src={iconChevronLeft} />
84
91
  </ScrollerButton>
@@ -93,7 +100,12 @@ export function SidebarSlider(props: SidebarSliderProps) {
93
100
  top: `calc(50% - 28px)`,
94
101
  })}
95
102
  >
96
- <ScrollerButton direction='right' className={classes.sliderButtons}>
103
+ <ScrollerButton
104
+ direction='right'
105
+ className={classes.sliderButtons}
106
+ sx={{ display: { xs: 'none', md: 'flex' } }}
107
+ size={buttonSize}
108
+ >
97
109
  <SvgIcon src={iconChevronRight} />
98
110
  </ScrollerButton>
99
111
  </Box>
@@ -25,6 +25,7 @@ export type LayoutOverlayBaseProps = {
25
25
  children?: React.ReactNode
26
26
  className?: string
27
27
  sx?: SxProps<Theme>
28
+ sxBackdrop?: SxProps<Theme>
28
29
  } & StyleProps
29
30
 
30
31
  enum OverlayPosition {
@@ -50,6 +51,7 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
50
51
  justifySm = 'stretch',
51
52
  justifyMd = 'stretch',
52
53
  sx = [],
54
+ sxBackdrop = [],
53
55
  } = props
54
56
 
55
57
  const { scrollerRef, snap } = useScrollerContext()
@@ -104,6 +106,7 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
104
106
 
105
107
  const resize = () => {
106
108
  if (positions.open.visible.get() !== 1) return
109
+
107
110
  scroller.scrollLeft = positions.open.x.get()
108
111
  scroller.scrollTop = positions.open.y.get()
109
112
  }
@@ -187,7 +190,7 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
187
190
  WebkitTapHighlightColor: 'transparent',
188
191
  willChange: 'opacity',
189
192
  },
190
- ...(Array.isArray(sx) ? sx : [sx]),
193
+ ...(Array.isArray(sxBackdrop) ? sxBackdrop : [sxBackdrop]),
191
194
  ]}
192
195
  />
193
196
  <Scroller
@@ -195,62 +198,65 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
195
198
  grid={false}
196
199
  hideScrollbar
197
200
  onClick={onClickAway}
198
- sx={(theme) => ({
199
- display: 'grid',
200
- '&.canGrab': {
201
- cursor: 'default',
202
- },
203
- '&.mdSnapDirInline': {
204
- overflow: 'auto',
205
- },
206
-
207
- height: '100vh',
208
- '@supports (-webkit-touch-callout: none)': {
209
- height: '-webkit-fill-available',
210
- },
211
-
212
- [theme.breakpoints.down('md')]: {
213
- '&.variantSmLeft': {
214
- gridTemplate: `"overlay beforeOverlay"`,
215
- borderTopRightRadius: theme.shape.borderRadius * 3,
216
- borderBottomRightRadius: theme.shape.borderRadius * 3,
217
- },
218
- '&.variantSmRight': {
219
- gridTemplate: `"beforeOverlay overlay"`,
220
- borderTopLeftRadius: theme.shape.borderRadius * 3,
221
- borderBottomLeftRadius: theme.shape.borderRadius * 3,
222
- },
223
- '&.variantSmBottom': {
224
- borderTopLeftRadius: theme.shape.borderRadius * 3,
225
- borderTopRightRadius: theme.shape.borderRadius * 3,
226
- gridTemplate: `"beforeOverlay" "overlay"`,
227
- height: '100vh',
228
- '@supports (-webkit-touch-callout: none)': {
229
- height: '-webkit-fill-available',
230
- },
201
+ sx={[
202
+ (theme) => ({
203
+ display: 'grid',
204
+ '&.canGrab': {
205
+ cursor: 'default',
231
206
  },
232
- },
233
- [theme.breakpoints.up('md')]: {
234
- '&.variantMdLeft': {
235
- gridTemplate: `"overlay beforeOverlay"`,
236
- borderTopRightRadius: theme.shape.borderRadius * 4,
237
- borderBottomRightRadius: theme.shape.borderRadius * 4,
207
+ '&.mdSnapDirInline': {
208
+ overflow: 'auto',
238
209
  },
239
- '&.variantMdRight': {
240
- gridTemplate: `"beforeOverlay overlay"`,
241
- borderTopLeftRadius: theme.shape.borderRadius * 4,
242
- borderBottomLeftRadius: theme.shape.borderRadius * 4,
210
+
211
+ height: '100vh',
212
+ '@supports (-webkit-touch-callout: none)': {
213
+ height: '-webkit-fill-available',
243
214
  },
244
- '&.variantMdBottom': {
245
- borderTopLeftRadius: theme.shape.borderRadius * 4,
246
- borderTopRightRadius: theme.shape.borderRadius * 4,
247
- [theme.breakpoints.up('md')]: {
215
+
216
+ [theme.breakpoints.down('md')]: {
217
+ '&.variantSmLeft': {
218
+ gridTemplate: `"overlay beforeOverlay"`,
219
+ borderTopRightRadius: theme.shape.borderRadius * 3,
220
+ borderBottomRightRadius: theme.shape.borderRadius * 3,
221
+ },
222
+ '&.variantSmRight': {
223
+ gridTemplate: `"beforeOverlay overlay"`,
224
+ borderTopLeftRadius: theme.shape.borderRadius * 3,
225
+ borderBottomLeftRadius: theme.shape.borderRadius * 3,
226
+ },
227
+ '&.variantSmBottom': {
228
+ borderTopLeftRadius: theme.shape.borderRadius * 3,
229
+ borderTopRightRadius: theme.shape.borderRadius * 3,
248
230
  gridTemplate: `"beforeOverlay" "overlay"`,
249
231
  height: '100vh',
232
+ '@supports (-webkit-touch-callout: none)': {
233
+ height: '-webkit-fill-available',
234
+ },
250
235
  },
251
236
  },
252
- },
253
- })}
237
+ [theme.breakpoints.up('md')]: {
238
+ '&.variantMdLeft': {
239
+ gridTemplate: `"overlay beforeOverlay"`,
240
+ borderTopRightRadius: theme.shape.borderRadius * 4,
241
+ borderBottomRightRadius: theme.shape.borderRadius * 4,
242
+ },
243
+ '&.variantMdRight': {
244
+ gridTemplate: `"beforeOverlay overlay"`,
245
+ borderTopLeftRadius: theme.shape.borderRadius * 4,
246
+ borderBottomLeftRadius: theme.shape.borderRadius * 4,
247
+ },
248
+ '&.variantMdBottom': {
249
+ borderTopLeftRadius: theme.shape.borderRadius * 4,
250
+ borderTopRightRadius: theme.shape.borderRadius * 4,
251
+ [theme.breakpoints.up('md')]: {
252
+ gridTemplate: `"beforeOverlay" "overlay"`,
253
+ height: '100vh',
254
+ },
255
+ },
256
+ },
257
+ }),
258
+ ...(Array.isArray(sx) ? sx : [sx]),
259
+ ]}
254
260
  >
255
261
  <Box
256
262
  onClick={onClickAway}
@@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
3
3
  import { useCallback } from 'react'
4
4
  import { LayoutOverlay, LayoutOverlayProps } from '../components/LayoutOverlay'
5
5
 
6
- export type LayoutOverlayState = Omit<LayoutOverlayProps, 'children' | 'sx'>
6
+ export type LayoutOverlayState = Omit<LayoutOverlayProps, 'children' | 'sx' | 'sxBackdrop'>
7
7
 
8
8
  function useQueryState<T extends ParsedUrlQuery>(builder: (query: T) => T) {
9
9
  const { query, replace } = useRouter()
@@ -56,7 +56,6 @@ export function MenuFab(props: MenuFabProps) {
56
56
  <Fab
57
57
  color='inherit'
58
58
  aria-label='Open Menu'
59
- size='medium'
60
59
  onClick={(event) => setOpenEl(event.currentTarget)}
61
60
  sx={(theme) => ({
62
61
  boxShadow: 'none',
@@ -73,10 +72,10 @@ export function MenuFab(props: MenuFabProps) {
73
72
  className={classes.fab}
74
73
  >
75
74
  {closeIcon ?? (
76
- <SvgIcon src={iconClose} size='medium' sx={{ display: openEl ? 'block' : 'none' }} />
75
+ <SvgIcon src={iconClose} size='large' sx={{ display: openEl ? 'block' : 'none' }} />
77
76
  )}
78
77
  {menuIcon ?? (
79
- <SvgIcon src={iconMenu} size='medium' sx={{ display: openEl ? 'none' : 'block' }} />
78
+ <SvgIcon src={iconMenu} size='large' sx={{ display: openEl ? 'none' : 'block' }} />
80
79
  )}
81
80
  </Fab>
82
81
  <MotionDiv
@@ -13,7 +13,7 @@ const ButtonItem = styled(Button)(({ theme }) => ({
13
13
  borderBottom: `1px solid ${theme.palette.divider}`,
14
14
  borderRadius: 0,
15
15
  justifyContent: 'space-between',
16
- ...theme.typography.body1,
16
+ typography: 'body1',
17
17
  }))
18
18
 
19
19
  export function ButtonLinkListItem(props: ButtonLinkProps) {
@@ -14,13 +14,18 @@ const parts = ['root', 'scroller', 'title'] as const
14
14
  const { classes } = extendableComponent(compName, parts)
15
15
 
16
16
  export function ContentLinks(props: ContentLinksProps) {
17
- const { title, children } = props
17
+ const { title, children, sx = [] } = props
18
18
 
19
19
  return (
20
20
  <Container
21
21
  className={classes.root}
22
22
  maxWidth={false}
23
- sx={(theme) => ({ marginBottom: `${theme.spacings.md}` })}
23
+ sx={[
24
+ (theme) => ({
25
+ marginBottom: `${theme.spacings.md}`,
26
+ }),
27
+ ...(Array.isArray(sx) ? sx : [sx]),
28
+ ]}
24
29
  >
25
30
  <ScrollerProvider scrollSnapAlign='none'>
26
31
  <Scroller
@@ -1,8 +1,17 @@
1
1
  import { capitalize, Interpolation, Theme } from '@mui/material'
2
- import React from 'react'
3
2
 
4
3
  export type ExtendableComponent<StyleProps extends Record<string, unknown>> = {
4
+ /**
5
+ * Allows you to override the props of a component globally
6
+ *
7
+ * @see https://mui.com/customization/theme-components/#adding-new-component-variants
8
+ */
5
9
  defaultProps?: Partial<StyleProps>
10
+ /**
11
+ * Allows you to define custom styling for a variant.
12
+ *
13
+ * @see https://mui.com/customization/theme-components/#adding-new-component-variants
14
+ */
6
15
  variants?: { props: Partial<StyleProps>; style: Interpolation<{ theme: Theme }> }[]
7
16
  }
8
17
 
@@ -1,60 +1,101 @@
1
- import { ImageProps, srcToString } from '@graphcommerce/image'
2
- import { Box, SxProps, Theme } from '@mui/material'
1
+ import { ImageProps, srcToString, StaticImport } from '@graphcommerce/image'
2
+ import { styled, SxProps, Theme, useTheme } from '@mui/material'
3
3
  import { ComponentProps, forwardRef } from 'react'
4
- import { ExtendableComponent } from '../Styles/extendableComponent'
4
+ import { extendableComponent, ExtendableComponent } from '../Styles/extendableComponent'
5
5
  import { responsiveVal as rv } from '../Styles/responsiveVal'
6
+ import { svgIconStrokeWidth } from './svgIconStrokeWidth'
6
7
 
7
8
  const name = 'SvgIcon'
9
+ const parts = ['root'] as const
8
10
  type StyleProps = {
9
11
  size?: 'default' | 'inherit' | 'xxl' | 'xl' | 'large' | 'medium' | 'small' | 'xs'
10
12
  fillIcon?: boolean
11
13
  }
14
+ const { withState } = extendableComponent<StyleProps, typeof name, typeof parts>(name, parts)
12
15
 
13
- // Expose the component to be exendable in your theme.components
16
+ /** Expose the component to be exendable in your theme.components */
14
17
  declare module '@mui/material/styles/components' {
15
18
  interface Components {
16
- SvgIcon?: ExtendableComponent<StyleProps>
19
+ SvgIcon?: ExtendableComponent<StyleProps> & {
20
+ /**
21
+ * To override an icon with your own icon, provide the original src and the replacement src.
22
+ *
23
+ * ```tsx
24
+ * import { originalIcon, originalIcon2 } from '@graphcommerce/image'
25
+ * import myIcon from './myIcon.svg'
26
+ * import myIcon2 from './myIcon2.svg'
27
+ *
28
+ * overrides: [
29
+ * [originalIcon, myIcon],
30
+ * [originalIcon2, myIcon2],
31
+ * ]
32
+ * ```
33
+ */
34
+ overrides?: [StaticImport | string, StaticImport | string][]
35
+ }
17
36
  }
18
37
  }
19
38
 
20
39
  export type SvgIconProps = StyleProps &
21
40
  Pick<ImageProps, 'src'> &
22
- Pick<ComponentProps<'svg'>, 'className'> & { sx?: SxProps<Theme> }
41
+ Pick<ComponentProps<'svg'>, 'className' | 'style'> & { sx?: SxProps<Theme> }
23
42
 
24
- /** SvgIcon component is supposed to be used in combination with `icons` */
43
+ const Svg = styled('svg', { name, target: name })(() => [
44
+ {
45
+ userSelect: 'none',
46
+ width: '1em',
47
+ height: '1em',
48
+ display: 'inline-block',
49
+
50
+ strokeLinecap: 'square',
51
+ strokeLinejoin: 'miter',
52
+ strokeMiterlimit: 4,
53
+
54
+ fill: 'none',
55
+ stroke: 'currentColor',
56
+
57
+ fontSize: '1.3em',
58
+
59
+ strokeWidth: svgIconStrokeWidth(28, 148, 1.4, 0.8),
60
+
61
+ '&.sizeXs': { fontSize: rv(11, 13) },
62
+ '&.sizeSmall': { fontSize: rv(12, 16) },
63
+ '&.sizeMedium': { fontSize: rv(22, 24) },
64
+ '&.sizeLarge': { fontSize: rv(24, 28) },
65
+ '&.sizeXl': { fontSize: rv(38, 62) },
66
+ '&.sizeXxl': { fontSize: rv(96, 148) },
67
+
68
+ '&.fillIcon': {
69
+ fill: 'currentColor',
70
+ stroke: 'none',
71
+ },
72
+ },
73
+ ])
74
+
75
+ /**
76
+ * SvgIcon component is supposed to be used in combination with `icons`
77
+ *
78
+ * @see https://graphcommerce-docs.vercel.app/framework/icons
79
+ */
25
80
  export const SvgIcon = forwardRef<SVGSVGElement, SvgIconProps>((props, ref) => {
26
- const { className, src, size, fillIcon, sx = [], ...svgProps } = props
81
+ const { src, size, fillIcon, className, ...svgProps } = props
82
+
83
+ const srcWithOverride =
84
+ (useTheme().components?.SvgIcon?.overrides ?? []).find(
85
+ ([overrideSrc]) => overrideSrc === src,
86
+ )?.[1] ?? src
87
+
88
+ const classes = withState({ size, fillIcon })
27
89
 
28
90
  return (
29
- <Box
30
- component='svg'
91
+ <Svg
31
92
  ref={ref}
32
93
  aria-hidden='true'
33
- className={`${name} ${className ?? ''}`}
94
+ className={`${classes.root} ${className ?? ''}`}
34
95
  {...svgProps}
35
- sx={[
36
- {
37
- userSelect: 'none',
38
- width: '1.3em',
39
- height: '1.3em',
40
- strokeWidth: 1.8,
41
- strokeLinecap: 'square',
42
- strokeLinejoin: 'miter',
43
- fill: 'none',
44
- stroke: 'currentColor',
45
- },
46
- size === 'xs' && { width: rv(11, 13), height: rv(11, 13), strokeWidth: 2.1 },
47
- size === 'small' && { width: rv(12, 16), height: rv(12, 16), strokeWidth: 2.1 },
48
- size === 'medium' && { width: rv(22, 24), height: rv(22, 24), strokeWidth: 1.8 },
49
- size === 'large' && { width: rv(24, 28), height: rv(24, 28), strokeWidth: 1.4 },
50
- size === 'xl' && { width: rv(38, 62), height: rv(38, 62), strokeWidth: 1.1 },
51
- size === 'xxl' && { width: rv(96, 148), height: rv(96, 148), strokeWidth: 0.8 },
52
- fillIcon === true && { fill: 'currentColor', stroke: `none` },
53
- ...(Array.isArray(sx) ? sx : [sx]),
54
- ]}
55
96
  >
56
- <use href={`${srcToString(src)}#icon`} />
57
- </Box>
97
+ <use href={`${srcToString(srcWithOverride)}#icon`} />
98
+ </Svg>
58
99
  )
59
100
  })
60
101
  SvgIcon.displayName = 'SvgIcon'
@@ -0,0 +1,2 @@
1
+ export * from './SvgIcon'
2
+ export * from './svgIconStrokeWidth'
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Responsive strokeWidth calculation:
3
+ *
4
+ * - We want the stoke width to be inverse to the width of the element
5
+ * - When the width is 96 we want strokeWidth to be 0.5
6
+ * - When the width is 48 we want strokeWidth to be 1
7
+ * - When the width is 24 we want strokeWidth to be 2
8
+ * - To achieve this we have actual width of the element as defined by '1em'.
9
+ * - We use the calc property to calculate the strokeWidth.
10
+ *
11
+ * Sensible values are:
12
+ *
13
+ * - `lowSize`: 10-20
14
+ * - `highSize`: 50-150
15
+ * - `lowStroke`: 0.5-2
16
+ * - `highStroke`: 0.2-1
17
+ */
18
+ export function svgIconStrokeWidth(
19
+ lowSize: number,
20
+ highSize: number,
21
+ lowStroke: number,
22
+ highStroke: number,
23
+ ) {
24
+ const val = `calc(${lowStroke}px - ((1em - ${lowSize}px) / (${highSize} - ${lowSize}) * (${lowStroke} - ${highStroke})))`
25
+ return val
26
+ }
package/index.ts CHANGED
@@ -58,7 +58,7 @@ export * from './Snackbar/MessageSnackbarImpl'
58
58
  export * from './StarRatingField'
59
59
  export * from './Stepper/Stepper'
60
60
  export * from './Styles'
61
- export * from './SvgIcon/SvgIcon'
61
+ export * from './SvgIcon'
62
62
  export * from './TextInputNumber'
63
63
  export * from './Theme'
64
64
  export * from './TimeAgo'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.1.1",
5
+ "version": "4.1.4",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "sideEffects": false,
@@ -19,14 +19,14 @@
19
19
  "@emotion/react": "^11.7.1",
20
20
  "@emotion/server": "^11.4.0",
21
21
  "@emotion/styled": "^11.6.0",
22
- "@graphcommerce/framer-next-pages": "^3.0.2",
23
- "@graphcommerce/framer-scroller": "^2.0.2",
24
- "@graphcommerce/framer-utils": "^3.0.2",
25
- "@graphcommerce/image": "^3.0.2",
22
+ "@graphcommerce/framer-next-pages": "^3.1.0",
23
+ "@graphcommerce/framer-scroller": "^2.0.4",
24
+ "@graphcommerce/framer-utils": "^3.0.3",
25
+ "@graphcommerce/image": "^3.1.0",
26
26
  "react-is": "^17.0.2",
27
27
  "react-schemaorg": "^2.0.0",
28
- "schema-dts": "^1.0.0",
29
- "type-fest": "^2.11.2"
28
+ "schema-dts": "^1.1.0",
29
+ "type-fest": "^2.12.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@lingui/macro": "^3.13.2",
@@ -39,9 +39,9 @@
39
39
  "react-dom": "^17.0.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@graphcommerce/eslint-config-pwa": "^4.0.2",
43
- "@graphcommerce/prettier-config-pwa": "^4.0.1",
44
- "@graphcommerce/typescript-config-pwa": "^4.0.1",
42
+ "@graphcommerce/eslint-config-pwa": "^4.0.4",
43
+ "@graphcommerce/prettier-config-pwa": "^4.0.2",
44
+ "@graphcommerce/typescript-config-pwa": "^4.0.2",
45
45
  "@playwright/test": "^1.19.1",
46
46
  "@types/react-is": "^17.0.3",
47
47
  "typescript": "^4.5.5"