-
Notifications
You must be signed in to change notification settings - Fork 2
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 #51 from GGO-web/player_trailer
Features: added tabs component, video trailer added for title screen
- Loading branch information
Showing
6 changed files
with
152 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { | ||
Tab, | ||
TabList, | ||
TabPanel, | ||
Tabs as AriaTabs, | ||
TabsProps | ||
} from 'react-aria-components'; | ||
import type { TabPanelProps, TabProps } from 'react-aria-components'; | ||
import React, { Key, useMemo, useState } from 'react'; | ||
|
||
export interface ITab { | ||
id: string; | ||
label: string; | ||
element: JSX.Element; | ||
} | ||
|
||
export interface ITabs extends TabsProps { | ||
tabs: ITab[]; | ||
} | ||
|
||
export const Tabs = ({ tabs, ...props }: ITabs) => { | ||
const [selectedKey, setSelectedKey] = useState<Key>(tabs[0].id); | ||
|
||
const selectedItem = useMemo(() => { | ||
return document.querySelector(`.tabpanel-${selectedKey as string}`); | ||
}, [selectedKey]); | ||
|
||
return ( | ||
<div className="flex justify-center"> | ||
<AriaTabs | ||
selectedKey={selectedKey} | ||
onSelectionChange={setSelectedKey} | ||
className="w-full tabs" | ||
{...props} | ||
> | ||
<TabList className="flex space-x-1 tabs__list"> | ||
{tabs.map(({ id, label }, index) => { | ||
return ( | ||
<MyTab | ||
key={id} | ||
id={id} | ||
style={{ marginLeft: index ? '-6px' : 0 }} | ||
> | ||
{label} | ||
</MyTab> | ||
); | ||
})} | ||
</TabList> | ||
|
||
<div | ||
className={`tabs__tabpanels flex aspect-video min-h-[${ | ||
selectedItem?.clientHeight || 0 | ||
}px] relative`} | ||
> | ||
{tabs.map(({ id, element }) => { | ||
return ( | ||
<MyTabPanel | ||
key={`tabpanel-${id}`} | ||
id={id} | ||
className={`tabpanel-${id}`} | ||
> | ||
{element} | ||
</MyTabPanel> | ||
); | ||
})} | ||
</div> | ||
</AriaTabs> | ||
</div> | ||
); | ||
}; | ||
|
||
function MyTab(props: TabProps) { | ||
return ( | ||
<Tab | ||
{...props} | ||
className={({ isSelected }) => ` | ||
tabs__item w-full max-w-[300px] py-2.5 text-center outline-none transition-colors font-bold cursor-pointer | ||
${ | ||
isSelected | ||
? 'rounded-tl-[6px] rounded-tr-[6px] text-white bg-[var(--color-red)] border-[1px] border-transparent' | ||
: 'rounded-tl-[6px] rounded-tr-[6px] text-white border-[1px] border-[var(--color-red)]' | ||
} | ||
`} | ||
/> | ||
); | ||
} | ||
|
||
function MyTabPanel({ className, ...props }: TabPanelProps) { | ||
return ( | ||
<TabPanel | ||
shouldForceMount={true} | ||
{...props} | ||
className={`mt-2 text-gray-700 rounded-2x tabpanel ${className}`} | ||
/> | ||
); | ||
} |
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,15 @@ | ||
import React from 'react'; | ||
import { FlexGroup } from '@components/FlexGroup/FlexGroup'; | ||
|
||
export const TrailerPlayer = () => { | ||
return ( | ||
<FlexGroup className="trailer-container"> | ||
<iframe | ||
className={'w-full aspect-video'} | ||
src="https://www.youtube.com/embed/i66VJnh-hYc" | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" | ||
allowFullScreen | ||
/> | ||
</FlexGroup> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
@import './components/breadcrumbs'; | ||
|
||
@import './components/slider.scss'; | ||
|
||
@import "./components/tabs.scss"; |
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,16 @@ | ||
.tabs { | ||
overflow: hidden; | ||
} | ||
|
||
.tabpanel { | ||
position: absolute; | ||
inset: 0; | ||
opacity: 1; | ||
translate: 0; | ||
transition: translate 0.2s ease-in-out, opacity 0.3s; | ||
} | ||
|
||
.tabpanel[data-inert="true"] { | ||
opacity: 0; | ||
translate: -100%; | ||
} |