-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(web): next page button story block (#846)
- Loading branch information
Showing
25 changed files
with
152 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
web/src/beta/lib/core/StoryPanel/Block/builtin/NextPage/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useCallback } from "react"; | ||
|
||
import Icon from "@reearth/beta/components/Icon"; | ||
import BlockWrapper from "@reearth/beta/lib/core/StoryPanel/Block/builtin/common/Wrapper"; | ||
import type { CommonProps as BlockProps } from "@reearth/beta/lib/core/StoryPanel/Block/types"; | ||
import { styled } from "@reearth/services/theme"; | ||
|
||
import { usePanelContext } from "../../../context"; | ||
|
||
const NextPage: React.FC<BlockProps> = ({ block, pageId, isSelected, ...props }) => { | ||
const { pageIds, onJumpToPage } = usePanelContext(); | ||
|
||
const handlePageChange = useCallback(() => { | ||
if (!pageId) return; | ||
const pageIndex = pageIds?.findIndex(id => id === pageId); | ||
if (pageIndex === undefined) return; | ||
onJumpToPage?.(pageIndex + 1); | ||
}, [pageId, pageIds, onJumpToPage]); | ||
|
||
return ( | ||
<BlockWrapper | ||
name={block?.name} | ||
icon={block?.extensionId} | ||
isSelected={isSelected} | ||
propertyId={block?.propertyId} | ||
property={block?.property} | ||
{...props}> | ||
<Wrapper> | ||
<Button onClick={handlePageChange}> | ||
<StyledIcon icon={block?.extensionId} size={16} /> | ||
</Button> | ||
</Wrapper> | ||
</BlockWrapper> | ||
); | ||
}; | ||
|
||
export default NextPage; | ||
|
||
const Wrapper = styled.div` | ||
display: flex; | ||
width: 100%; | ||
justify-content: center; | ||
`; | ||
|
||
const StyledIcon = styled(Icon)` | ||
transition: none; | ||
`; | ||
|
||
const Button = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 4px 12px; | ||
border: 1px solid #2c2c2c; | ||
border-radius: 6px; | ||
transition: none; | ||
cursor: pointer; | ||
:hover { | ||
background: #8d8d8d; | ||
border: 1px solid #8d8d8d; | ||
color: ${({ theme }) => theme.content.strong}; | ||
} | ||
`; |
2 changes: 1 addition & 1 deletion
2
web/src/beta/lib/core/StoryPanel/Block/builtin/Timeline/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.