forked from chrisbenincasa/tunarr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix modal height calc and missing ref types
- Loading branch information
1 parent
a6197e0
commit c44347a
Showing
5 changed files
with
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,51 @@ | ||
import { Grid } from '@mui/material'; | ||
import { forwardRef } from 'react'; | ||
import { ForwardedRef, forwardRef } from 'react'; | ||
import useStore from '../store'; | ||
|
||
type TabPanelProps = { | ||
children?: React.ReactNode; | ||
index: number; | ||
value: number; | ||
ref?: any; // to do | ||
ref?: React.RefObject<HTMLDivElement>; | ||
}; | ||
|
||
const CustomTabPanel = forwardRef((props: TabPanelProps, ref: any) => { | ||
const { children, value, index, ...other } = props; | ||
const CustomTabPanel = forwardRef( | ||
(props: TabPanelProps, ref: ForwardedRef<HTMLDivElement>) => { | ||
const { children, value, index, ...other } = props; | ||
|
||
const viewType = useStore((state) => state.theme.programmingSelectorView); | ||
const viewType = useStore((state) => state.theme.programmingSelectorView); | ||
|
||
return ( | ||
<div | ||
role="tabpanel" | ||
hidden={value !== index} | ||
id={`simple-tabpanel-${index}`} | ||
aria-labelledby={`simple-tab-${index}`} | ||
key={value} | ||
{...other} | ||
> | ||
{value === index && children && ( | ||
<Grid | ||
container | ||
component={'div'} | ||
spacing={2} | ||
sx={{ | ||
display: viewType === 'grid' ? 'grid' : 'flex', | ||
gridTemplateColumns: | ||
viewType === 'grid' | ||
? 'repeat(auto-fill, minmax(160px, 1fr))' | ||
: 'none', | ||
justifyContent: viewType === 'grid' ? 'space-around' : 'normal', | ||
mt: 2, | ||
}} | ||
ref={ref} | ||
> | ||
{children} | ||
</Grid> | ||
)} | ||
</div> | ||
); | ||
}); | ||
return ( | ||
<div | ||
role="tabpanel" | ||
hidden={value !== index} | ||
id={`simple-tabpanel-${index}`} | ||
aria-labelledby={`simple-tab-${index}`} | ||
key={value} | ||
{...other} | ||
> | ||
{value === index && children && ( | ||
<Grid | ||
container | ||
component={'div'} | ||
spacing={2} | ||
sx={{ | ||
display: viewType === 'grid' ? 'grid' : 'flex', | ||
gridTemplateColumns: | ||
viewType === 'grid' | ||
? 'repeat(auto-fill, minmax(160px, 1fr))' | ||
: 'none', | ||
justifyContent: viewType === 'grid' ? 'space-around' : 'normal', | ||
mt: 2, | ||
}} | ||
ref={ref} | ||
> | ||
{children} | ||
</Grid> | ||
)} | ||
</div> | ||
); | ||
}, | ||
); | ||
|
||
export default CustomTabPanel; |
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