@graphcommerce/magento-cart 3.8.22 → 3.8.26

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
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.8.25](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@3.8.24...@graphcommerce/magento-cart@3.8.25) (2021-12-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * cart fab wouldnt properly switch to darkmode ([2f4fe1e](https://github.com/ho-nl/m2-pwa/commit/2f4fe1ed28ab3b63440f40d1455f06bc02e44ce7))
12
+
13
+
14
+
15
+
16
+
17
+ ## [3.8.23](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@3.8.22...@graphcommerce/magento-cart@3.8.23) (2021-12-21)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * make sure the cart renders the correct currency ([cc43c8a](https://github.com/ho-nl/m2-pwa/commit/cc43c8acdce339a2f9c99fd7f7e79d6277c8603f))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [3.8.22](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@3.8.21...@graphcommerce/magento-cart@3.8.22) (2021-12-21)
7
29
 
8
30
 
@@ -4,12 +4,12 @@ import {
4
4
  responsiveVal,
5
5
  StyledBadge,
6
6
  SvgImageSimple,
7
- useFixedFabAnimation,
7
+ useScrollY,
8
8
  UseStyles,
9
9
  } from '@graphcommerce/next-ui'
10
10
  import { t } from '@lingui/macro'
11
- import { darken, Fab, FabProps, makeStyles, NoSsr, Theme } from '@material-ui/core'
12
- import { m } from 'framer-motion'
11
+ import { alpha, darken, Fab, FabProps, makeStyles, NoSsr, Theme, useTheme } from '@material-ui/core'
12
+ import { m, useTransform } from 'framer-motion'
13
13
  import PageLink from 'next/link'
14
14
  import React from 'react'
15
15
  import { useCartQuery } from '../../hooks/useCartQuery'
@@ -19,21 +19,10 @@ import { CartTotalQuantityFragment } from './CartTotalQuantity.gql'
19
19
  const useStyles = makeStyles(
20
20
  (theme: Theme) => ({
21
21
  fab: {
22
- color:
23
- theme.palette.type === 'light'
24
- ? theme.palette.text.primary
25
- : darken(theme.palette.text.primary, 1),
26
- boxShadow: 'none',
27
- '&:hover, &:focus': {
28
- boxShadow: 'none',
29
- },
30
22
  width: responsiveVal(42, 56),
31
23
  height: responsiveVal(42, 56),
32
- },
33
- fabWrapper: {
34
- position: 'relative',
35
24
  [theme.breakpoints.down('sm')]: {
36
- backgroundColor: '#fff !important',
25
+ backgroundColor: `${theme.palette.background.paper} !important`,
37
26
  },
38
27
  },
39
28
  shadow: {
@@ -49,33 +38,44 @@ const useStyles = makeStyles(
49
38
  },
50
39
  },
51
40
  }),
52
- {
53
- name: 'CartFab',
54
- },
41
+ { name: 'CartFab' },
55
42
  )
56
43
 
57
44
  export type CartFabProps = {
58
45
  icon?: React.ReactNode
59
- } & Omit<FabProps, 'children' | 'aria-label'> &
60
- UseStyles<typeof useStyles>
46
+ } & UseStyles<typeof useStyles>
61
47
 
62
48
  type CartFabContentProps = CartFabProps & CartTotalQuantityFragment
63
49
 
50
+ const MotionFab = m(
51
+ React.forwardRef<any, Omit<FabProps, 'style' | 'onDrag'>>((props, ref) => (
52
+ <Fab {...props} ref={ref} />
53
+ )),
54
+ )
55
+
64
56
  function CartFabContent(props: CartFabContentProps) {
65
57
  const { total_quantity, icon, ...fabProps } = props
66
- const cartIcon = icon ?? <SvgImageSimple src={iconShoppingBag} loading='eager' size='large' />
67
- const { opacity, backgroundColor } = useFixedFabAnimation()
68
58
  const classes = useStyles(props)
69
59
 
60
+ const theme = useTheme()
61
+ const scrollY = useScrollY()
62
+ const opacity = useTransform(scrollY, [50, 60], [0, 1])
63
+
64
+ const paper0 = alpha(theme.palette.background.paper, 0)
65
+ const paper1 = alpha(theme.palette.background.paper, 1)
66
+ const backgroundColor = useTransform(scrollY, [0, 10], [paper0, paper1])
67
+
68
+ const cartIcon = icon ?? <SvgImageSimple src={iconShoppingBag} loading='eager' size='large' />
70
69
  return (
71
- <m.div className={classes.fabWrapper} style={{ backgroundColor, borderRadius: 'inherit' }}>
70
+ <>
72
71
  <PageLink href='/cart' passHref>
73
- <Fab
72
+ <MotionFab
73
+ {...fabProps}
74
74
  aria-label={t`Cart`}
75
75
  color='inherit'
76
76
  size='large'
77
77
  classes={{ root: classes.fab }}
78
- {...fabProps}
78
+ style={{ backgroundColor }}
79
79
  >
80
80
  {total_quantity > 0 ? (
81
81
  <StyledBadge color='primary' variant='dot'>
@@ -84,10 +84,10 @@ function CartFabContent(props: CartFabContentProps) {
84
84
  ) : (
85
85
  cartIcon
86
86
  )}
87
- </Fab>
87
+ </MotionFab>
88
88
  </PageLink>
89
89
  <m.div className={classes.shadow} style={{ opacity }} />
90
- </m.div>
90
+ </>
91
91
  )
92
92
  }
93
93
 
@@ -128,7 +128,7 @@ export default function CartTotals(props: CartTotalsProps) {
128
128
  >
129
129
  <div>{discount?.label}</div>
130
130
  <div className={classes.money}>
131
- {discount?.amount && <Money {...discount} value={value} />}
131
+ {discount?.amount && <Money {...discount.amount} value={value} />}
132
132
  </div>
133
133
  </AnimatedRow>
134
134
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-cart",
3
- "version": "3.8.22",
3
+ "version": "3.8.26",
4
4
  "sideEffects": false,
5
5
  "prettier": "@graphcommerce/prettier-config-pwa",
6
6
  "browserslist": [
@@ -21,14 +21,14 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@apollo/client": "^3.5.6",
24
- "@graphcommerce/framer-next-pages": "^2.108.8",
25
- "@graphcommerce/framer-scroller": "^1.1.18",
24
+ "@graphcommerce/framer-next-pages": "^2.108.9",
25
+ "@graphcommerce/framer-scroller": "^1.1.22",
26
26
  "@graphcommerce/graphql": "^2.105.12",
27
27
  "@graphcommerce/image": "^2.105.11",
28
- "@graphcommerce/magento-customer": "^3.6.25",
28
+ "@graphcommerce/magento-customer": "^3.6.28",
29
29
  "@graphcommerce/magento-graphql": "^2.104.12",
30
- "@graphcommerce/magento-store": "^3.3.25",
31
- "@graphcommerce/next-ui": "^3.21.8",
30
+ "@graphcommerce/magento-store": "^3.3.28",
31
+ "@graphcommerce/next-ui": "^3.21.12",
32
32
  "@graphcommerce/react-hook-form": "^2.104.6",
33
33
  "@lingui/macro": "^3.13.0",
34
34
  "@material-ui/core": "^4.12.3",
@@ -39,5 +39,5 @@
39
39
  "react": "^17.0.2",
40
40
  "react-dom": "^17.0.2"
41
41
  },
42
- "gitHead": "5ad26fe58ae85c8d776e3f571e96832f24811d5d"
42
+ "gitHead": "55abd5ec0f5821dc4bba8d0a82fd265ff1d6a024"
43
43
  }