From 968b6b4977ae495cf2d3a158bedda6fb5cc7affd Mon Sep 17 00:00:00 2001
From: KaWaite <34051327+KaWaite@users.noreply.github.com>
Date: Wed, 29 Nov 2023 16:39:27 +0900
Subject: [PATCH] chore(web): add page name tag to indicator and fix some small
bugs (#841)
---
server/pkg/builtin/manifest.yml | 9 +-
server/pkg/builtin/manifest_ja.yml | 2 +
web/src/beta/components/Popover/hooks.ts | 3 +-
web/src/beta/components/Popover/index.tsx | 116 +++++++++---------
web/src/beta/components/Popover/types.ts | 3 +-
.../SidePanelSectionField/index.tsx | 9 +-
.../components/fields/ListField/index.tsx | 2 +-
.../fields/Property/PropertyList/index.tsx | 2 +-
.../tabs/map/LeftPanel/GroupField/index.tsx | 2 +-
.../PageIndicator/IndicatorSection.tsx | 88 +++++++++++++
.../core/StoryPanel/PageIndicator/index.tsx | 54 ++++----
web/src/beta/lib/core/StoryPanel/hooks.ts | 1 +
web/src/beta/lib/core/StoryPanel/index.tsx | 1 +
web/src/services/i18n/translations/en.yml | 3 +-
web/src/services/i18n/translations/ja.yml | 3 +-
15 files changed, 193 insertions(+), 105 deletions(-)
create mode 100644 web/src/beta/lib/core/StoryPanel/PageIndicator/IndicatorSection.tsx
diff --git a/server/pkg/builtin/manifest.yml b/server/pkg/builtin/manifest.yml
index d0cd41b88a..af103762c0 100644
--- a/server/pkg/builtin/manifest.yml
+++ b/server/pkg/builtin/manifest.yml
@@ -23,11 +23,11 @@ extensions:
defaultValue: 3d
choices:
- key: 3d
- label: Scene 3D
+ label: 3D
- key: 2d
- label: Scene 2D
+ label: 2D
- key: columbus
- label: Columbus View
+ label: 2.5D (Columbus View)
- id: ion
type: string
title: Cesium Ion API access token
@@ -2323,11 +2323,10 @@ extensions:
ui: color
- id: padding
type: spacing
- title: Spacing settings
+ title: Padding
ui: padding
min: 0
max: 100
- defaultValue: { top: 0, bottom: 0, left: 0, right: 0 }
- id: cameraAnimation
title: Camera Animation
fields:
diff --git a/server/pkg/builtin/manifest_ja.yml b/server/pkg/builtin/manifest_ja.yml
index cb87fd1b13..72cf712b59 100644
--- a/server/pkg/builtin/manifest_ja.yml
+++ b/server/pkg/builtin/manifest_ja.yml
@@ -1153,6 +1153,8 @@ extensions:
title: タイトル
color:
title: 色
+ padding:
+ title: 余白
cameraAnimation:
title: カメラアニメーション
fields:
diff --git a/web/src/beta/components/Popover/hooks.ts b/web/src/beta/components/Popover/hooks.ts
index 636faa9140..32ed62bb9c 100644
--- a/web/src/beta/components/Popover/hooks.ts
+++ b/web/src/beta/components/Popover/hooks.ts
@@ -18,6 +18,7 @@ export default function usePopover({
placement = "bottom",
modal,
offset: offsetProps,
+ shift: shiftProps,
open: controlledOpen,
onOpenChange: setControlledOpen,
}: PopoverOptions = {}) {
@@ -38,7 +39,7 @@ export default function usePopover({
fallbackAxisSideDirection: "end",
padding: 4,
}),
- shift({ padding: 4 }),
+ shift(shiftProps ?? { padding: 4 }),
],
});
diff --git a/web/src/beta/components/Popover/index.tsx b/web/src/beta/components/Popover/index.tsx
index 69fb42e48d..f3b58f22fd 100644
--- a/web/src/beta/components/Popover/index.tsx
+++ b/web/src/beta/components/Popover/index.tsx
@@ -4,7 +4,15 @@ import {
FloatingFocusManager,
useTransitionStyles,
} from "@floating-ui/react";
-import * as React from "react";
+import {
+ forwardRef,
+ isValidElement,
+ cloneElement,
+ MutableRefObject,
+ type ButtonHTMLAttributes,
+ type HTMLProps,
+ type ReactNode,
+} from "react";
import { PopoverContext, usePopoverContext } from "@reearth/beta/components/Popover/context";
import { useTheme } from "@reearth/services/theme";
@@ -18,7 +26,7 @@ export function Provider({
modal = false,
...restOptions
}: {
- children: React.ReactNode;
+ children: ReactNode;
} & PopoverOptions) {
const popover = usePopover({ modal, ...restOptions });
return {children};
@@ -26,19 +34,19 @@ export function Provider({
type TriggerProps = {
className?: string;
- children: React.ReactNode;
+ children: ReactNode;
asChild?: boolean;
};
-export const Trigger = React.forwardRef & TriggerProps>(
+export const Trigger = forwardRef & TriggerProps>(
function Trigger({ children, asChild = false, className, ...props }, propRef) {
const context = usePopoverContext();
const childrenRef = (children as any).ref;
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
// `asChild` allows the user to pass any element as the anchor
- if (asChild && React.isValidElement(children)) {
- return React.cloneElement(
+ if (asChild && isValidElement(children)) {
+ return cloneElement(
children,
context.getReferenceProps({
ref,
@@ -68,55 +76,53 @@ type ContentProps = {
attachToRoot?: boolean;
};
-export const Content = React.forwardRef<
- HTMLDivElement,
- React.HTMLProps & ContentProps
->(function Content({ style, className, attachToRoot = false, ...props }, propRef) {
- const { context: floatingContext, ...context } = usePopoverContext();
- const theme = useTheme();
- const ref = useMergeRefs([context.refs.setFloating, propRef]);
- const { isMounted, styles: transitionStyles } = useTransitionStyles(floatingContext, {
- duration: 50,
- });
+export const Content = forwardRef & ContentProps>(
+ function Content({ style, className, attachToRoot = false, ...props }, propRef) {
+ const { context: floatingContext, ...context } = usePopoverContext();
+ const theme = useTheme();
+ const ref = useMergeRefs([context.refs.setFloating, propRef]);
+ const { isMounted, styles: transitionStyles } = useTransitionStyles(floatingContext, {
+ duration: 50,
+ });
- if (!isMounted) return null;
+ if (!isMounted) return null;
- return (
- ) : null}>
-
-
- {props.children}
-
-
-
- );
-});
+ return (
+ ) : null}>
+
+
+ {props.children}
+
+
+
+ );
+ },
+);
-export const Close = React.forwardRef<
- HTMLButtonElement,
- React.ButtonHTMLAttributes
->(function PopoverClose(props, ref) {
- const { setOpen } = usePopoverContext();
- return (
-