-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathStack.ts
More file actions
36 lines (32 loc) · 1.06 KB
/
Copy pathStack.ts
File metadata and controls
36 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { basicRendererPlugin } from "@stackflow/plugin-renderer-basic";
import { type ActivityComponentType, stackflow } from "@stackflow/react/future";
import { defineConfig, type RegisteredActivityName } from "@stackflow/config";
import { seedPlugin } from "@seed-design/stackflow";
interface MakeStackProps {
activities: {
name: RegisteredActivityName;
component: ActivityComponentType<RegisteredActivityName>;
}[];
}
export const makeStack = ({ activities }: MakeStackProps) => {
const components = Object.fromEntries(
activities.map(({ name, component }) => [name, component]),
) as {
[K in RegisteredActivityName]: ActivityComponentType<K>;
};
const { Stack, actions, stepActions } = stackflow({
config: defineConfig({
activities: activities.map(({ name }) => ({ name })),
transitionDuration: 270,
initialActivity: () => activities[0].name,
}),
components,
plugins: [
basicRendererPlugin(),
seedPlugin({
theme: "cupertino",
}),
],
});
return { Stack, actions, stepActions };
};