@seed-design/stackflow 1.1.15 → 1.1.17

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.
@@ -14,6 +14,9 @@ const React = require('react');
14
14
  const AppBar = require('../../primitive/AppBar/AppBar.cjs');
15
15
  const useAppBarContext = require('../../primitive/AppBar/useAppBarContext.cjs');
16
16
  const createStyleContext = require('../../utils/createStyleContext.cjs');
17
+ const useTopActivity = require('../../primitive/private/useTopActivity.cjs');
18
+ const react = require('@stackflow/react');
19
+ const styled = require('../../utils/styled.cjs');
17
20
 
18
21
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } = createStyleContext.createStyleContext(appBar.appBar);
19
22
  const {
@@ -23,26 +26,28 @@ const {
23
26
  } = createStyleContext.createStyleContext(appBarMain.appBarMain);
24
27
  const AppBarPropsProvider = PropsProvider;
25
28
  const AppBarRoot = React.forwardRef((props, ref) => {
29
+ const { style: boxStyle, restProps: propsWithoutBoxProps } = styled.useBoxBackgroundProps(props);
26
30
  const contextProps = useProps();
27
- const [variantProps, otherProps] = appBar.appBar.splitVariantProps({ ...contextProps, ...props });
28
- const classNames = appBar.appBar(variantProps);
29
- return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(
30
- MainPropsProvider,
31
+ const [variantProps, otherProps] = appBar.appBar.splitVariantProps({
32
+ ...contextProps,
33
+ ...propsWithoutBoxProps
34
+ });
35
+ const topActivityTransitionStyle = useTopActivity.useTopActivity().transitionStyle;
36
+ const resolvedVariantProps = {
37
+ // this includes the default transitionStyle decided by theme, from contextProps or props
38
+ ...variantProps,
39
+ ...react.useActivity().isTop === false && {
40
+ transitionStyle: topActivityTransitionStyle
41
+ }
42
+ };
43
+ const classNames = appBar.appBar(resolvedVariantProps);
44
+ return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(MainPropsProvider, { value: resolvedVariantProps, children: /* @__PURE__ */ jsxRuntime.jsx(
45
+ AppBar.AppBarRoot,
31
46
  {
32
- value: {
33
- theme: variantProps.theme,
34
- transitionStyle: variantProps.transitionStyle,
35
- tone: variantProps.tone
36
- },
37
- children: /* @__PURE__ */ jsxRuntime.jsx(
38
- AppBar.AppBarRoot,
39
- {
40
- ref,
41
- ...domUtils.mergeProps({ className: classNames.root }, otherProps)
42
- }
43
- )
47
+ ref,
48
+ ...domUtils.mergeProps({ className: classNames.root, style: boxStyle }, otherProps)
44
49
  }
45
- ) });
50
+ ) }) });
46
51
  });
47
52
  AppBarRoot.displayName = "AppBarRoot";
48
53
  const AppBarLeft = withContext(
@@ -2,12 +2,13 @@ import { AppBarVariantProps, AppBarVariant } from '@seed-design/css/recipes/app-
2
2
  import { AppBarMainVariantProps } from '@seed-design/css/recipes/app-bar-main';
3
3
  import { PrimitiveProps } from '@seed-design/react-primitive';
4
4
  import { AppBar as AppBarPrimitive } from '../../primitive';
5
+ import { BoxBackgroundProps } from '../../utils/styled';
5
6
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
6
7
  export declare const AppBarPropsProvider: ({ children, value }: {
7
8
  children: React.ReactNode;
8
9
  value: Partial< AppBarVariant>;
9
10
  }) => import("react/jsx-runtime").JSX.Element;
10
- export interface AppBarProps extends AppBarVariantProps, AppBarPrimitive.RootProps {
11
+ export interface AppBarProps extends AppBarVariantProps, AppBarPrimitive.RootProps, BoxBackgroundProps {
11
12
  }
12
13
  export declare const AppBarRoot: ForwardRefExoticComponent<AppBarProps & RefAttributes<HTMLDivElement>>;
13
14
  export interface AppBarLeftProps extends AppBarPrimitive.LeftProps {
@@ -10,6 +10,9 @@ import { forwardRef } from 'react';
10
10
  import { AppBarLeft as AppBarLeft$1, AppBarMain as AppBarMain$1, AppBarRight as AppBarRight$1, AppBarRoot as AppBarRoot$1 } from '../../primitive/AppBar/AppBar.js';
11
11
  import { useAppBarContext } from '../../primitive/AppBar/useAppBarContext.js';
12
12
  import { createStyleContext } from '../../utils/createStyleContext.js';
13
+ import { useTopActivity } from '../../primitive/private/useTopActivity.js';
14
+ import { useActivity } from '@stackflow/react';
15
+ import { useBoxBackgroundProps } from '../../utils/styled.js';
13
16
 
14
17
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } = createStyleContext(appBar);
15
18
  const {
@@ -19,26 +22,28 @@ const {
19
22
  } = createStyleContext(appBarMain);
20
23
  const AppBarPropsProvider = PropsProvider;
21
24
  const AppBarRoot = forwardRef((props, ref) => {
25
+ const { style: boxStyle, restProps: propsWithoutBoxProps } = useBoxBackgroundProps(props);
22
26
  const contextProps = useProps();
23
- const [variantProps, otherProps] = appBar.splitVariantProps({ ...contextProps, ...props });
24
- const classNames = appBar(variantProps);
25
- return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(
26
- MainPropsProvider,
27
+ const [variantProps, otherProps] = appBar.splitVariantProps({
28
+ ...contextProps,
29
+ ...propsWithoutBoxProps
30
+ });
31
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
32
+ const resolvedVariantProps = {
33
+ // this includes the default transitionStyle decided by theme, from contextProps or props
34
+ ...variantProps,
35
+ ...useActivity().isTop === false && {
36
+ transitionStyle: topActivityTransitionStyle
37
+ }
38
+ };
39
+ const classNames = appBar(resolvedVariantProps);
40
+ return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(MainPropsProvider, { value: resolvedVariantProps, children: /* @__PURE__ */ jsx(
41
+ AppBarRoot$1,
27
42
  {
28
- value: {
29
- theme: variantProps.theme,
30
- transitionStyle: variantProps.transitionStyle,
31
- tone: variantProps.tone
32
- },
33
- children: /* @__PURE__ */ jsx(
34
- AppBarRoot$1,
35
- {
36
- ref,
37
- ...mergeProps({ className: classNames.root }, otherProps)
38
- }
39
- )
43
+ ref,
44
+ ...mergeProps({ className: classNames.root, style: boxStyle }, otherProps)
40
45
  }
41
- ) });
46
+ ) }) });
42
47
  });
43
48
  AppBarRoot.displayName = "AppBarRoot";
44
49
  const AppBarLeft = withContext(
@@ -10,6 +10,8 @@ const React = require('react');
10
10
  const AppScreen = require('../../primitive/AppScreen/AppScreen.cjs');
11
11
  const createStyleContext = require('../../utils/createStyleContext.cjs');
12
12
  const AppBar = require('../AppBar/AppBar.cjs');
13
+ const useTopActivity = require('../../primitive/private/useTopActivity.cjs');
14
+ const react = require('@stackflow/react');
13
15
 
14
16
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext.createStyleContext(appScreen.appScreen);
15
17
  const AppScreenPropsProvider = PropsProvider;
@@ -17,21 +19,23 @@ const AppScreenRoot = React.forwardRef((props, ref) => {
17
19
  const contextProps = useProps();
18
20
  const [variantProps, otherProps] = appScreen.appScreen.splitVariantProps({ ...contextProps, ...props });
19
21
  const transitionStyle = variantProps.transitionStyle ?? (variantProps.theme === "cupertino" ? "slideFromRightIOS" : "fadeFromBottomAndroid");
22
+ const topActivityTransitionStyle = useTopActivity.useTopActivity().transitionStyle;
20
23
  const classNames = appScreen.appScreen({
21
24
  ...variantProps,
22
- transitionStyle
25
+ transitionStyle: react.useActivity().isTop ? transitionStyle : topActivityTransitionStyle
23
26
  });
24
27
  return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(
25
28
  AppBar.AppBarPropsProvider,
26
29
  {
27
30
  value: React.useMemo(
28
- () => ({ theme: variantProps.theme, transitionStyle, tone: variantProps.tone }),
29
- [variantProps.theme, transitionStyle, variantProps.tone]
31
+ () => ({ ...variantProps, transitionStyle }),
32
+ [variantProps, transitionStyle]
30
33
  ),
31
34
  children: /* @__PURE__ */ jsxRuntime.jsx(
32
35
  AppScreen.AppScreenRoot,
33
36
  {
34
37
  ref,
38
+ "data-transition-style": transitionStyle,
35
39
  ...domUtils.mergeProps({ className: classNames.root }, otherProps)
36
40
  }
37
41
  )
@@ -6,6 +6,8 @@ import { forwardRef, useMemo } from 'react';
6
6
  import { AppScreenDim as AppScreenDim$1, AppScreenEdge as AppScreenEdge$1, AppScreenLayer as AppScreenLayer$1, AppScreenRoot as AppScreenRoot$1 } from '../../primitive/AppScreen/AppScreen.js';
7
7
  import { createStyleContext } from '../../utils/createStyleContext.js';
8
8
  import { AppBarPropsProvider } from '../AppBar/AppBar.js';
9
+ import { useTopActivity } from '../../primitive/private/useTopActivity.js';
10
+ import { useActivity } from '@stackflow/react';
9
11
 
10
12
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext(appScreen);
11
13
  const AppScreenPropsProvider = PropsProvider;
@@ -13,21 +15,23 @@ const AppScreenRoot = forwardRef((props, ref) => {
13
15
  const contextProps = useProps();
14
16
  const [variantProps, otherProps] = appScreen.splitVariantProps({ ...contextProps, ...props });
15
17
  const transitionStyle = variantProps.transitionStyle ?? (variantProps.theme === "cupertino" ? "slideFromRightIOS" : "fadeFromBottomAndroid");
18
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
16
19
  const classNames = appScreen({
17
20
  ...variantProps,
18
- transitionStyle
21
+ transitionStyle: useActivity().isTop ? transitionStyle : topActivityTransitionStyle
19
22
  });
20
23
  return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(
21
24
  AppBarPropsProvider,
22
25
  {
23
26
  value: useMemo(
24
- () => ({ theme: variantProps.theme, transitionStyle, tone: variantProps.tone }),
25
- [variantProps.theme, transitionStyle, variantProps.tone]
27
+ () => ({ ...variantProps, transitionStyle }),
28
+ [variantProps, transitionStyle]
26
29
  ),
27
30
  children: /* @__PURE__ */ jsx(
28
31
  AppScreenRoot$1,
29
32
  {
30
33
  ref,
34
+ "data-transition-style": transitionStyle,
31
35
  ...mergeProps({ className: classNames.root }, otherProps)
32
36
  }
33
37
  )
@@ -109,9 +109,15 @@ function useGlobalInteraction() {
109
109
  () => ({
110
110
  "data-swipe-back-state": swipeBackState,
111
111
  "data-global-transition-state": topActivity.transitionState,
112
- "data-top-activity-type": topActivity.activityType
112
+ "data-top-activity-type": topActivity.activityType,
113
+ "data-top-transition-style": topActivity.transitionStyle
113
114
  }),
114
- [swipeBackState, topActivity.transitionState, topActivity.activityType]
115
+ [
116
+ swipeBackState,
117
+ topActivity.transitionState,
118
+ topActivity.activityType,
119
+ topActivity.transitionStyle
120
+ ]
115
121
  );
116
122
  return React.useMemo(
117
123
  () => ({
@@ -105,9 +105,15 @@ function useGlobalInteraction() {
105
105
  () => ({
106
106
  "data-swipe-back-state": swipeBackState,
107
107
  "data-global-transition-state": topActivity.transitionState,
108
- "data-top-activity-type": topActivity.activityType
108
+ "data-top-activity-type": topActivity.activityType,
109
+ "data-top-transition-style": topActivity.transitionStyle
109
110
  }),
110
- [swipeBackState, topActivity.transitionState, topActivity.activityType]
111
+ [
112
+ swipeBackState,
113
+ topActivity.transitionState,
114
+ topActivity.activityType,
115
+ topActivity.transitionStyle
116
+ ]
111
117
  );
112
118
  return useMemo(
113
119
  () => ({
@@ -18,6 +18,7 @@ function useTopActivity() {
18
18
  const transitionState = topActivity?.transitionState ?? "enter-done";
19
19
  const [topEl, setTopEl] = React.useState(null);
20
20
  const activityType = topEl?.dataset["activityType"];
21
+ const transitionStyle = topEl?.dataset["transitionStyle"];
21
22
  React.useLayoutEffect(() => {
22
23
  if (!topId) return;
23
24
  const el = document.querySelector(`[data-activity-id="${topId}"]`);
@@ -25,7 +26,8 @@ function useTopActivity() {
25
26
  }, [topId]);
26
27
  return {
27
28
  transitionState,
28
- activityType
29
+ activityType,
30
+ transitionStyle
29
31
  };
30
32
  }
31
33
 
@@ -1,4 +1,5 @@
1
1
  export declare function useTopActivity(): {
2
2
  transitionState: "enter-active" | "enter-done" | "exit-active" | "exit-done";
3
3
  activityType: string | undefined;
4
+ transitionStyle: string | undefined;
4
5
  };
@@ -14,6 +14,7 @@ function useTopActivity() {
14
14
  const transitionState = topActivity?.transitionState ?? "enter-done";
15
15
  const [topEl, setTopEl] = useState(null);
16
16
  const activityType = topEl?.dataset["activityType"];
17
+ const transitionStyle = topEl?.dataset["transitionStyle"];
17
18
  useLayoutEffect(() => {
18
19
  if (!topId) return;
19
20
  const el = document.querySelector(`[data-activity-id="${topId}"]`);
@@ -21,7 +22,8 @@ function useTopActivity() {
21
22
  }, [topId]);
22
23
  return {
23
24
  transitionState,
24
- activityType
25
+ activityType,
26
+ transitionStyle
25
27
  };
26
28
  }
27
29
 
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const vars = require('@seed-design/css/vars');
7
+
8
+ function handleColor(color) {
9
+ if (!color) {
10
+ return void 0;
11
+ }
12
+ const [type, value] = color.split(".");
13
+ return vars.vars.$color[type]?.[value] ?? color;
14
+ }
15
+ function useBoxBackgroundProps(props) {
16
+ const { bg, background, ...restProps } = props;
17
+ return {
18
+ style: {
19
+ "--seed-box-background": handleColor(background ?? bg)
20
+ },
21
+ restProps
22
+ };
23
+ }
24
+
25
+ exports.useBoxBackgroundProps = useBoxBackgroundProps;
@@ -0,0 +1,16 @@
1
+ import { ScopedColorBg, ScopedColorPalette, ScopedColorBanner } from '@seed-design/css/vars';
2
+ /**
3
+ * A minimal subset of `StyleProps` from `@seed-design/react`.
4
+ * Copied here to avoid package dependency. May be extracted to a shared package later.
5
+ */
6
+ export interface BoxBackgroundProps {
7
+ /**
8
+ * Shorthand for `background`.
9
+ */
10
+ bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
11
+ background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
12
+ }
13
+ export declare function useBoxBackgroundProps<T extends BoxBackgroundProps>(props: T): {
14
+ style: React.CSSProperties;
15
+ restProps: Omit<T, keyof BoxBackgroundProps>;
16
+ };
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+ import { vars } from '@seed-design/css/vars';
3
+
4
+ function handleColor(color) {
5
+ if (!color) {
6
+ return void 0;
7
+ }
8
+ const [type, value] = color.split(".");
9
+ return vars.$color[type]?.[value] ?? color;
10
+ }
11
+ function useBoxBackgroundProps(props) {
12
+ const { bg, background, ...restProps } = props;
13
+ return {
14
+ style: {
15
+ "--seed-box-background": handleColor(background ?? bg)
16
+ },
17
+ restProps
18
+ };
19
+ }
20
+
21
+ export { useBoxBackgroundProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/stackflow",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -36,7 +36,7 @@
36
36
  "clsx": "^2.1.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@seed-design/css": "1.1.15",
39
+ "@seed-design/css": "1.2.3",
40
40
  "@stackflow/core": "^1.2.0",
41
41
  "@stackflow/react": "^1.5.1",
42
42
  "@types/react": "^19.2.2",
@@ -49,7 +49,7 @@
49
49
  "vite-plugin-dts": "^4.5.3"
50
50
  },
51
51
  "peerDependencies": {
52
- "@seed-design/css": ">=1.1.15",
52
+ "@seed-design/css": ">=1.1.19",
53
53
  "@stackflow/core": ">=1.1.0",
54
54
  "@stackflow/react": ">=1.4.1",
55
55
  "react": ">=18.0.0",
@@ -8,6 +8,9 @@ import { forwardRef } from "react";
8
8
  import { AppBar as AppBarPrimitive } from "../../primitive";
9
9
  import { useAppBarContext } from "../../primitive/AppBar/useAppBarContext";
10
10
  import { createStyleContext } from "../../utils/createStyleContext";
11
+ import { useTopActivity } from "../../primitive/private/useTopActivity";
12
+ import { useActivity } from "@stackflow/react";
13
+ import { useBoxBackgroundProps, type BoxBackgroundProps } from "../../utils/styled";
11
14
 
12
15
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } =
13
16
  createStyleContext(appBar);
@@ -19,25 +22,40 @@ const {
19
22
 
20
23
  export const AppBarPropsProvider = PropsProvider;
21
24
 
22
- export interface AppBarProps extends AppBarVariantProps, AppBarPrimitive.RootProps {}
25
+ export interface AppBarProps
26
+ extends AppBarVariantProps,
27
+ AppBarPrimitive.RootProps,
28
+ BoxBackgroundProps {}
23
29
 
24
30
  export const AppBarRoot = forwardRef<HTMLDivElement, AppBarProps>((props, ref) => {
31
+ const { style: boxStyle, restProps: propsWithoutBoxProps } = useBoxBackgroundProps(props);
32
+
25
33
  const contextProps = useProps();
26
- const [variantProps, otherProps] = appBar.splitVariantProps({ ...contextProps, ...props });
27
- const classNames = appBar(variantProps);
34
+ const [variantProps, otherProps] = appBar.splitVariantProps({
35
+ ...contextProps,
36
+ ...propsWithoutBoxProps,
37
+ });
38
+
39
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
40
+
41
+ const resolvedVariantProps: AppBarVariantProps = {
42
+ // this includes the default transitionStyle decided by theme, from contextProps or props
43
+ ...variantProps,
44
+ ...(useActivity().isTop === false && {
45
+ transitionStyle: topActivityTransitionStyle as NonNullable<
46
+ AppBarVariantProps["transitionStyle"]
47
+ >,
48
+ }),
49
+ };
50
+
51
+ const classNames = appBar(resolvedVariantProps);
28
52
 
29
53
  return (
30
54
  <ClassNamesProvider value={classNames}>
31
- <MainPropsProvider
32
- value={{
33
- theme: variantProps.theme,
34
- transitionStyle: variantProps.transitionStyle,
35
- tone: variantProps.tone,
36
- }}
37
- >
55
+ <MainPropsProvider value={resolvedVariantProps}>
38
56
  <AppBarPrimitive.Root
39
57
  ref={ref}
40
- {...mergeProps({ className: classNames.root }, otherProps)}
58
+ {...mergeProps({ className: classNames.root, style: boxStyle }, otherProps)}
41
59
  />
42
60
  </MainPropsProvider>
43
61
  </ClassNamesProvider>
@@ -4,6 +4,8 @@ import { forwardRef, useMemo } from "react";
4
4
  import { AppScreen as AppScreenPrimitive } from "../../primitive";
5
5
  import { createStyleContext } from "../../utils/createStyleContext";
6
6
  import { AppBarPropsProvider } from "../AppBar/AppBar";
7
+ import { useTopActivity } from "../../primitive/private/useTopActivity";
8
+ import { useActivity } from "@stackflow/react";
7
9
 
8
10
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext(appScreen);
9
11
 
@@ -21,25 +23,30 @@ export const AppScreenRoot = forwardRef<HTMLDivElement, AppScreenRootProps>((pro
21
23
  const [variantProps, otherProps] = appScreen.splitVariantProps({ ...contextProps, ...props });
22
24
 
23
25
  // TODO: we have to implement conditional default in recipe; this is temporal workaround.
24
- const transitionStyle =
26
+ const transitionStyle: NonNullable<AppScreenVariantProps["transitionStyle"]> =
25
27
  variantProps.transitionStyle ??
26
28
  (variantProps.theme === "cupertino" ? "slideFromRightIOS" : "fadeFromBottomAndroid");
27
29
 
30
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
31
+
28
32
  const classNames = appScreen({
29
33
  ...variantProps,
30
- transitionStyle,
34
+ transitionStyle: useActivity().isTop
35
+ ? transitionStyle
36
+ : (topActivityTransitionStyle as NonNullable<AppScreenVariantProps["transitionStyle"]>),
31
37
  });
32
38
 
33
39
  return (
34
40
  <ClassNamesProvider value={classNames}>
35
41
  <AppBarPropsProvider
36
42
  value={useMemo(
37
- () => ({ theme: variantProps.theme, transitionStyle, tone: variantProps.tone }),
38
- [variantProps.theme, transitionStyle, variantProps.tone],
43
+ () => ({ ...variantProps, transitionStyle }),
44
+ [variantProps, transitionStyle],
39
45
  )}
40
46
  >
41
47
  <AppScreenPrimitive.Root
42
48
  ref={ref}
49
+ data-transition-style={transitionStyle}
43
50
  {...mergeProps({ className: classNames.root }, otherProps)}
44
51
  />
45
52
  </AppBarPropsProvider>
@@ -162,8 +162,14 @@ export function useGlobalInteraction() {
162
162
  "data-swipe-back-state": swipeBackState,
163
163
  "data-global-transition-state": topActivity.transitionState,
164
164
  "data-top-activity-type": topActivity.activityType,
165
+ "data-top-transition-style": topActivity.transitionStyle,
165
166
  }),
166
- [swipeBackState, topActivity.transitionState, topActivity.activityType],
167
+ [
168
+ swipeBackState,
169
+ topActivity.transitionState,
170
+ topActivity.activityType,
171
+ topActivity.transitionStyle,
172
+ ],
167
173
  ) as React.HTMLAttributes<HTMLElement>;
168
174
 
169
175
  return useMemo(
@@ -16,6 +16,7 @@ export function useTopActivity() {
16
16
  // TODO: There should be a better way to handle this. We should not rely on the DOM element to get the activity type.
17
17
  const [topEl, setTopEl] = useState<HTMLElement | null>(null);
18
18
  const activityType = topEl?.dataset["activityType"];
19
+ const transitionStyle = topEl?.dataset["transitionStyle"];
19
20
 
20
21
  useLayoutEffect(() => {
21
22
  if (!topId) return;
@@ -27,5 +28,6 @@ export function useTopActivity() {
27
28
  return {
28
29
  transitionState,
29
30
  activityType,
31
+ transitionStyle,
30
32
  };
31
33
  }
@@ -0,0 +1,41 @@
1
+ import type { ScopedColorBg, ScopedColorPalette, ScopedColorBanner } from "@seed-design/css/vars";
2
+ import { vars } from "@seed-design/css/vars";
3
+
4
+ /**
5
+ * A minimal subset of `StyleProps` from `@seed-design/react`.
6
+ * Copied here to avoid package dependency. May be extracted to a shared package later.
7
+ */
8
+ export interface BoxBackgroundProps {
9
+ /**
10
+ * Shorthand for `background`.
11
+ */
12
+ bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
13
+
14
+ background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
15
+ }
16
+
17
+ function handleColor(color: string | undefined) {
18
+ if (!color) {
19
+ return undefined;
20
+ }
21
+ const [type, value] = color.split(".");
22
+
23
+ // @ts-expect-error - dynamic access
24
+ return vars.$color[type]?.[value] ?? color;
25
+ }
26
+
27
+ export function useBoxBackgroundProps<T extends BoxBackgroundProps>(
28
+ props: T,
29
+ ): {
30
+ style: React.CSSProperties;
31
+ restProps: Omit<T, keyof BoxBackgroundProps>;
32
+ } {
33
+ const { bg, background, ...restProps } = props;
34
+
35
+ return {
36
+ style: {
37
+ "--seed-box-background": handleColor(background ?? bg),
38
+ } as React.CSSProperties,
39
+ restProps: restProps as Omit<T, keyof BoxBackgroundProps>,
40
+ };
41
+ }