@graphcommerce/next-ui 9.1.0-canary.33 → 9.1.0-canary.35
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 +12 -0
- package/LayoutParts/MenuFabSecondaryItem.tsx +8 -1
- package/package.json +8 -8
- package/utils/cookie.ts +22 -0
- package/utils/cssFlags.tsx +6 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 9.1.0-canary.35
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#2528](https://github.com/graphcommerce-org/graphcommerce/pull/2528) [`6a3e7f9`](https://github.com/graphcommerce-org/graphcommerce/commit/6a3e7f9bec6d03c146718ad594b064a75b536e99) - cssFlag and cssNotFlag css selector can now select values ([@paales](https://github.com/paales))
|
8
|
+
|
9
|
+
- [#2528](https://github.com/graphcommerce-org/graphcommerce/pull/2528) [`a4344ed`](https://github.com/graphcommerce-org/graphcommerce/commit/a4344ed7ff7b3b5f88185c1f6a5fc4b6306fc472) - Created a useCookie hook that is synced between usages ([@paales](https://github.com/paales))
|
10
|
+
|
11
|
+
- [#2528](https://github.com/graphcommerce-org/graphcommerce/pull/2528) [`f89210b`](https://github.com/graphcommerce-org/graphcommerce/commit/f89210b09e64f520d308cb1bac693c027be1ac46) - Solve issue where the MenuFabSecondaryItem coudn't handle text overflow. ([@paales](https://github.com/paales))
|
12
|
+
|
13
|
+
## 9.1.0-canary.34
|
14
|
+
|
3
15
|
## 9.1.0-canary.33
|
4
16
|
|
5
17
|
## 9.1.0-canary.32
|
@@ -43,7 +43,14 @@ export function MenuFabSecondaryItem(props: FabMenuSecondaryItemProps) {
|
|
43
43
|
{icon}
|
44
44
|
</ListItemIcon>
|
45
45
|
)}
|
46
|
-
<ListItemText
|
46
|
+
<ListItemText
|
47
|
+
className={classes.icon}
|
48
|
+
primaryTypographyProps={{
|
49
|
+
sx: { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' },
|
50
|
+
}}
|
51
|
+
>
|
52
|
+
{children}
|
53
|
+
</ListItemText>
|
47
54
|
</ListItemButton>
|
48
55
|
)
|
49
56
|
}
|
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": "9.1.0-canary.
|
5
|
+
"version": "9.1.0-canary.35",
|
6
6
|
"sideEffects": false,
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
8
8
|
"eslintConfig": {
|
@@ -24,13 +24,13 @@
|
|
24
24
|
"@emotion/react": "^11",
|
25
25
|
"@emotion/server": "^11",
|
26
26
|
"@emotion/styled": "^11",
|
27
|
-
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.
|
28
|
-
"@graphcommerce/framer-next-pages": "^9.1.0-canary.
|
29
|
-
"@graphcommerce/framer-scroller": "^9.1.0-canary.
|
30
|
-
"@graphcommerce/framer-utils": "^9.1.0-canary.
|
31
|
-
"@graphcommerce/image": "^9.1.0-canary.
|
32
|
-
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.
|
33
|
-
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.
|
27
|
+
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.35",
|
28
|
+
"@graphcommerce/framer-next-pages": "^9.1.0-canary.35",
|
29
|
+
"@graphcommerce/framer-scroller": "^9.1.0-canary.35",
|
30
|
+
"@graphcommerce/framer-utils": "^9.1.0-canary.35",
|
31
|
+
"@graphcommerce/image": "^9.1.0-canary.35",
|
32
|
+
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.35",
|
33
|
+
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.35",
|
34
34
|
"@lingui/core": "^4.2.1",
|
35
35
|
"@lingui/macro": "^4.2.1",
|
36
36
|
"@lingui/react": "^4.2.1",
|
package/utils/cookie.ts
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
import type { SerializeOptions } from 'cookie'
|
2
2
|
import { parse, serialize } from 'cookie'
|
3
|
+
import { motionValue } from 'framer-motion'
|
4
|
+
import { useEffect, useState } from 'react'
|
5
|
+
|
6
|
+
// We need this motionValue to be synced with the actual cookie store.
|
7
|
+
const cookieNotify = motionValue<number>(0)
|
3
8
|
|
4
9
|
/** Read a cookie */
|
5
10
|
export function cookie(name: string): string | undefined
|
@@ -20,6 +25,7 @@ export function cookie(name: string, value?: string | null, options?: SerializeO
|
|
20
25
|
if (typeof value === 'string') {
|
21
26
|
const serialized = serialize(name, value, { path: '/', maxAge: 31536000, ...options })
|
22
27
|
document.cookie = serialized
|
28
|
+
cookieNotify.set(cookieNotify.get() + 1)
|
23
29
|
return undefined
|
24
30
|
}
|
25
31
|
|
@@ -27,8 +33,24 @@ export function cookie(name: string, value?: string | null, options?: SerializeO
|
|
27
33
|
if (value === null) {
|
28
34
|
const serialized = serialize(name, '', { path: '/', maxAge: 0 })
|
29
35
|
document.cookie = serialized
|
36
|
+
cookieNotify.set(cookieNotify.get() + 1)
|
30
37
|
return undefined
|
31
38
|
}
|
32
39
|
|
33
40
|
return undefined
|
34
41
|
}
|
42
|
+
|
43
|
+
export function useCookie(name: string) {
|
44
|
+
const [value, setValue] = useState<string | null | undefined>(undefined)
|
45
|
+
|
46
|
+
useEffect(() => setValue(cookie(name)), [name])
|
47
|
+
useEffect(() => cookieNotify.on('change', () => setValue(cookie(name))))
|
48
|
+
|
49
|
+
const update = (val: string | null) => {
|
50
|
+
if (val) cookie(name, val, { sameSite: true })
|
51
|
+
else cookie(name, null)
|
52
|
+
cookieNotify.set(cookieNotify.get() + 1)
|
53
|
+
}
|
54
|
+
|
55
|
+
return [value, update] as const
|
56
|
+
}
|
package/utils/cssFlags.tsx
CHANGED
@@ -35,10 +35,11 @@ export function getCssFlag(flagName: string) {
|
|
35
35
|
* Example:
|
36
36
|
*
|
37
37
|
* ```tsx
|
38
|
-
* ;<Box sx={{ [
|
38
|
+
* ;<Box sx={{ [cssFlag('mode', 'dark')]: { color: 'white' } }} />
|
39
39
|
* ```
|
40
40
|
*/
|
41
|
-
export const cssFlag = <T extends string>(flagName: T) =>
|
41
|
+
export const cssFlag = <T extends string>(flagName: T, val?: string) =>
|
42
|
+
`html[data-${flagName}${val ? `=${val}` : ''}] &` as const
|
42
43
|
|
43
44
|
/**
|
44
45
|
* Easily create a CSS selector that only applies when a flag is not set.
|
@@ -46,8 +47,8 @@ export const cssFlag = <T extends string>(flagName: T) => `html[data-${flagName}
|
|
46
47
|
* Example:
|
47
48
|
*
|
48
49
|
* ```tsx
|
49
|
-
* ;<Box sx={{ [
|
50
|
+
* ;<Box sx={{ [cssNotFlag('mode', 'dark')]: { color: 'black' } }} />
|
50
51
|
* ```
|
51
52
|
*/
|
52
|
-
export const cssNotFlag = <T extends string>(flagName: T) =>
|
53
|
-
`html:not([data-${flagName}]) &` as const
|
53
|
+
export const cssNotFlag = <T extends string>(flagName: T, val?: string) =>
|
54
|
+
`html:not([data-${flagName}${val ? `=${val}` : ''}]) &` as const
|