-
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.
- Loading branch information
Showing
18 changed files
with
271 additions
and
60 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,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
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.