-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1629 from starknet-io/enhancement/update-homwpage…
…-videos Update how it works section
- Loading branch information
Showing
10 changed files
with
512 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Module dependencies | ||
*/ | ||
|
||
import { Box } from "@chakra-ui/react"; | ||
import { | ||
VideoSectionBlock as VideoSectionProps, | ||
ChapterInfo | ||
} from "@starknet-io/cms-data/src/pages"; | ||
|
||
import { CategoryTabs } from "@ui/CategoryTabs/CategoryTabs"; | ||
import { Heading } from "@ui/Typography/Heading"; | ||
import { Chapter, playlist } from "@ui/VideoPlayer/constants"; | ||
import { VideoPlayerWebsite } from "@ui/VideoPlayer/player-website/VideoPlayerWebsite"; | ||
import { useMemo, useState } from "react"; | ||
import { MarkdownBlock } from "./MarkdownBlock"; | ||
|
||
/** | ||
* `ChapterType` type. | ||
*/ | ||
|
||
type ChapterType = Chapter & ChapterInfo; | ||
|
||
/** | ||
* Export `VideoSectionBlock` component. | ||
*/ | ||
|
||
export default function VideoSectionBlock(props: VideoSectionProps) { | ||
const normalizedPlaylist = useMemo(() => { | ||
return playlist.map((chapter) => { | ||
const chapterInfo = props[chapter.id as keyof VideoSectionProps] as ChapterInfo; | ||
return ({ | ||
...chapter, | ||
...chapterInfo | ||
}) as ChapterType; | ||
}); | ||
}, [props, playlist]) | ||
|
||
const [currentChapter, setCurrentChapter] = useState<ChapterType>(normalizedPlaylist[0]); | ||
|
||
return ( | ||
<Box> | ||
<Heading | ||
color="heading-navy-fg" | ||
variant="h2" | ||
fontSize={"32px"} | ||
marginBottom={"24px"} | ||
> | ||
{currentChapter.title} | ||
</Heading> | ||
|
||
<VideoPlayerWebsite | ||
chapters={normalizedPlaylist} | ||
initialActiveChapter={normalizedPlaylist[0].id} | ||
onChapterChange={(id) => | ||
setCurrentChapter(normalizedPlaylist.find((p) => p.id === id) ?? normalizedPlaylist[0]) | ||
} | ||
playlistOnBottom | ||
/> | ||
|
||
<Box mt="md"> | ||
<CategoryTabs | ||
activeItemId={currentChapter.id} | ||
onTabClick={(id) => | ||
setCurrentChapter(normalizedPlaylist.find((p) => p.id === id) ?? normalizedPlaylist[0]) | ||
} | ||
items={normalizedPlaylist.map((p) => ({ | ||
id: p.id, | ||
label: p.subtitle, | ||
}))} | ||
/> | ||
|
||
<Box | ||
maxW="656px" | ||
marginInline="auto" | ||
marginTop={'32px'} | ||
> | ||
<MarkdownBlock body={currentChapter.content} /> | ||
</Box> | ||
</Box> | ||
</Box> | ||
); | ||
} |
71 changes: 71 additions & 0 deletions
71
workspaces/website/src/components/CategoryTabs/CategoryTabs.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,71 @@ | ||
|
||
/** | ||
* Module dependencies | ||
*/ | ||
|
||
import { Box, Flex } from "@chakra-ui/react"; | ||
import { Button } from "@ui/Button"; | ||
|
||
/** | ||
* Export `CategoryTabItem` type. | ||
*/ | ||
|
||
export type CategoryTabItem = { | ||
id: string; | ||
label: string; | ||
link?: string; | ||
}; | ||
|
||
/** | ||
* Export `CategoryTabProps` type. | ||
*/ | ||
|
||
export type CategoryTabsProps = { | ||
items: CategoryTabItem[]; | ||
activeItemId: string; | ||
onTabClick?: (id: string) => void; | ||
}; | ||
|
||
/** | ||
* Export `CategoryTabs` component. | ||
*/ | ||
|
||
export const CategoryTabs = ({ | ||
items, | ||
activeItemId, | ||
onTabClick, | ||
}: CategoryTabsProps) => { | ||
return ( | ||
<Box | ||
borderTopWidth="1px" | ||
borderBottomWidth="1px" | ||
borderColor="border.divider" | ||
width="100%" | ||
> | ||
<Flex | ||
as="ul" | ||
sx={{ overflowX: "auto" }} | ||
gap="24px" | ||
width="100%" | ||
padding={'0 24px'} | ||
> | ||
{items.map((item) => { | ||
return ( | ||
<Box> | ||
<Button | ||
as={item.link ? "a" : "button"} | ||
href={item.link} | ||
isActive={item.id === activeItemId} | ||
onClick={() => onTabClick?.(item.id)} | ||
variant="category" | ||
padding={'24px 12px'} | ||
> | ||
{item.label} | ||
</Button> | ||
</Box> | ||
); | ||
})} | ||
</Flex> | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.