@graphcommerce/framer-scroller 7.0.2-canary.0 → 7.0.2-canary.2

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.
@@ -12,11 +12,20 @@ export type ScrollerButtonProps = {
12
12
  direction: SnapPositionDirection
13
13
  layout?: boolean
14
14
  sxContainer?: SxProps<Theme>
15
+ showButtons?: 'auto' | 'desktopAuto' | 'always' | 'desktopAlways' | 'never'
15
16
  } & FabProps
16
17
 
17
18
  export const ScrollerButton = m(
18
19
  React.forwardRef<HTMLDivElement, ScrollerButtonProps>((props, ref) => {
19
- const { direction, sx = [], layout, className, sxContainer, ...buttonProps } = props
20
+ const {
21
+ direction,
22
+ sx = [],
23
+ layout,
24
+ className,
25
+ sxContainer,
26
+ showButtons = 'desktopAuto',
27
+ ...buttonProps
28
+ } = props
20
29
 
21
30
  const { getSnapPosition, scroll } = useScrollerContext()
22
31
  const scrollTo = useScrollTo()
@@ -38,21 +47,35 @@ export const ScrollerButton = m(
38
47
  (v) => v,
39
48
  )
40
49
 
50
+ const mode = {
51
+ ...(showButtons === 'auto' && {
52
+ display: 'inline-flex',
53
+ transform: `scale(${visibility})`,
54
+ opacity: visibility,
55
+ }),
56
+ ...(showButtons === 'desktopAuto' && {
57
+ display: { xs: 'none', md: 'inline-flex' },
58
+ transform: `scale(${visibility})`,
59
+ opacity: visibility,
60
+ }),
61
+ ...(showButtons === 'desktopAlways' && {
62
+ display: { xs: 'none', md: 'inline-flex' },
63
+ }),
64
+ }
65
+
66
+ if (showButtons === 'never') return null
67
+
41
68
  return (
42
69
  <MotionDiv ref={ref} layout={layout} sx={sxContainer} className={className}>
43
70
  <Fab
44
71
  type='button'
45
72
  size='small'
73
+ className='scrollerButton'
46
74
  {...buttonProps}
47
75
  onClick={handleClick}
48
76
  aria-label={direction}
49
77
  sx={[
50
- {
51
- display: { xs: 'none', md: 'flex' },
52
- transition: 'all 250ms',
53
- opacity: visibility,
54
- transform: `scale(${visibility})`,
55
- },
78
+ { transition: 'all 250ms', zIndex: 'inherit', ...mode },
56
79
  ...(Array.isArray(sx) ? sx : [sx]),
57
80
  ]}
58
81
  />
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/framer-scroller",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "7.0.2-canary.0",
5
+ "version": "7.0.2-canary.2",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -16,13 +16,13 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "popmotion": "11.0.5",
19
- "@graphcommerce/framer-utils": "7.0.2-canary.0",
20
- "@graphcommerce/image": "7.0.2-canary.0"
19
+ "@graphcommerce/framer-utils": "7.0.2-canary.2",
20
+ "@graphcommerce/image": "7.0.2-canary.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@graphcommerce/eslint-config-pwa": "7.0.2-canary.0",
24
- "@graphcommerce/prettier-config-pwa": "7.0.2-canary.0",
25
- "@graphcommerce/typescript-config-pwa": "7.0.2-canary.0"
23
+ "@graphcommerce/eslint-config-pwa": "7.0.2-canary.2",
24
+ "@graphcommerce/prettier-config-pwa": "7.0.2-canary.2",
25
+ "@graphcommerce/typescript-config-pwa": "7.0.2-canary.2"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@mui/material": "^5.10.16",