@ahnseungchan/webviewkit 1.0.7 → 1.2.0
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/README.md +57 -112
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/{packages/core/src/history.d.ts → history.d.ts} +3 -2
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +91 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/stack-dev/stack-dev-roadmap.d.ts +15 -0
- package/dist/stack-dev/stack-dev-roadmap.d.ts.map +1 -0
- package/dist/stack-dev/stack-dev-roadmap.js +66 -0
- package/dist/stack-router/_components/back-router.d.ts +3 -0
- package/dist/stack-router/_components/back-router.d.ts.map +1 -0
- package/dist/stack-router/_components/back-router.js +39 -0
- package/dist/stack-router/_components/header.d.ts +3 -0
- package/dist/stack-router/_components/header.d.ts.map +1 -0
- package/dist/stack-router/_components/header.js +42 -0
- package/dist/{packages/core/src/stack-router → stack-router}/stack-router-provider.d.ts +4 -5
- package/dist/stack-router/stack-router-provider.d.ts.map +1 -0
- package/dist/stack-router/stack-router-provider.js +227 -0
- package/dist/{packages/core/src/type.d.ts → type.d.ts} +3 -5
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +14 -0
- package/package.json +22 -26
- package/dist/packages/core/src/__tests__/back-router.test.d.ts +0 -0
- package/dist/packages/core/src/__tests__/back-router.test.js +0 -62
- package/dist/packages/core/src/__tests__/history.test.d.ts +0 -1
- package/dist/packages/core/src/__tests__/history.test.js +0 -114
- package/dist/packages/core/src/__tests__/stack-router.test.d.ts +0 -0
- package/dist/packages/core/src/__tests__/stack-router.test.js +0 -185
- package/dist/packages/core/src/history.js +0 -82
- package/dist/packages/core/src/index.d.ts +0 -5
- package/dist/packages/core/src/index.js +0 -6
- package/dist/packages/core/src/stack-router/__tests__/stack-router.test.d.ts +0 -0
- package/dist/packages/core/src/stack-router/__tests__/stack-router.test.js +0 -153
- package/dist/packages/core/src/stack-router/_components/back-router.d.ts +0 -2
- package/dist/packages/core/src/stack-router/_components/back-router.js +0 -34
- package/dist/packages/core/src/stack-router/_components/header.d.ts +0 -2
- package/dist/packages/core/src/stack-router/_components/header.js +0 -36
- package/dist/packages/core/src/stack-router/stack-router-provider.js +0 -221
- package/dist/packages/core/src/type.js +0 -11
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import React from "react";
|
|
3
|
-
// import {
|
|
4
|
-
// render,
|
|
5
|
-
// screen,
|
|
6
|
-
// fireEvent,
|
|
7
|
-
// act,
|
|
8
|
-
// waitFor,
|
|
9
|
-
// } from "@testing-library/react";
|
|
10
|
-
// import StackRouter, {
|
|
11
|
-
// useStackRouter,
|
|
12
|
-
// } from "../stack-router/stack-router-provider";
|
|
13
|
-
// import { history } from "../history";
|
|
14
|
-
// // Test component that uses useStackRouter
|
|
15
|
-
// const MockPushComponent = ({ path }: { path: string }) => {
|
|
16
|
-
// const { push } = useStackRouter();
|
|
17
|
-
// return (
|
|
18
|
-
// <button
|
|
19
|
-
// onClick={() => push(path)}
|
|
20
|
-
// data-testid={`push-to-${path.replace("/", "")}`}
|
|
21
|
-
// >
|
|
22
|
-
// Navigate to {path}
|
|
23
|
-
// </button>
|
|
24
|
-
// );
|
|
25
|
-
// };
|
|
26
|
-
// const MockBackComponent = ({ path }: { path: string }) => {
|
|
27
|
-
// const { back } = useStackRouter();
|
|
28
|
-
// return (
|
|
29
|
-
// <button onClick={back} data-testid={`back-to-${path.replace("/", "")}`}>
|
|
30
|
-
// Back
|
|
31
|
-
// </button>
|
|
32
|
-
// );
|
|
33
|
-
// };
|
|
34
|
-
// // Mock components for testing
|
|
35
|
-
// const MockPage1 = () => (
|
|
36
|
-
// <div data-testid="page1">
|
|
37
|
-
// <MockPushComponent path="/page2" />
|
|
38
|
-
// Page1
|
|
39
|
-
// </div>
|
|
40
|
-
// );
|
|
41
|
-
// const MockPage2 = () => (
|
|
42
|
-
// <div data-testid="page2">
|
|
43
|
-
// <MockPushComponent path="/page3" />
|
|
44
|
-
// <MockBackComponent path="/page1" />
|
|
45
|
-
// Page2
|
|
46
|
-
// </div>
|
|
47
|
-
// );
|
|
48
|
-
// const MockPage3 = () => (
|
|
49
|
-
// <div data-testid="page3">
|
|
50
|
-
// <MockBackComponent path="/page2" />
|
|
51
|
-
// Page3
|
|
52
|
-
// </div>
|
|
53
|
-
// );
|
|
54
|
-
// const mockActivities = [
|
|
55
|
-
// { path: "/page1", element: <MockPage1 /> },
|
|
56
|
-
// { path: "/page2", element: <MockPage2 /> },
|
|
57
|
-
// { path: "/page3", element: <MockPage3 /> },
|
|
58
|
-
// ];
|
|
59
|
-
// // Helper function to wait for animations and state updates
|
|
60
|
-
// const waitForStateUpdate = async () => {
|
|
61
|
-
// await act(async () => {
|
|
62
|
-
// await new Promise((resolve) => setTimeout(resolve, 100));
|
|
63
|
-
// });
|
|
64
|
-
// };
|
|
65
|
-
// describe("StackRouter", () => {
|
|
66
|
-
// it("renders initial page correctly", () => {
|
|
67
|
-
// render(
|
|
68
|
-
// <StackRouter
|
|
69
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
70
|
-
// Activities={mockActivities}
|
|
71
|
-
// />
|
|
72
|
-
// );
|
|
73
|
-
// expect(screen.getByTestId("page1")).toBeInTheDocument();
|
|
74
|
-
// });
|
|
75
|
-
// it("navigates to new page when push is called", async () => {
|
|
76
|
-
// render(
|
|
77
|
-
// <StackRouter
|
|
78
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
79
|
-
// Activities={mockActivities}
|
|
80
|
-
// />
|
|
81
|
-
// );
|
|
82
|
-
// // Click the navigation button
|
|
83
|
-
// await act(async () => {
|
|
84
|
-
// fireEvent.click(screen.getByTestId("push-to-page2"));
|
|
85
|
-
// await waitForStateUpdate();
|
|
86
|
-
// });
|
|
87
|
-
// await waitFor(() => {
|
|
88
|
-
// expect(screen.getByText("Page2")).toBeInTheDocument();
|
|
89
|
-
// });
|
|
90
|
-
// });
|
|
91
|
-
// it("goes back when back is called", async () => {
|
|
92
|
-
// render(
|
|
93
|
-
// <StackRouter
|
|
94
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
95
|
-
// Activities={mockActivities}
|
|
96
|
-
// />
|
|
97
|
-
// );
|
|
98
|
-
// // First push to page2
|
|
99
|
-
// await act(async () => {
|
|
100
|
-
// fireEvent.click(screen.getByTestId("push-to-page2"));
|
|
101
|
-
// await waitForStateUpdate();
|
|
102
|
-
// });
|
|
103
|
-
// // Then go back
|
|
104
|
-
// await act(async () => {
|
|
105
|
-
// fireEvent.click(screen.getByTestId("back-to-page1"));
|
|
106
|
-
// await waitForStateUpdate();
|
|
107
|
-
// });
|
|
108
|
-
// await waitFor(() => {
|
|
109
|
-
// expect(screen.getByText("Page1")).toBeInTheDocument();
|
|
110
|
-
// });
|
|
111
|
-
// });
|
|
112
|
-
// it("handles multiple page transitions correctly", async () => {
|
|
113
|
-
// render(
|
|
114
|
-
// <StackRouter
|
|
115
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
116
|
-
// Activities={mockActivities}
|
|
117
|
-
// />
|
|
118
|
-
// );
|
|
119
|
-
// // Navigate through pages
|
|
120
|
-
// await act(async () => {
|
|
121
|
-
// fireEvent.click(screen.getByTestId("push-to-page2"));
|
|
122
|
-
// await waitForStateUpdate();
|
|
123
|
-
// });
|
|
124
|
-
// await waitFor(() => {
|
|
125
|
-
// expect(screen.getByText("Page2")).toBeInTheDocument();
|
|
126
|
-
// });
|
|
127
|
-
// await act(async () => {
|
|
128
|
-
// fireEvent.click(screen.getByTestId("push-to-page3"));
|
|
129
|
-
// await waitForStateUpdate();
|
|
130
|
-
// });
|
|
131
|
-
// await waitFor(() => {
|
|
132
|
-
// expect(screen.getByText("Page3")).toBeInTheDocument();
|
|
133
|
-
// });
|
|
134
|
-
// // Go back twice
|
|
135
|
-
// await act(async () => {
|
|
136
|
-
// fireEvent.click(screen.getByTestId("back-to-page2"));
|
|
137
|
-
// await waitForStateUpdate();
|
|
138
|
-
// });
|
|
139
|
-
// await waitFor(() => {
|
|
140
|
-
// expect(screen.getByText("Page2")).toBeInTheDocument();
|
|
141
|
-
// });
|
|
142
|
-
// await act(async () => {
|
|
143
|
-
// fireEvent.click(screen.getByTestId("back-to-page1"));
|
|
144
|
-
// await waitForStateUpdate();
|
|
145
|
-
// });
|
|
146
|
-
// await waitFor(() => {
|
|
147
|
-
// expect(screen.getByText("Page1")).toBeInTheDocument();
|
|
148
|
-
// });
|
|
149
|
-
// });
|
|
150
|
-
// it("maintains correct page order in stack", async () => {
|
|
151
|
-
// const { rerender } = render(
|
|
152
|
-
// <StackRouter
|
|
153
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
154
|
-
// Activities={mockActivities}
|
|
155
|
-
// />
|
|
156
|
-
// );
|
|
157
|
-
// // Navigate to page2
|
|
158
|
-
// await act(async () => {
|
|
159
|
-
// fireEvent.click(screen.getByTestId("push-to-page2"));
|
|
160
|
-
// await waitForStateUpdate();
|
|
161
|
-
// });
|
|
162
|
-
// await waitFor(() => {
|
|
163
|
-
// expect(screen.getByText("Page2")).toBeInTheDocument();
|
|
164
|
-
// });
|
|
165
|
-
// // Navigate to page3
|
|
166
|
-
// await act(async () => {
|
|
167
|
-
// fireEvent.click(screen.getByTestId("push-to-page3"));
|
|
168
|
-
// await waitForStateUpdate();
|
|
169
|
-
// });
|
|
170
|
-
// await waitFor(() => {
|
|
171
|
-
// expect(screen.getByText("Page3")).toBeInTheDocument();
|
|
172
|
-
// });
|
|
173
|
-
// });
|
|
174
|
-
// it("handles maxWidth prop correctly", () => {
|
|
175
|
-
// render(
|
|
176
|
-
// <StackRouter
|
|
177
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
178
|
-
// Activities={mockActivities}
|
|
179
|
-
// maxWidth="800px"
|
|
180
|
-
// />
|
|
181
|
-
// );
|
|
182
|
-
// const layout = screen.getByTestId("layout");
|
|
183
|
-
// expect(layout).toHaveStyle({ maxWidth: "800px" });
|
|
184
|
-
// });
|
|
185
|
-
// });
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { HistoryAction } from "./type";
|
|
2
|
-
const listeners = new Set();
|
|
3
|
-
const handlePopState = (event) => {
|
|
4
|
-
const state = event.state;
|
|
5
|
-
notifyListeners(state);
|
|
6
|
-
};
|
|
7
|
-
// notify to listeners
|
|
8
|
-
const notifyListeners = (state) => {
|
|
9
|
-
listeners.forEach((listener) => listener(state));
|
|
10
|
-
};
|
|
11
|
-
// initialize
|
|
12
|
-
window.addEventListener("popstate", handlePopState);
|
|
13
|
-
export const history = {
|
|
14
|
-
// add new history entry
|
|
15
|
-
push: async (path, data) => {
|
|
16
|
-
const state = {
|
|
17
|
-
path,
|
|
18
|
-
data,
|
|
19
|
-
action: HistoryAction.PUSH,
|
|
20
|
-
};
|
|
21
|
-
window.history.pushState(state, "", path);
|
|
22
|
-
// 애니메이션을 위한 지연
|
|
23
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
24
|
-
notifyListeners(state);
|
|
25
|
-
},
|
|
26
|
-
// replace current history entry
|
|
27
|
-
replace: async (path, data) => {
|
|
28
|
-
const state = {
|
|
29
|
-
path,
|
|
30
|
-
data,
|
|
31
|
-
action: HistoryAction.REPLACE,
|
|
32
|
-
};
|
|
33
|
-
window.history.replaceState(state, "", path);
|
|
34
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
35
|
-
notifyListeners(state);
|
|
36
|
-
},
|
|
37
|
-
// back to previous history entry
|
|
38
|
-
back: async () => {
|
|
39
|
-
window.history.back();
|
|
40
|
-
await new Promise((resolve) => {
|
|
41
|
-
const handlePopState = () => {
|
|
42
|
-
window.removeEventListener("popstate", handlePopState);
|
|
43
|
-
resolve();
|
|
44
|
-
};
|
|
45
|
-
window.addEventListener("popstate", handlePopState);
|
|
46
|
-
});
|
|
47
|
-
const state = {
|
|
48
|
-
path: window.location.pathname,
|
|
49
|
-
action: HistoryAction.POP,
|
|
50
|
-
};
|
|
51
|
-
notifyListeners(state);
|
|
52
|
-
},
|
|
53
|
-
// forward to next history entry
|
|
54
|
-
forward: async () => {
|
|
55
|
-
window.history.forward();
|
|
56
|
-
const state = {
|
|
57
|
-
path: window.location.pathname,
|
|
58
|
-
action: HistoryAction.PUSH,
|
|
59
|
-
};
|
|
60
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
61
|
-
notifyListeners(state);
|
|
62
|
-
},
|
|
63
|
-
// go to specific history entry
|
|
64
|
-
go: async (delta) => {
|
|
65
|
-
window.history.go(delta);
|
|
66
|
-
const state = {
|
|
67
|
-
path: window.location.pathname,
|
|
68
|
-
action: HistoryAction.PUSH,
|
|
69
|
-
};
|
|
70
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
71
|
-
notifyListeners(state);
|
|
72
|
-
},
|
|
73
|
-
// get current history entry
|
|
74
|
-
getCurrentState: () => window.history.state || {
|
|
75
|
-
path: window.location.pathname,
|
|
76
|
-
},
|
|
77
|
-
// change listener to history
|
|
78
|
-
addListener: (listener) => {
|
|
79
|
-
listeners.add(listener);
|
|
80
|
-
return () => listeners.delete(listener);
|
|
81
|
-
},
|
|
82
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type { StackRouterProviderProps, VisiblePage, DirectionType, HistoryState, HistoryListener, } from "./type";
|
|
2
|
-
export { Direction, HistoryAction } from "./type";
|
|
3
|
-
export { history } from "./history";
|
|
4
|
-
export { default as StackRouterProvider } from "./stack-router/stack-router-provider";
|
|
5
|
-
export { useStackRouter } from "./stack-router/stack-router-provider";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Direction, HistoryAction } from "./type";
|
|
2
|
-
// Export history API
|
|
3
|
-
export { history } from "./history";
|
|
4
|
-
// Export stack router components
|
|
5
|
-
export { default as StackRouterProvider } from "./stack-router/stack-router-provider";
|
|
6
|
-
export { useStackRouter } from "./stack-router/stack-router-provider";
|
|
File without changes
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import React from "react";
|
|
3
|
-
// import { render, screen, fireEvent, act } from "@testing-library/react";
|
|
4
|
-
// import StackRouter from "../stack-router-provider";
|
|
5
|
-
// import { history } from "../../history";
|
|
6
|
-
// // Mock components for testing
|
|
7
|
-
// const MockPage1 = () => <div data-testid="page1">Page 1</div>;
|
|
8
|
-
// const MockPage2 = () => <div data-testid="page2">Page 2</div>;
|
|
9
|
-
// const MockPage3 = () => <div data-testid="page3">Page 3</div>;
|
|
10
|
-
// const mockActivities = [
|
|
11
|
-
// { path: "/page1", element: <MockPage1 /> },
|
|
12
|
-
// { path: "/page2", element: <MockPage2 /> },
|
|
13
|
-
// { path: "/page3", element: <MockPage3 /> },
|
|
14
|
-
// ];
|
|
15
|
-
// // Helper function to wait for animations
|
|
16
|
-
// const waitForAnimation = async () => {
|
|
17
|
-
// await act(async () => {
|
|
18
|
-
// await new Promise((resolve) => setTimeout(resolve, 700)); // 애니메이션 시간과 동일하게 설정
|
|
19
|
-
// });
|
|
20
|
-
// };
|
|
21
|
-
// describe("StackRouter", () => {
|
|
22
|
-
// beforeEach(() => {
|
|
23
|
-
// // Reset history before each test
|
|
24
|
-
// history.push("/page1");
|
|
25
|
-
// });
|
|
26
|
-
// it("renders initial page correctly", () => {
|
|
27
|
-
// render(
|
|
28
|
-
// <StackRouter
|
|
29
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
30
|
-
// Activities={mockActivities}
|
|
31
|
-
// />
|
|
32
|
-
// );
|
|
33
|
-
// expect(screen.getByTestId("page1")).toBeInTheDocument();
|
|
34
|
-
// });
|
|
35
|
-
// it("navigates to new page when push is called", async () => {
|
|
36
|
-
// const { rerender } = render(
|
|
37
|
-
// <StackRouter
|
|
38
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
39
|
-
// Activities={mockActivities}
|
|
40
|
-
// />
|
|
41
|
-
// );
|
|
42
|
-
// // Mock history.push
|
|
43
|
-
// history.push("/page2");
|
|
44
|
-
// // Wait for animation
|
|
45
|
-
// await waitForAnimation();
|
|
46
|
-
// rerender(
|
|
47
|
-
// <StackRouter
|
|
48
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
49
|
-
// Activities={mockActivities}
|
|
50
|
-
// />
|
|
51
|
-
// );
|
|
52
|
-
// // 페이지가 렌더링될 때까지 대기
|
|
53
|
-
// await screen.findByTestId("page2");
|
|
54
|
-
// expect(screen.getByTestId("page2")).toBeInTheDocument();
|
|
55
|
-
// });
|
|
56
|
-
// it("goes back when back is called", async () => {
|
|
57
|
-
// const { rerender } = render(
|
|
58
|
-
// <StackRouter
|
|
59
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
60
|
-
// Activities={mockActivities}
|
|
61
|
-
// />
|
|
62
|
-
// );
|
|
63
|
-
// // First push to page2
|
|
64
|
-
// history.push("/page2");
|
|
65
|
-
// await waitForAnimation();
|
|
66
|
-
// // Then go back
|
|
67
|
-
// history.back();
|
|
68
|
-
// await waitForAnimation();
|
|
69
|
-
// rerender(
|
|
70
|
-
// <StackRouter
|
|
71
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
72
|
-
// Activities={mockActivities}
|
|
73
|
-
// />
|
|
74
|
-
// );
|
|
75
|
-
// // 페이지가 렌더링될 때까지 대기
|
|
76
|
-
// await screen.findByTestId("page1");
|
|
77
|
-
// expect(screen.getByTestId("page1")).toBeInTheDocument();
|
|
78
|
-
// });
|
|
79
|
-
// it("handles multiple page transitions correctly", async () => {
|
|
80
|
-
// const { rerender } = render(
|
|
81
|
-
// <StackRouter
|
|
82
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
83
|
-
// Activities={mockActivities}
|
|
84
|
-
// />
|
|
85
|
-
// );
|
|
86
|
-
// // Navigate through pages
|
|
87
|
-
// history.push("/page2");
|
|
88
|
-
// await waitForAnimation();
|
|
89
|
-
// history.push("/page3");
|
|
90
|
-
// await waitForAnimation();
|
|
91
|
-
// rerender(
|
|
92
|
-
// <StackRouter
|
|
93
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
94
|
-
// Activities={mockActivities}
|
|
95
|
-
// />
|
|
96
|
-
// );
|
|
97
|
-
// // 페이지가 렌더링될 때까지 대기
|
|
98
|
-
// await screen.findByTestId("page3");
|
|
99
|
-
// expect(screen.getByTestId("page3")).toBeInTheDocument();
|
|
100
|
-
// // Go back twice
|
|
101
|
-
// history.back();
|
|
102
|
-
// await waitForAnimation();
|
|
103
|
-
// history.back();
|
|
104
|
-
// await waitForAnimation();
|
|
105
|
-
// rerender(
|
|
106
|
-
// <StackRouter
|
|
107
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
108
|
-
// Activities={mockActivities}
|
|
109
|
-
// />
|
|
110
|
-
// );
|
|
111
|
-
// // 페이지가 렌더링될 때까지 대기
|
|
112
|
-
// await screen.findByTestId("page1");
|
|
113
|
-
// expect(screen.getByTestId("page1")).toBeInTheDocument();
|
|
114
|
-
// });
|
|
115
|
-
// it("maintains correct page order in stack", async () => {
|
|
116
|
-
// const { rerender } = render(
|
|
117
|
-
// <StackRouter
|
|
118
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
119
|
-
// Activities={mockActivities}
|
|
120
|
-
// />
|
|
121
|
-
// );
|
|
122
|
-
// // Navigate to page2
|
|
123
|
-
// history.push("/page2");
|
|
124
|
-
// await waitForAnimation();
|
|
125
|
-
// // Navigate to page3
|
|
126
|
-
// history.push("/page3");
|
|
127
|
-
// await waitForAnimation();
|
|
128
|
-
// rerender(
|
|
129
|
-
// <StackRouter
|
|
130
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
131
|
-
// Activities={mockActivities}
|
|
132
|
-
// />
|
|
133
|
-
// );
|
|
134
|
-
// // 모든 페이지가 렌더링될 때까지 대기
|
|
135
|
-
// await screen.findByTestId("page3");
|
|
136
|
-
// // Check if all pages are in the correct order
|
|
137
|
-
// const pages = screen.getAllByTestId(/page[1-3]/);
|
|
138
|
-
// expect(pages[0]).toHaveTextContent("Page 1");
|
|
139
|
-
// expect(pages[1]).toHaveTextContent("Page 2");
|
|
140
|
-
// expect(pages[2]).toHaveTextContent("Page 3");
|
|
141
|
-
// });
|
|
142
|
-
// it("handles maxWidth prop correctly", () => {
|
|
143
|
-
// const { container } = render(
|
|
144
|
-
// <StackRouter
|
|
145
|
-
// initialActivity={{ path: "/page1", element: <MockPage1 /> }}
|
|
146
|
-
// Activities={mockActivities}
|
|
147
|
-
// maxWidth="800px"
|
|
148
|
-
// />
|
|
149
|
-
// );
|
|
150
|
-
// const layout = container.querySelector('div[style*="max-width: 800px"]');
|
|
151
|
-
// expect(layout).toBeInTheDocument();
|
|
152
|
-
// });
|
|
153
|
-
// });
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import styled from "@emotion/styled";
|
|
3
|
-
import { useStackRouter } from "../stack-router-provider";
|
|
4
|
-
const BackRouter = () => {
|
|
5
|
-
const { back } = useStackRouter();
|
|
6
|
-
return (_jsx(BackButton, { onClick: back, children: _jsx(BackIcon, {}) }));
|
|
7
|
-
};
|
|
8
|
-
export default BackRouter;
|
|
9
|
-
/**
|
|
10
|
-
styles
|
|
11
|
-
*/
|
|
12
|
-
const BackButton = styled.button `
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
width: 40px;
|
|
17
|
-
height: 40px;
|
|
18
|
-
border: none;
|
|
19
|
-
background: none;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
padding: 8px;
|
|
22
|
-
border-radius: 50%;
|
|
23
|
-
transition: all 0.2s;
|
|
24
|
-
color: #000000;
|
|
25
|
-
|
|
26
|
-
&:hover {
|
|
27
|
-
color: #666666;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&:active {
|
|
31
|
-
color: #999999;
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
const BackIcon = () => (_jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M12 20L4 12L12 4", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
import styled from "@emotion/styled";
|
|
4
|
-
import BackRouter from "./back-router";
|
|
5
|
-
import { useStackRouter } from "../stack-router-provider";
|
|
6
|
-
const Header = () => {
|
|
7
|
-
const { currentPath, visiblePages } = useStackRouter();
|
|
8
|
-
const [displayPath, setDisplayPath] = useState(currentPath);
|
|
9
|
-
const [isVisible, setIsVisible] = useState(visiblePages.length > 1);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const timer = setTimeout(() => {
|
|
12
|
-
setDisplayPath(currentPath);
|
|
13
|
-
setIsVisible(visiblePages.length > 1);
|
|
14
|
-
}, 500);
|
|
15
|
-
return () => clearTimeout(timer);
|
|
16
|
-
}, [currentPath, visiblePages]);
|
|
17
|
-
return (_jsxs(StyledHeader, { children: [isVisible && _jsx(BackRouter, {}), _jsx(StyledTitle, { children: displayPath })] }));
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
styles
|
|
21
|
-
*/
|
|
22
|
-
const StyledHeader = styled.header `
|
|
23
|
-
width: 100%;
|
|
24
|
-
height: 64px;
|
|
25
|
-
background-color: white;
|
|
26
|
-
border-bottom: 1px solid #e5e7eb;
|
|
27
|
-
display: flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
padding: 0 1rem;
|
|
30
|
-
`;
|
|
31
|
-
const StyledTitle = styled.h1 `
|
|
32
|
-
font-size: 1.25rem;
|
|
33
|
-
font-weight: 600;
|
|
34
|
-
color: #111827;
|
|
35
|
-
`;
|
|
36
|
-
export default Header;
|