Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #387

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 37 additions & 41 deletions components/nav/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"use client"
'use client'
import {Box, Button, Center, Flex, HStack, useMediaQuery} from '@chakra-ui/react'
import {produce} from 'immer'
import {produce} from 'immer'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import {usePathname} from 'next/navigation'
import React from 'react'
import {useContext} from 'react'
import League, {SeasonPortion} from '../../classes/custom/League'
import { PlayerScores, SleeperPlayerDetails } from '../../classes/custom/Player'
import {DatabasePlayer, PlayerScores, SleeperPlayerDetails} from '../../classes/custom/Player'
import {LeagueContext} from '../../contexts/LeagueContext'
import { PlayerDetailsContext } from '../../contexts/PlayerDetailsContext'
import { PlayerScoresContext } from '../../contexts/PlayerScoresContext'
import { project_colors } from '../../utility/project_colors'
import {PlayerDetailsContext} from '../../contexts/PlayerDetailsContext'
import {PlayerScoresContext} from '../../contexts/PlayerScoresContext'
import {project_colors} from '../../utility/project_colors'
import ExpandableLeagueSearch from '../forms/ExpandableLeagueSearch'
import MobileSidebar from './MobileSidebar'
import SeasonPortionSelector from './SeasonPortionSelector'
Expand All @@ -23,32 +23,32 @@ interface MyProps {

const Navbar = (props: MyProps) => {
const [context, setContext] = useContext(LeagueContext)
const [playerScores, setPlayerScores] = useContext(PlayerScoresContext) as [Map<string, PlayerScores>, any];
const [playerDetails, setPlayerDetails] = useContext(PlayerDetailsContext) as [Map<string, SleeperPlayerDetails>, any];
const [playerScores, setPlayerScores] = useContext(PlayerScoresContext) as [Map<string, PlayerScores>, any]
const [playerDetails, setPlayerDetails] = useContext(PlayerDetailsContext) as [
Map<string, DatabasePlayer>,
any
]

// function setSeasonPortion(selected: String) {

// const nextState = produce(context, (draftState: League) => {
// draftState.setSeasonPortion(playerScores, playerDetails, selected as SeasonPortion)
// })
// setContext(nextState)
// }
function setSeasonPortion(selected: String) {
const nextState = produce(context, (draftState: League) => {
draftState.setSeasonPortion(playerScores, playerDetails, selected as SeasonPortion)
})
setContext(nextState)
}
return (
<Flex
bg={'secondary.600'}
bgGradient='linear(to-r, surface.1, surface.0)'
maxWidth={'100vw'}
color={'white'}
>
color={'white'}>
<HStack
spacing='0px'
pl={3}
paddingY={1}
flex={1}
display={{sm: 'none', base: 'flex'}}
maxWidth={'100vw'}
overflow='hidden'
>
overflow='hidden'>
<MobileSidebar />
<NavbarButton
buttonText='VisuaLeague'
Expand All @@ -65,8 +65,7 @@ const Navbar = (props: MyProps) => {
spacing='0px'
display={{sm: 'flex', base: 'none'}}
maxWidth={'100vw'}
overflow='hidden'
>
overflow='hidden'>
<NavbarButton
buttonText='League'
disabled={context.settings == undefined}
Expand Down Expand Up @@ -97,8 +96,12 @@ const Navbar = (props: MyProps) => {
<ExpandableLeagueSearch />
</Box>
</HStack>
{/* <SeasonPortionSelector onclick={setSeasonPortion} /> */}
<Center pr={3} my={2}>{context?.settings && <SettingsSidebar leagueSettings={context?.settings} />}</Center>
<Center pr={3} my={2}>
<SeasonPortionSelector onclick={setSeasonPortion} />
</Center>
<Center pr={3} my={2}>
{context?.settings && <SettingsSidebar leagueSettings={context?.settings} />}
</Center>
</Flex>
)
}
Expand All @@ -111,13 +114,12 @@ interface NavButtonProps {
disabled?: boolean
onclick?: () => void
}
function NavbarButton(props: NavButtonProps) {;
const pathName = usePathname();
function NavbarButton(props: NavButtonProps) {
const pathName = usePathname()
const [isLargerThan800] = useMediaQuery('(min-width: 800px)')
if (props.link != undefined && props.disabled != true) {
return (
<Link href={props.link}
>
<Link href={props.link}>
<Button
transition={'all .2s ease'}
_hover={{
Expand All @@ -131,13 +133,10 @@ function NavbarButton(props: NavButtonProps) {;
borderRadius={0}
colorScheme={'primary'}
textColor='white'
isActive={pathName == "/" + props.link && isLargerThan800}
_active={
{ bg: project_colors.secondary[500]}
}
variant={"ghost"}
aria-label={props.buttonText}
>
isActive={pathName == '/' + props.link && isLargerThan800}
_active={{bg: project_colors.secondary[500]}}
variant={'ghost'}
aria-label={props.buttonText}>
{props.buttonText}
</Button>
</Link>
Expand All @@ -157,13 +156,10 @@ function NavbarButton(props: NavButtonProps) {;
fontWeight={'medium'}
colorScheme={'primary'}
textColor='white'
isActive={pathName?.includes("/" + props.link) && isLargerThan800}
_active={
{ bg: project_colors.secondary[500]}
}
isActive={pathName?.includes('/' + props.link) && isLargerThan800}
_active={{bg: project_colors.secondary[500]}}
variant='ghost'
aria-label={props.buttonText}
>
aria-label={props.buttonText}>
{props.buttonText}
</Button>
)
Expand Down
10 changes: 8 additions & 2 deletions components/nav/SeasonPortionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ export default function HorizontalPillSelector(props: MyProps) {

}, [context, context?.league_id, league_id, props])

function isVisible() {
if (context && context instanceof League) {
return (context.settings.settings.playoff_week_start! <= context.settings.settings.leg)
}

}



if (!(context instanceof League)) return <Box></Box>
return (
<Center textAlign={'center'} mx={[1, 2, 4]} visibility={(context as League | null)?.settings?.season_type == SeasonPortion.POST || (context as League | null)?.settings?.season_type == SeasonPortion.ALL ? "visible" : "hidden"}>
<Center textAlign={'center'} mx={[1, 2, 4]} visibility={isVisible() ? 'visible' : 'hidden'}>
<HStack
{...group}
bg={project_colors.secondary[800]}
Expand Down
106 changes: 59 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading