@graphcommerce/next-ui 10.0.0-canary.65 → 10.0.0-canary.67

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.
@@ -36,6 +36,11 @@ export type BreadcrumbsProps = BreadcrumbsType &
36
36
  itemSx?: SxProps<Theme>
37
37
  linkProps?: Omit<LinkProps, 'href'>
38
38
  disableHome?: boolean
39
+ /**
40
+ * Hide the last breadcrumb item (and its separator) on mobile. Useful when the last item
41
+ * duplicates the page title.
42
+ */
43
+ hideLastOnMobile?: boolean
39
44
  }
40
45
 
41
46
  export function Breadcrumbs(props: BreadcrumbsProps) {
@@ -49,13 +54,19 @@ export function Breadcrumbs(props: BreadcrumbsProps) {
49
54
  itemSx = [],
50
55
  linkProps,
51
56
  disableHome = false,
57
+ hideLastOnMobile = false,
52
58
  ...rest
53
59
  } = props
54
60
  const [anchorElement, setAnchorElement] = useState<HTMLButtonElement | null>(null)
55
61
  const theme = useTheme()
56
62
 
63
+ // When hiding the last item on mobile, show one more item to compensate
64
+ const effectiveBreadcrumbsAmountMobile = hideLastOnMobile
65
+ ? breadcrumbsAmountMobile + 1
66
+ : breadcrumbsAmountMobile
67
+
57
68
  const isDefaultMobile = breadcrumbsAmountMobile === 0
58
- const showButtonMobile = breadcrumbs.length > breadcrumbsAmountMobile && !isDefaultMobile
69
+ const showButtonMobile = breadcrumbs.length > effectiveBreadcrumbsAmountMobile && !isDefaultMobile
59
70
  const isDefaultDesktop = breadcrumbsAmountDesktop === 0
60
71
  const showButtonDesktop = breadcrumbs.length > breadcrumbsAmountDesktop && !isDefaultDesktop
61
72
 
@@ -104,7 +115,7 @@ export function Breadcrumbs(props: BreadcrumbsProps) {
104
115
  [theme.breakpoints.down('md')]: showButtonMobile && {
105
116
  '& .MuiBreadcrumbs-li, & .MuiBreadcrumbs-separator': {
106
117
  display: 'none',
107
- [`&:nth-last-of-type(-n+${breadcrumbsAmountMobile * 2})`]: {
118
+ [`&:nth-last-of-type(-n+${effectiveBreadcrumbsAmountMobile * 2})`]: {
108
119
  display: 'flex',
109
120
  },
110
121
  },
@@ -119,6 +130,17 @@ export function Breadcrumbs(props: BreadcrumbsProps) {
119
130
  },
120
131
  },
121
132
  },
133
+ // Hide the last item and its separator on mobile
134
+ hideLastOnMobile && {
135
+ [theme.breakpoints.down('md')]: {
136
+ '& .MuiBreadcrumbs-ol .MuiBreadcrumbs-li:nth-last-of-type(1)': {
137
+ display: 'none',
138
+ },
139
+ '& .MuiBreadcrumbs-ol > :nth-last-child(2)': {
140
+ display: 'none',
141
+ },
142
+ },
143
+ },
122
144
  ...(Array.isArray(sx) ? sx : [sx]),
123
145
  ]}
124
146
  >
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.0.0-canary.67
4
+
5
+ ## 10.0.0-canary.66
6
+
3
7
  ## 10.0.0-canary.65
4
8
 
5
9
  ### Patch Changes
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": "10.0.0-canary.65",
5
+ "version": "10.0.0-canary.67",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -42,13 +42,13 @@
42
42
  "@emotion/react": "^11",
43
43
  "@emotion/server": "^11",
44
44
  "@emotion/styled": "^11",
45
- "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.65",
46
- "@graphcommerce/framer-next-pages": "^10.0.0-canary.65",
47
- "@graphcommerce/framer-scroller": "^10.0.0-canary.65",
48
- "@graphcommerce/framer-utils": "^10.0.0-canary.65",
49
- "@graphcommerce/image": "^10.0.0-canary.65",
50
- "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.65",
51
- "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.65",
45
+ "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.67",
46
+ "@graphcommerce/framer-next-pages": "^10.0.0-canary.67",
47
+ "@graphcommerce/framer-scroller": "^10.0.0-canary.67",
48
+ "@graphcommerce/framer-utils": "^10.0.0-canary.67",
49
+ "@graphcommerce/image": "^10.0.0-canary.67",
50
+ "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.67",
51
+ "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.67",
52
52
  "@lingui/core": "^5",
53
53
  "@lingui/macro": "^5",
54
54
  "@lingui/react": "^5",