diff --git a/web/src/beta/features/Editor/Tabs/Storytelling/StoryPageIndicator/index.stories.tsx b/web/src/beta/features/Editor/Tabs/Storytelling/StoryPageIndicator/index.stories.tsx new file mode 100644 index 0000000000..0ae165344b --- /dev/null +++ b/web/src/beta/features/Editor/Tabs/Storytelling/StoryPageIndicator/index.stories.tsx @@ -0,0 +1,19 @@ +import { Meta, StoryObj } from "@storybook/react"; + +import StoryPageIndicator from "."; + +const meta: Meta = { + component: StoryPageIndicator, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + currentPage: 3, + currentPageProgress: 33, + maxPage: 5, + }, +}; diff --git a/web/src/beta/features/Editor/Tabs/Storytelling/StoryPageIndicator/index.tsx b/web/src/beta/features/Editor/Tabs/Storytelling/StoryPageIndicator/index.tsx new file mode 100644 index 0000000000..b3a1c472f8 --- /dev/null +++ b/web/src/beta/features/Editor/Tabs/Storytelling/StoryPageIndicator/index.tsx @@ -0,0 +1,65 @@ +import { FC } from "react"; + +import { styled } from "@reearth/services/theme"; + +type Props = { + currentPage: number; + currentPageProgress: number; + maxPage: number; + onPageChange: (page: number) => void; +}; + +const StoryPageIndicator: FC = ({ + currentPage, + currentPageProgress, + maxPage, + onPageChange, +}) => { + return ( + + {[...Array(maxPage)].map((_, i) => { + const page = i + 1; + const isActive = currentPage >= page; + const isCurrentPage = page === currentPage; + const progress = isCurrentPage ? currentPageProgress : isActive ? 100 : 0; + return ( + onPageChange(page)} /> + ); + })} + + ); +}; + +export default StoryPageIndicator; + +const Wrapper = styled.div` + display: flex; +`; + +// TODO: fix colors/transitions including hover +const Indicator = styled.button<{ progress: number }>` + position: relative; + flex: 1; + height: 8px; + background-color: #c2deff; + transition: all 0.15s; + + :hover { + opacity: 0.8; + } + + :not(:first-child) { + border-left: 1px solid #ffffff; + } + + :after { + content: ""; + position: absolute; + top: 0; + bottom: 0; + left: 0; + width: ${({ progress }) => progress}%; + background-color: #3592ff; + transition: width 0.15s; + } +`; diff --git a/web/src/beta/features/Editor/Tabs/Storytelling/StoryPanel/index.tsx b/web/src/beta/features/Editor/Tabs/Storytelling/StoryPanel/index.tsx index a83ea5980c..5676f3ff00 100644 --- a/web/src/beta/features/Editor/Tabs/Storytelling/StoryPanel/index.tsx +++ b/web/src/beta/features/Editor/Tabs/Storytelling/StoryPanel/index.tsx @@ -1,18 +1,33 @@ import { FC } from "react"; +import StoryPageIndicator from "@reearth/beta/features/Editor/Tabs/Storytelling/StoryPageIndicator"; import { styled } from "@reearth/services/theme"; type Props = {}; -const StoryPanel: FC = () => { - return StoryPanel; +export const StoryPanel: FC = () => { + return ( + + console.log(page)} + /> + +
StoryPanel
+
+
+ ); }; export default StoryPanel; const Wrapper = styled.div` - box-sizing: border-box; width: 462px; - padding: 10px 24px; background-color: #f1f1f1; `; + +const Content = styled.div` + padding: 10px 24px; +`;