@heliosgraphics/ui 2.0.0-alpha.73 → 2.0.0-alpha.75
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/components/Dialog/Dialog.module.css +1 -8
- package/components/Layout/components/LayoutMain/components/LayoutMainContent/LayoutMainContent.tsx +15 -4
- package/components/Layout/components/LayoutMain/components/LayoutMainContent/LayoutMainContent.utils.ts +65 -0
- package/components/Shimmer/Shimmer.tsx +1 -1
- package/css/feat.atomics.css +6 -10
- package/package.json +1 -1
- package/types/scale.ts +1 -0
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
width: 580px;
|
|
10
10
|
|
|
11
11
|
border: 0;
|
|
12
|
-
border-radius: var(--radius-lg);
|
|
12
|
+
border-radius: var(--radius-lg) 0 0 var(--radius-lg);
|
|
13
13
|
touch-action: pan-y;
|
|
14
14
|
transform: translateX(-50%);
|
|
15
15
|
}
|
|
@@ -29,11 +29,6 @@
|
|
|
29
29
|
transform: translateX(-50%) translateY(-50%);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.dialog::-webkit-scrollbar {
|
|
33
|
-
height: 8px;
|
|
34
|
-
width: 8px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
32
|
.dialog__content {
|
|
38
33
|
position: relative;
|
|
39
34
|
z-index: var(--z-index-1);
|
|
@@ -60,8 +55,6 @@
|
|
|
60
55
|
|
|
61
56
|
@media (max-width: 576px) {
|
|
62
57
|
.dialog:not(.dialogCentered) {
|
|
63
|
-
margin-left: 8px;
|
|
64
|
-
margin-right: 8px;
|
|
65
58
|
width: calc(100% - 16px);
|
|
66
59
|
}
|
|
67
60
|
|
package/components/Layout/components/LayoutMain/components/LayoutMainContent/LayoutMainContent.tsx
CHANGED
|
@@ -4,6 +4,11 @@ import { getFlexUtility, getSafeFlexProps } from "../../../../../Flex/Flex.utils
|
|
|
4
4
|
import { getClasses } from "@heliosgraphics/utils/classnames"
|
|
5
5
|
import styles from "./LayoutMainContent.module.css"
|
|
6
6
|
import { useLayoutEffect, useRef, type FC } from "react"
|
|
7
|
+
import {
|
|
8
|
+
initLocationTracker,
|
|
9
|
+
shouldResetScrollOnLocationChange,
|
|
10
|
+
subscribeToLocationChanges,
|
|
11
|
+
} from "./LayoutMainContent.utils"
|
|
7
12
|
import type { LayoutMainContentProps } from "./LayoutMainContent.types"
|
|
8
13
|
|
|
9
14
|
export const LayoutMainContent: FC<LayoutMainContentProps> = (props) => {
|
|
@@ -16,11 +21,17 @@ export const LayoutMainContent: FC<LayoutMainContentProps> = (props) => {
|
|
|
16
21
|
const mainContentClasses: string = getClasses(layoutMainFlexClasses, styles.layoutMainContent, "ui-bg-secondary")
|
|
17
22
|
const safeProps = getSafeFlexProps(props)
|
|
18
23
|
|
|
19
|
-
useLayoutEffect(() => {
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
useLayoutEffect((): (() => void) => {
|
|
25
|
+
const onLocationChange = (): void => {
|
|
26
|
+
if (shouldResetScrollOnLocationChange()) {
|
|
27
|
+
contentRef.current?.scrollTo(0, 0)
|
|
28
|
+
}
|
|
22
29
|
}
|
|
23
|
-
|
|
30
|
+
|
|
31
|
+
initLocationTracker()
|
|
32
|
+
|
|
33
|
+
return subscribeToLocationChanges(onLocationChange)
|
|
34
|
+
})
|
|
24
35
|
|
|
25
36
|
return (
|
|
26
37
|
<section {...safeProps} ref={contentRef} className={mainContentClasses} data-ui-component="Main.Content">
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
let lastLocation: string | null = null
|
|
4
|
+
let isHistoryPatched: boolean = false
|
|
5
|
+
|
|
6
|
+
const getLocationKey = (): string | null => {
|
|
7
|
+
if (!globalThis?.location) return null
|
|
8
|
+
|
|
9
|
+
return `${globalThis.location.pathname}${globalThis.location.search}${globalThis.location.hash}`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const patchHistory = (): void => {
|
|
13
|
+
if (isHistoryPatched || !globalThis?.history) return
|
|
14
|
+
|
|
15
|
+
isHistoryPatched = true
|
|
16
|
+
|
|
17
|
+
const { pushState, replaceState } = globalThis.history
|
|
18
|
+
const dispatchLocationChange = (): void => {
|
|
19
|
+
globalThis.dispatchEvent(new Event("locationchange"))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const pushStateWrapper = (...args: Parameters<History["pushState"]>): ReturnType<History["pushState"]> => {
|
|
23
|
+
const result = pushState.apply(globalThis.history, args as Parameters<History["pushState"]>)
|
|
24
|
+
dispatchLocationChange()
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const replaceStateWrapper = (...args: Parameters<History["replaceState"]>): ReturnType<History["replaceState"]> => {
|
|
29
|
+
const result = replaceState.apply(globalThis.history, args as Parameters<History["replaceState"]>)
|
|
30
|
+
dispatchLocationChange()
|
|
31
|
+
return result
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
globalThis.history.pushState = pushStateWrapper
|
|
35
|
+
globalThis.history.replaceState = replaceStateWrapper
|
|
36
|
+
|
|
37
|
+
globalThis.addEventListener("popstate", dispatchLocationChange)
|
|
38
|
+
globalThis.addEventListener("hashchange", dispatchLocationChange)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const initLocationTracker = (): void => {
|
|
42
|
+
patchHistory()
|
|
43
|
+
lastLocation = getLocationKey()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const shouldResetScrollOnLocationChange = (): boolean => {
|
|
47
|
+
const currentLocation: string | null = getLocationKey()
|
|
48
|
+
const shouldReset: boolean = Boolean(currentLocation && lastLocation && currentLocation !== lastLocation)
|
|
49
|
+
|
|
50
|
+
lastLocation = currentLocation
|
|
51
|
+
|
|
52
|
+
return shouldReset
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const subscribeToLocationChanges = (handler: () => void): (() => void) => {
|
|
56
|
+
patchHistory()
|
|
57
|
+
|
|
58
|
+
globalThis.addEventListener("locationchange", handler)
|
|
59
|
+
|
|
60
|
+
const unsubscribe = (): void => {
|
|
61
|
+
globalThis.removeEventListener("locationchange", handler)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return unsubscribe
|
|
65
|
+
}
|
|
@@ -6,7 +6,7 @@ import type { FC } from "react"
|
|
|
6
6
|
export const Shimmer: FC<ShimmerProps> = ({ isRounded, paddingTop, paddingBottom, height, width }) => {
|
|
7
7
|
const shimmerDivClasses: string = getClasses({
|
|
8
8
|
["radius-max"]: isRounded,
|
|
9
|
-
["radius-
|
|
9
|
+
["radius-sm"]: !isRounded,
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
return (
|
package/css/feat.atomics.css
CHANGED
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
|
|
55
55
|
/* scrollbar */
|
|
56
56
|
.ui-scrollbar::-webkit-scrollbar {
|
|
57
|
-
height:
|
|
58
|
-
width:
|
|
57
|
+
height: 8px;
|
|
58
|
+
width: 8px;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
.ui-scrollbar--narrow::-webkit-scrollbar {
|
|
62
|
-
height:
|
|
63
|
-
width:
|
|
62
|
+
height: 4px;
|
|
63
|
+
width: 4px;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
.ui-scrollbar::-webkit-scrollbar-
|
|
67
|
-
background-color: var(--ui-bg-
|
|
66
|
+
.ui-scrollbar::-webkit-scrollbar-track {
|
|
67
|
+
background-color: var(--ui-bg-tertiary);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
.ui-scrollbar::-webkit-scrollbar-thumb {
|
|
@@ -75,10 +75,6 @@
|
|
|
75
75
|
transition: all var(--speed-sm) var(--ease-in-out-sine);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.ui-scrollbar::-webkit-scrollbar-track {
|
|
79
|
-
background-color: var(--ui-bg-soft-gray);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
78
|
.ui-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
83
79
|
background-color: var(--ui-bg-secondary);
|
|
84
80
|
}
|
package/package.json
CHANGED