@stackflow/plugin-basic-ui 1.3.5-alpha.3 → 1.4.1
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/dist/components/AppBar.css.d.ts +17 -2
- package/dist/components/AppBar.d.ts +3 -2
- package/dist/components/AppScreen.css.d.ts +11 -2
- package/dist/components/AppScreen.d.ts +2 -1
- package/dist/hooks/useStyleEffectOffset.d.ts +2 -1
- package/dist/index.css +35 -21
- package/dist/index.css.map +3 -3
- package/dist/index.js +90 -41
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +90 -41
- package/dist/index.mjs.map +2 -2
- package/package.json +5 -6
- package/src/assets/IconBack.tsx +1 -1
- package/src/components/AppBar.css.ts +19 -2
- package/src/components/AppBar.tsx +12 -11
- package/src/components/AppScreen.css.ts +11 -2
- package/src/components/AppScreen.tsx +67 -26
- package/src/components/BottomSheet.tsx +3 -0
- package/src/components/Modal.tsx +3 -0
- package/src/hooks/useStyleEffectOffset.ts +24 -5
- package/LICENSE +0 -21
|
@@ -134,8 +134,8 @@ export const paper = recipe({
|
|
|
134
134
|
},
|
|
135
135
|
],
|
|
136
136
|
},
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
modalPresentationStyle: {
|
|
138
|
+
fullScreen: {
|
|
139
139
|
selectors: {
|
|
140
140
|
[`${cupertino} &`]: {
|
|
141
141
|
transform: "translate3d(0, 100%, 0)",
|
|
@@ -143,6 +143,15 @@ export const paper = recipe({
|
|
|
143
143
|
},
|
|
144
144
|
},
|
|
145
145
|
},
|
|
146
|
+
activityEnterStyle: {
|
|
147
|
+
slideInLeft: {
|
|
148
|
+
selectors: {
|
|
149
|
+
[`${android} &`]: {
|
|
150
|
+
transform: "translate3d(50%, 0, 0)",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
146
155
|
},
|
|
147
156
|
});
|
|
148
157
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
|
|
3
1
|
import { useActions } from "@stackflow/react";
|
|
4
2
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
5
3
|
import { createContext, useContext, useMemo, useRef } from "react";
|
|
@@ -36,7 +34,8 @@ export type AppScreenProps = Partial<
|
|
|
36
34
|
"theme" | "modalPresentationStyle" | "ref" | "key"
|
|
37
35
|
>;
|
|
38
36
|
preventSwipeBack?: boolean;
|
|
39
|
-
|
|
37
|
+
CUPERTINO_ONLY_modalPresentationStyle?: "fullScreen";
|
|
38
|
+
ANDROID_ONLY_activityEnterStyle?: "slideInLeft";
|
|
40
39
|
children: React.ReactNode;
|
|
41
40
|
};
|
|
42
41
|
const AppScreen: React.FC<AppScreenProps> = ({
|
|
@@ -44,7 +43,8 @@ const AppScreen: React.FC<AppScreenProps> = ({
|
|
|
44
43
|
dimBackgroundColor,
|
|
45
44
|
appBar,
|
|
46
45
|
preventSwipeBack,
|
|
47
|
-
|
|
46
|
+
CUPERTINO_ONLY_modalPresentationStyle,
|
|
47
|
+
ANDROID_ONLY_activityEnterStyle,
|
|
48
48
|
children,
|
|
49
49
|
}) => {
|
|
50
50
|
const globalOptions = useGlobalOptions();
|
|
@@ -58,44 +58,78 @@ const AppScreen: React.FC<AppScreenProps> = ({
|
|
|
58
58
|
const edgeRef = useRef<HTMLDivElement>(null);
|
|
59
59
|
const appBarRef = useRef<HTMLDivElement>(null);
|
|
60
60
|
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const modalPresentationStyle =
|
|
62
|
+
globalOptions.theme === "cupertino"
|
|
63
|
+
? CUPERTINO_ONLY_modalPresentationStyle
|
|
64
|
+
: undefined;
|
|
65
|
+
const activityEnterStyle =
|
|
66
|
+
globalOptions.theme === "android"
|
|
67
|
+
? ANDROID_ONLY_activityEnterStyle
|
|
68
|
+
: undefined;
|
|
69
|
+
|
|
70
|
+
const swipeBackPrevented =
|
|
71
|
+
preventSwipeBack || modalPresentationStyle === "fullScreen";
|
|
72
|
+
|
|
73
|
+
const hasAppBar = !!appBar;
|
|
74
|
+
|
|
75
|
+
const zIndexBase = (activity?.zIndex ?? 0) * 5;
|
|
76
|
+
|
|
77
|
+
let zIndexDim: number;
|
|
78
|
+
let zIndexPaper: number;
|
|
79
|
+
let zIndexEdge: number;
|
|
80
|
+
let zIndexAppBar: number;
|
|
81
|
+
|
|
82
|
+
switch (globalOptions.theme) {
|
|
83
|
+
case "cupertino": {
|
|
84
|
+
zIndexDim =
|
|
85
|
+
zIndexBase + (modalPresentationStyle === "fullScreen" ? 2 : 0);
|
|
86
|
+
zIndexPaper =
|
|
87
|
+
zIndexBase +
|
|
88
|
+
(hasAppBar && modalPresentationStyle !== "fullScreen" ? 1 : 3);
|
|
89
|
+
zIndexEdge = zIndexBase + 4;
|
|
90
|
+
zIndexAppBar = zIndexBase + 7;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "android":
|
|
94
|
+
default: {
|
|
95
|
+
zIndexDim = zIndexBase;
|
|
96
|
+
zIndexPaper = zIndexBase + (activityEnterStyle === "slideInLeft" ? 1 : 3);
|
|
97
|
+
zIndexEdge = zIndexBase + 4;
|
|
98
|
+
zIndexAppBar =
|
|
99
|
+
zIndexBase + (activityEnterStyle === "slideInLeft" ? 7 : 4);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const transitionState = activity?.transitionState ?? "enter-done";
|
|
105
|
+
const lazyTransitionState = useLazy(transitionState);
|
|
63
106
|
|
|
64
107
|
useStyleEffectHide({
|
|
65
108
|
refs: [appScreenRef],
|
|
66
109
|
hasEffect: true,
|
|
67
110
|
});
|
|
68
111
|
useStyleEffectOffset({
|
|
69
|
-
theme: globalOptions.theme,
|
|
70
112
|
refs:
|
|
71
|
-
globalOptions.theme === "cupertino"
|
|
72
|
-
|
|
113
|
+
globalOptions.theme === "cupertino" ||
|
|
114
|
+
activityEnterStyle === "slideInLeft"
|
|
115
|
+
? [paperRef]
|
|
116
|
+
: [paperRef, appBarRef],
|
|
117
|
+
theme: globalOptions.theme,
|
|
118
|
+
activityEnterStyle,
|
|
119
|
+
hasEffect: modalPresentationStyle !== "fullScreen",
|
|
73
120
|
});
|
|
74
121
|
useStyleEffectSwipeBack({
|
|
75
|
-
theme: globalOptions.theme,
|
|
76
122
|
dimRef,
|
|
77
123
|
edgeRef,
|
|
78
124
|
paperRef,
|
|
79
|
-
|
|
125
|
+
theme: globalOptions.theme,
|
|
80
126
|
prevented: swipeBackPrevented,
|
|
81
127
|
onSwiped() {
|
|
82
128
|
pop();
|
|
83
129
|
},
|
|
130
|
+
hasEffect: true,
|
|
84
131
|
});
|
|
85
132
|
|
|
86
|
-
const hasAppBar = !!appBar;
|
|
87
|
-
|
|
88
|
-
const zIndexBase = (activity?.zIndex ?? 0) * 5;
|
|
89
|
-
const zIndexDim = zIndexBase;
|
|
90
|
-
const zIndexPaper =
|
|
91
|
-
zIndexBase + (globalOptions.theme === "cupertino" && hasAppBar ? 1 : 3);
|
|
92
|
-
const zIndexEdge = zIndexBase + 4;
|
|
93
|
-
const zIndexAppBar =
|
|
94
|
-
globalOptions.theme === "cupertino" ? zIndexBase + 7 : zIndexBase + 4;
|
|
95
|
-
|
|
96
|
-
const transitionState = activity?.transitionState ?? "enter-done";
|
|
97
|
-
const lazyTransitionState = useLazy(transitionState);
|
|
98
|
-
|
|
99
133
|
const onAppBarTopClick: React.MouseEventHandler = (e) => {
|
|
100
134
|
appBar?.onTopClick?.(e);
|
|
101
135
|
|
|
@@ -147,13 +181,19 @@ const AppScreen: React.FC<AppScreenProps> = ({
|
|
|
147
181
|
: "0ms",
|
|
148
182
|
}),
|
|
149
183
|
)}
|
|
184
|
+
data-stackflow-component-name="AppScreen"
|
|
185
|
+
data-stackflow-activity-id={activity?.id}
|
|
186
|
+
data-stackflow-activity-is-active={activity?.isActive}
|
|
150
187
|
>
|
|
151
|
-
|
|
188
|
+
{activityEnterStyle !== "slideInLeft" && (
|
|
189
|
+
<div className={css.dim} ref={dimRef} />
|
|
190
|
+
)}
|
|
152
191
|
{appBar && (
|
|
153
192
|
<AppBar
|
|
154
193
|
{...appBar}
|
|
155
194
|
ref={appBarRef}
|
|
156
195
|
modalPresentationStyle={modalPresentationStyle}
|
|
196
|
+
activityEnterStyle={activityEnterStyle}
|
|
157
197
|
onTopClick={onAppBarTopClick}
|
|
158
198
|
/>
|
|
159
199
|
)}
|
|
@@ -161,7 +201,8 @@ const AppScreen: React.FC<AppScreenProps> = ({
|
|
|
161
201
|
key={activity?.id}
|
|
162
202
|
className={css.paper({
|
|
163
203
|
hasAppBar,
|
|
164
|
-
|
|
204
|
+
modalPresentationStyle,
|
|
205
|
+
activityEnterStyle,
|
|
165
206
|
})}
|
|
166
207
|
ref={paperRef}
|
|
167
208
|
>
|
|
@@ -87,6 +87,9 @@ const BottomSheet: React.FC<BottomSheetProps> = ({
|
|
|
87
87
|
: "0ms",
|
|
88
88
|
}),
|
|
89
89
|
)}
|
|
90
|
+
data-stackflow-component-name="BottomSheet"
|
|
91
|
+
data-stackflow-activity-id={activity?.id}
|
|
92
|
+
data-stackflow-activity-is-active={activity?.isActive}
|
|
90
93
|
>
|
|
91
94
|
<div className={css.dim} ref={paperRef} onClick={onDimClick}>
|
|
92
95
|
<div className={css.paper} onClick={onPaperClick}>
|
package/src/components/Modal.tsx
CHANGED
|
@@ -87,6 +87,9 @@ const Modal: React.FC<ModalProps> = ({
|
|
|
87
87
|
: "0ms",
|
|
88
88
|
}),
|
|
89
89
|
)}
|
|
90
|
+
data-stackflow-component-name="Modal"
|
|
91
|
+
data-stackflow-activity-id={activity?.id}
|
|
92
|
+
data-stackflow-activity-is-active={activity?.isActive}
|
|
90
93
|
>
|
|
91
94
|
<div className={css.dim} ref={paperRef} onClick={onDimClick}>
|
|
92
95
|
<div className={css.paper} onClick={onPaperClick}>
|
|
@@ -10,10 +10,12 @@ export const OFFSET_PX_CUPERTINO = 80;
|
|
|
10
10
|
export function useStyleEffectOffset({
|
|
11
11
|
refs,
|
|
12
12
|
theme,
|
|
13
|
-
|
|
13
|
+
activityEnterStyle,
|
|
14
|
+
hasEffect = false,
|
|
14
15
|
}: {
|
|
15
16
|
refs: Array<React.RefObject<any>>;
|
|
16
17
|
theme: "android" | "cupertino";
|
|
18
|
+
activityEnterStyle?: "slideInLeft";
|
|
17
19
|
hasEffect?: boolean;
|
|
18
20
|
}) {
|
|
19
21
|
useStyleEffect({
|
|
@@ -21,10 +23,25 @@ export function useStyleEffectOffset({
|
|
|
21
23
|
refs,
|
|
22
24
|
effect: hasEffect
|
|
23
25
|
? ({ activityTransitionState, refs }) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
let transform: string;
|
|
27
|
+
let opacity: string;
|
|
28
|
+
|
|
29
|
+
switch (theme) {
|
|
30
|
+
case "cupertino": {
|
|
31
|
+
transform = `translate3d(-${OFFSET_PX_CUPERTINO / 16}rem, 0, 0)`;
|
|
32
|
+
opacity = "1";
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case "android":
|
|
36
|
+
default: {
|
|
37
|
+
transform =
|
|
38
|
+
activityEnterStyle === "slideInLeft"
|
|
39
|
+
? `translate3d(-50%, 0, 0)`
|
|
40
|
+
: `translate3d(0, -${OFFSET_PX_ANDROID / 16}rem, 0)`;
|
|
41
|
+
opacity = activityEnterStyle === "slideInLeft" ? "0" : "1";
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
28
45
|
|
|
29
46
|
const cleanup = () => {
|
|
30
47
|
requestNextFrame(() => {
|
|
@@ -36,6 +53,7 @@ export function useStyleEffectOffset({
|
|
|
36
53
|
const $el = ref.current;
|
|
37
54
|
|
|
38
55
|
$el.style.transform = "";
|
|
56
|
+
$el.style.opacity = "";
|
|
39
57
|
|
|
40
58
|
listenOnce($el, "transitionend", () => {
|
|
41
59
|
$el.style.transition = "";
|
|
@@ -55,6 +73,7 @@ export function useStyleEffectOffset({
|
|
|
55
73
|
ref.current.style.transition =
|
|
56
74
|
globalVars.computedTransitionDuration;
|
|
57
75
|
ref.current.style.transform = transform;
|
|
76
|
+
ref.current.style.opacity = opacity;
|
|
58
77
|
});
|
|
59
78
|
|
|
60
79
|
switch (activityTransitionState) {
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Danggeun Market Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|