Skip to content

Commit

Permalink
Add attendees section in daily standup
Browse files Browse the repository at this point in the history
- Move deadlines section to second page in daily standup
- Use screen from SizeContext
  • Loading branch information
tnagorra committed Sep 6, 2024
1 parent ab7f44a commit e882d5b
Show file tree
Hide file tree
Showing 12 changed files with 396 additions and 181 deletions.
10 changes: 5 additions & 5 deletions src/components/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Page(props: Props) {
onSwipeRight,
} = props;

const { width } = useContext(SizeContext);
const { screen } = useContext(SizeContext);

const [storedConfig, setStoredConfig] = useLocalStorage('timur-config');

Expand Down Expand Up @@ -117,11 +117,11 @@ function Page(props: Props) {
!startSidebarShown && styles.startSidebarCollapsed,
debouncedStartSidebarCollapsed && styles.debouncedStartSidebarCollapsed,
debouncedEndSidebarCollapsed && styles.debouncedEndSidebarCollapsed,
(!endSidebarShown || width <= 900) && styles.endSidebarCollapsed,
(!endSidebarShown || screen === 'mobile') && styles.endSidebarCollapsed,
startSidebarShown && !!startAsideContent && styles.startSidebarVisible,
endSidebarShown
&& !!endAsideContent
&& width > 900
&& screen === 'desktop'
&& styles.endSidebarVisible,
className,
)}
Expand Down Expand Up @@ -160,7 +160,7 @@ function Page(props: Props) {
{children}
</div>
</main>
{endAsideContent && width > 900 && (
{endAsideContent && screen === 'desktop' && (
<Portal container={endActionsRef}>
<Button
name={!endSidebarShown}
Expand All @@ -172,7 +172,7 @@ function Page(props: Props) {
</Button>
</Portal>
)}
{endAsideContent && width > 900 && (
{endAsideContent && screen === 'desktop' && (
<aside className={_cs(styles.endAside, endAsideContainerClassName)}>
{endAsideContent}
</aside>
Expand Down
4 changes: 4 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ export function isCallable<T, X extends Func>(value: T | X): value is X {
export interface Size {
width: number;
height: number;
screen: 'desktop' | 'mobile';
}
export function getWindowSize(): Size {
return {
width: window.innerWidth,
height: window.innerHeight,
screen: window.innerWidth >= 900
? 'desktop'
: 'mobile',
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/views/DailyJournal/DayView/WorkItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function WorkItemRow(props: Props) {
} = props;

const { enums } = useContext(EnumsContext);
const { width: windowWidth } = useContext(SizeContext);
const { screen } = useContext(SizeContext);

const inputRef = useFocusClient<HTMLTextAreaElement>(workItem.clientId);
const [config] = useLocalStorage('timur-config');
Expand Down Expand Up @@ -217,7 +217,7 @@ function WorkItemRow(props: Props) {
icons={(
config.showInputIcons
// NOTE: hide/unhide icon wrt "checkbox for status" flag
&& (windowWidth < 900 || !config.checkboxForStatus)
&& (screen === 'mobile' || !config.checkboxForStatus)
&& <FcPackage />
)}
/>
Expand All @@ -234,7 +234,7 @@ function WorkItemRow(props: Props) {
icons={(
config.showInputIcons
// NOTE: hide/unhide icon wrt "checkbox for status" flag
&& (windowWidth >= 900 || !config.checkboxForStatus)
&& (screen === 'desktop' || !config.checkboxForStatus)
&& <FcDocument />
)}
placeholder="Description"
Expand Down Expand Up @@ -352,7 +352,7 @@ function WorkItemRow(props: Props) {
className,
)}
>
{windowWidth >= 900 ? (
{screen === 'desktop' ? (
<>
{statusInput}
{taskInput}
Expand Down
8 changes: 4 additions & 4 deletions src/views/DailyJournal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export function Component() {
);

const { midActionsRef } = useContext(NavbarContext);
const { width: windowWidth } = useContext(SizeContext);
const { screen } = useContext(SizeContext);

const handleSwipeLeft = useCallback(
() => {
Expand Down Expand Up @@ -631,7 +631,7 @@ export function Component() {
</div>
<Portal container={midActionsRef}>
<div className={styles.dateNavigation}>
{windowWidth >= 900 && (
{screen === 'desktop' && (
<>
<Link
to="dailyJournal"
Expand Down Expand Up @@ -673,7 +673,7 @@ export function Component() {
fallback={<IoStorefrontOutline />}
/>
</Button>
{windowWidth >= 900 && (
{screen === 'desktop' && (
<Button
name={undefined}
onClick={handleNoteUpdateClick}
Expand All @@ -683,7 +683,7 @@ export function Component() {
<IoNewspaperOutline />
</Button>
)}
{windowWidth >= 900 && (
{screen === 'desktop' && (
<Button
title="Show shortcuts"
name={undefined}
Expand Down
162 changes: 162 additions & 0 deletions src/views/DailyStandup/DeadlineSection/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import {
Fragment,
useMemo,
} from 'react';
import {
FcLandscape,
FcLeave,
FcNews,
FcNightLandscape,
FcSportsMode,
} from 'react-icons/fc';
import {
compareDate,
getDifferenceInDays,
} from '@togglecorp/fujs';
import {
gql,
useQuery,
} from 'urql';

import {
type DeadlinesAndEventsQuery,
type DeadlinesAndEventsQueryVariables,
} from '#generated/types/graphql';
import { type GeneralEvent } from '#utils/types';

import GeneralEventOutput from '../GeneralEvent';
import Slide from '../Slide';

import styles from './styles.module.css';

const dateFormatter = new Intl.DateTimeFormat(
[],
{
year: 'numeric',
month: 'short',
day: 'numeric',
weekday: 'short',
},
);

const DEADLINES_AND_EVENTS = gql`
query DeadlinesAndEvents {
private {
id
allProjects {
id
name
deadlines {
id
name
remainingDays
endDate
totalDays
usedDays
projectId
}
}
relativeEvents {
id
name
startDate
typeDisplay
dates
endDate
type
}
}
}
`;

interface Props {
date: string;
}

function DeadlineSection(props: Props) {
const {
date,
} = props;

const [deadlinesAndEvents] = useQuery<
DeadlinesAndEventsQuery,
DeadlinesAndEventsQueryVariables
>({
query: DEADLINES_AND_EVENTS,
});

const projects = deadlinesAndEvents.data?.private.allProjects;
const events = deadlinesAndEvents.data?.private.relativeEvents;

const formattedDate = dateFormatter.format(new Date(date));

const upcomingEvents = useMemo<GeneralEvent[]>(() => {
const deadlines = projects?.flatMap(
(project) => project.deadlines.map((deadline) => ({
...deadline,
name: `${project.name}: ${deadline.name}`,
})),
);

const iconsMap: Record<GeneralEvent['type'], React.ReactNode> = {
DEADLINE: <FcLeave />,
HOLIDAY: <FcLandscape />,
RETREAT: <FcNightLandscape />,
MISC: <FcNews />,
};

return [
...(deadlines?.map((deadline) => ({
key: `DEADLINE-${deadline.id}`,
type: 'DEADLINE' as const,
typeDisplay: 'Deadline',
icon: iconsMap.DEADLINE,
name: deadline.name,
date: deadline.endDate,
remainingDays: deadline.remainingDays,
})) ?? []),
...(events?.map((otherEvent) => ({
key: `${otherEvent.type}-${otherEvent.id}`,
type: otherEvent.type,
icon: iconsMap[otherEvent.type],
typeDisplay: otherEvent.typeDisplay,
name: otherEvent.name,
date: otherEvent.startDate,
remainingDays: getDifferenceInDays(
otherEvent.startDate,
date,
),
})) ?? []),
].sort((a, b) => compareDate(a.date, b.date));
}, [events, projects, date]);

return (
<Slide
variant="split"
primaryPreText="Welcome to"
primaryHeading="Daily Standup"
primaryDescription={formattedDate}
secondaryHeading="Upcoming Events"
secondaryContent={upcomingEvents.map(
(generalEvent, index) => (
<Fragment key={generalEvent.key}>
<GeneralEventOutput
generalEvent={generalEvent}
/>
{generalEvent.remainingDays < 0
&& upcomingEvents[index + 1]?.remainingDays >= 0
&& (
<div className={styles.separator}>
<div className={styles.line} />
<FcSportsMode className={styles.icon} />
<div className={styles.line} />
</div>
)}
</Fragment>
),
)}
/>
);
}

export default DeadlineSection;
30 changes: 30 additions & 0 deletions src/views/DailyStandup/DeadlineSection/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.separator {
display: flex;
align-items: center;
gap: var(--spacing-sm);
padding: 0 var(--spacing-lg);

.icon {
animation: run var(--duration-animation-fast) ease-in-out infinite;
font-size: var(--font-size-xl);
}

.line {
flex-grow: 1;
border-bottom: var(--width-separator-sm) solid var(--color-separator);
}
}

@keyframes run {
0% {
transform: rotate(0);
}

30% {
transform: rotate(5deg) translateY(2px);
}
70% {
transform: rotate(-4deg) translateX(-2px);
}
}

2 changes: 1 addition & 1 deletion src/views/DailyStandup/Slide/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styles from './styles.module.css';
interface SplitVariantProps {
variant: 'split';
primaryPreText?: React.ReactNode;
primaryHeading: React.ReactNode;
primaryHeading?: React.ReactNode;
primaryDescription?: React.ReactNode;
secondaryHeading: React.ReactNode;
secondaryContent: React.ReactNode;
Expand Down
Loading

0 comments on commit e882d5b

Please sign in to comment.