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

fix(skeleton): Changing the skeleton type #316

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
56 changes: 24 additions & 32 deletions components/roadmap-grid/RoadmapDetailedView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Spinner, Stack, Skeleton } from '@chakra-ui/react';
import { Box, Spinner, Skeleton } from '@chakra-ui/react';
import { useHookstate } from '@hookstate/core';
import type { Dayjs } from 'dayjs';
import _ from 'lodash';
Expand Down Expand Up @@ -139,19 +139,6 @@ export function RoadmapDetailed({
return <Spinner />;
}

// return early while loading.
if (globalLoadingState.get()) {
return (
<Stack pt={"20px"}>
<Skeleton height='60px' />
<Skeleton height='150px' />
<Skeleton height='150px' />
<Skeleton height='150px' />
<Skeleton height='150px' />
</Stack>
)
}

/**
* Current getTicks function returns 1 less than the number of ticks we want.
*/
Expand All @@ -164,24 +151,29 @@ export function RoadmapDetailed({
{isDevMode && <NumSlider msg="how many grid columns" value={numGridCols} min={20} max={60} step={numHeaderTicks} setValue={setNumGridCols} />}

<Box className={`${styles.timelineBox} ${viewMode == 'detail' ? styles.detailView : ''}`} >
<Grid ticksLength={numGridCols}>
{ticksHeader.map((tick, index) => (

<GridHeader key={index} tick={tick} index={index} numHeaderTicks={numHeaderTicks} numGridCols={numGridCols} />
))}

<Headerline numGridCols={numGridCols} ticksRatio={3} />
</Grid>
<Grid ticksLength={numGridCols} scroll={true} renderTodayLine={showTodayMarker} >
{issuesGroupedState.map((group, index) => (
<ErrorBoundary key={`Fragment-${index}`} >
<GroupHeader group={group} key={`GroupHeader-${index}`} issueDataState={issueDataState} /><GroupWrapper key={`GroupWrapper-${index}`}>
{group.ornull != null && group.items.ornull != null &&
_.sortBy(group.items.ornull, ['title']).map((item, index) => <GridRow key={index} milestone={item} index={index} timelineTicks={ticks} numGridCols={numGridCols} numHeaderItems={numHeaderTicks} issueDataState={issueDataState} />)}
</GroupWrapper>
</ErrorBoundary>
))}
</Grid>
<Skeleton isLoaded={!globalLoadingState.get()} >
<Grid ticksLength={numGridCols}>

{ticksHeader.map((tick, index) => (

<GridHeader key={index} tick={tick} index={index} numHeaderTicks={numHeaderTicks} numGridCols={numGridCols} />
))}

<Headerline numGridCols={numGridCols} ticksRatio={3} />
</Grid>
</Skeleton>
<Skeleton isLoaded={!globalLoadingState.get()} mt={8}>
<Grid ticksLength={numGridCols} scroll={true} renderTodayLine={showTodayMarker} >
{issuesGroupedState.map((group, index) => (
<ErrorBoundary key={`Fragment-${index}`} >
<GroupHeader group={group} key={`GroupHeader-${index}`} issueDataState={issueDataState} /><GroupWrapper key={`GroupWrapper-${index}`}>
{group.ornull != null && group.items.ornull != null &&
_.sortBy(group.items.ornull, ['title']).map((item, index) => <GridRow key={index} milestone={item} index={index} timelineTicks={ticks} numGridCols={numGridCols} numHeaderItems={numHeaderTicks} issueDataState={issueDataState} />)}
</GroupWrapper>
</ErrorBoundary>
))}
</Grid>
</Skeleton>
</Box>
</>
);
Expand Down
23 changes: 9 additions & 14 deletions components/roadmap-grid/RoadmapTabbedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Center,
Flex,
Link,
Skeleton,
Tab,
TabList,
TabPanel,
Expand All @@ -25,12 +24,10 @@ import { IssueDataViewInput } from '../../lib/types';
import Header from './header';
import styles from './Roadmap.module.css';
import { RoadmapDetailed } from './RoadmapDetailedView';
import { useGlobalLoadingState } from '../../hooks/useGlobalLoadingState';

export function RoadmapTabbedView({
issueDataState,
}: IssueDataViewInput): ReactElement {
const globalLoadingState = useGlobalLoadingState();
const viewMode = useViewMode() || DEFAULT_INITIAL_VIEW_MODE;
const router = useRouter();

Expand Down Expand Up @@ -66,17 +63,15 @@ export function RoadmapTabbedView({
}

return (
<Skeleton isLoaded={!globalLoadingState.get()}>
<Tab
className={styles.gridViewTab}
key={index}
>
<Center>
<TabIcon />
<Link href={'#' + tabViewMap[title]} className={styles.noDecoration}>{title}</Link>
</Center>
</Tab>
</Skeleton>
<Tab
className={styles.gridViewTab}
key={index}
>
<Center>
<TabIcon />
<Link href={'#' + tabViewMap[title]} className={styles.noDecoration}>{title}</Link>
</Center>
</Tab>
)
};

Expand Down
21 changes: 8 additions & 13 deletions components/roadmap-grid/today-marker-toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import { Button, Skeleton, Text } from '@chakra-ui/react';
import { Button, Text } from '@chakra-ui/react';
import React from 'react';
import SvgEyeClosedIcon from '../icons/svgr/SvgEyeClosedIcon';
import SvgEyeOpenIcon from '../icons/svgr/SvgEyeOpenIcon';

import { setShowTodayMarker, useShowTodayMarker } from '../../hooks/useShowTodayMarker';


import { useGlobalLoadingState } from '../../hooks/useGlobalLoadingState';
import styles from './today-marker.module.css';

export function TodayMarkerToggle() {
const showTodayMarker = useShowTodayMarker();
const globalLoadingState = useGlobalLoadingState();

return (
<Skeleton isLoaded={!globalLoadingState.get()}>
<Button
className={showTodayMarker ? styles.todayMarkerToggle : styles.todayMarkerToggleDisabled}
onClick={() => setShowTodayMarker(!showTodayMarker)}
>
{ showTodayMarker ? <SvgEyeOpenIcon /> : <SvgEyeClosedIcon /> }
<Text fontSize={"16px"} pl={'4px'} fontWeight={500}>Today</Text>
</Button>
</Skeleton>
<Button
className={showTodayMarker ? styles.todayMarkerToggle : styles.todayMarkerToggleDisabled}
onClick={() => setShowTodayMarker(!showTodayMarker)}
>
{ showTodayMarker ? <SvgEyeOpenIcon /> : <SvgEyeClosedIcon /> }
<Text fontSize={"16px"} pl={'4px'} fontWeight={500}>Today</Text>
</Button>
);
}