Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Presentation Mode - Layout Updates (#186)
Browse files Browse the repository at this point in the history
* change presentation mode header language

* export breadcrumbLinkStyle

* shuffle Presentation mode components

* simple presentation mode beacon name header

* adding more robust PresentationItemHeader

* removing the header-like nav breadcrumbs from the CommentGroup

* forgot .map() key

* maybe fix cy-test=presentation-header-bar test?

* Updates to presentation mode tests and data selectors.

---------

Co-authored-by: James Bradford <[email protected]>
Co-authored-by: Courtney Carpenter <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent 4b84407 commit db2d4ab
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css } from '@emotion/react';
import type { AnnotationModel } from '@redeye/client/store';
import { useStore } from '@redeye/client/store';
import type { CommandSummaryProps } from '@redeye/client/views';
import { CommandRow, CommentBox, NavBreadcrumbs } from '@redeye/client/views';
import { CommandRow, CommentBox } from '@redeye/client/views';
import { CoreTokens, ThemeClasses, Flex } from '@redeye/ui-styles';
import type { Ref } from 'mobx-keystone';
import { observer } from 'mobx-react-lite';
Expand Down Expand Up @@ -33,12 +33,6 @@ export const CommentGroup = observer<CommentGroupProps>(
}) => {
const store = useStore();
const commandGroup = store.graphqlStore.commandGroups.get(commandGroupId);
const firstCommandId = commandGroup?.commandIds?.[0];
const firstCommand = firstCommandId && store.graphqlStore.commands.get(firstCommandId);

// `showPath === 'server'` in this case means show the header path for presentation mode
// TODO: what in case of Multi-Beacon Comment?
const showNavPath = !!(showPath === 'server' && firstCommand);

return (
<div
Expand Down Expand Up @@ -74,16 +68,6 @@ export const CommentGroup = observer<CommentGroupProps>(
)}
</Flex>
<Flex column>
{showNavPath && (
<NavBreadcrumbs
command={firstCommand}
hideRoot
css={css`
padding: 0.5rem 1.5rem;
font-size: ${CoreTokens.FontSizeMedium};
`}
/>
)}
{!hideCommands &&
commandGroup?.commandIds?.map((commandId) => (
<CommandRow
Expand All @@ -92,7 +76,7 @@ export const CommentGroup = observer<CommentGroupProps>(
css={{ borderBottom: 'none !important' }}
key={`${commandGroup?.id}${commandId}`}
hideCommentButton
showPath={!showNavPath && showPath}
showPath={showPath}
expandedCommandIDs={expandedCommandIDs}
removeExpandedCommandID={removeExpandedCommandID}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ export type BreadcrumbsStyledProps = {
muted?: boolean;
};

export const breadcrumbLinkStyle = ({ muted }: BreadcrumbsStyledProps) => css`
.${Classes.BREADCRUMB} {
display: inline;
font-size: inherit;
}
a.${Classes.BREADCRUMB} {
color: ${CoreTokens.TextMuted};
${!muted &&
css`
font-weight: ${CoreTokens.FontWeightBold};
color: ${CoreTokens.TextLink};
`};
&:hover {
text-decoration: underline;
}
}
.${Classes.BREADCRUMB_CURRENT} {
color: ${CoreTokens.TextMuted};
}
`;

export const BreadcrumbsStyled = styled(BreadcrumbsSimple)<BreadcrumbsStyledProps>`
/* ${UtilityStyles.textMeta} */
Expand Down Expand Up @@ -64,28 +88,7 @@ export const BreadcrumbsStyled = styled(BreadcrumbsSimple)<BreadcrumbsStyledProp
`}
}
.${Classes.BREADCRUMB} {
display: inline;
font-size: inherit;
}
a.${Classes.BREADCRUMB} {
color: ${CoreTokens.TextMuted};
${({ muted }) =>
!muted &&
css`
font-weight: ${CoreTokens.FontWeightBold};
color: ${CoreTokens.TextLink};
`};
&:hover {
text-decoration: underline;
}
}
.${Classes.BREADCRUMB_CURRENT} {
color: ${CoreTokens.TextMuted};
}
${({ muted }) => breadcrumbLinkStyle({ muted })}
.${Classes.OVERFLOW_LIST_SPACER} {
// this is used by OverflowList to measure and adjust layout...
Expand Down
114 changes: 55 additions & 59 deletions applications/client/src/views/Campaign/Presentation/Presentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RedEyeRoutes,
useStore,
} from '@redeye/client/store';
import { PresentationItem, PresentationNavBar, PresentationTopicItem, SlideSelector } from '@redeye/client/views';
import { PresentationItem, PresentationNavBar, PresentationTopicItem } from '@redeye/client/views';
import { Header, CoreTokens } from '@redeye/ui-styles';
import { useQuery } from '@tanstack/react-query';
import { observer } from 'mobx-react-lite';
Expand Down Expand Up @@ -54,72 +54,68 @@ const Presentation = observer<PresentationProps>(({ ...props }) => {
cy-test="presentation-root"
{...props}
css={css`
/* width: 100%; */
display: flex;
flex-direction: column;
overflow: hidden;
/* background-color: var(--dark-gray2); */
`}
>
<div
cy-test="presentation-header-bar"
css={css`
flex: 0 0 auto;
border-bottom: 1px solid ${CoreTokens.BorderNormal};
`}
>
{store.campaign.presentation.isPresenting ? (
<PresentationNavBar />
) : (
<Header
medium
css={css`
margin-bottom: 0;
margin: 0.75rem 1rem;
`}
>
Select a comment topic to present
</Header>
)}
</div>
<ScrollBox css={{ backgroundColor: CoreTokens.Background2 }}>
<ScrollChild css={{ padding: '1rem 0 4rem 0' }}>
<Routes>
<Route
path={`${RedEyeRoutes.CAMPAIGN_PRESENTATION_SELECTED}/*`}
element={
<>
<SlideSelector />
<PresentationItem
cy-test="presentation-item"
commandGroupId={
store.campaign.presentation.selectedItem?.commandGroups?.[store.campaign.presentation.index]?.id
}
/>
</>
}
/>
<Route
path="*"
element={
<>
{data?.presentationItems
?.filter(
(presentationItem) =>
presentationItem.id !== 'procedural' && presentationItem.id.slice(0, 5) !== 'user-'
)
.map((presentationItem) => (
<PresentationTopicItem key={presentationItem.id} presentationItem={presentationItem} />
))}
</>
}
/>
</Routes>
</ScrollChild>
</ScrollBox>
<Routes>
<Route
path={`${RedEyeRoutes.CAMPAIGN_PRESENTATION_SELECTED}/*`}
element={
<>
<PresentationNavBar />
<StyledScrollBox>
<PresentationItem
cy-test="presentation-item"
commandGroupId={
store.campaign.presentation.selectedItem?.commandGroups?.[store.campaign.presentation.index]?.id
}
/>
</StyledScrollBox>
</>
}
/>
<Route
path="*"
element={
<>
<Header
cy-test="presentation-header-bar"
medium
css={css`
margin-bottom: 0;
margin: 0.75rem 1rem;
`}
>
Present a Comment Topic
</Header>
<StyledScrollBox>
{data?.presentationItems
?.filter(
(presentationItem) =>
presentationItem.id !== 'procedural' && presentationItem.id.slice(0, 5) !== 'user-'
)
.map((presentationItem) => (
<PresentationTopicItem key={presentationItem.id} presentationItem={presentationItem} />
))}
</StyledScrollBox>
</>
}
/>
</Routes>
</div>
);
});

// eslint-disable-next-line import/no-default-export
export default Presentation;

const StyledScrollBox = ({ children, ...props }: ComponentProps<'div'>) => (
<ScrollBox
css={{ backgroundColor: CoreTokens.Background2, borderTop: `1px solid ${CoreTokens.BorderNormal}` }}
{...props}
>
<ScrollChild css={{ padding: '1rem 0 4rem 0' }}>{children}</ScrollChild>
</ScrollBox>
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { observable } from 'mobx';
import { observer } from 'mobx-react-lite';
import { useEffect } from 'react';
import type { ComponentProps } from 'react';
import { PresentationItemHeader } from './PresentationItemHeader';

type PresentationItemProps = ComponentProps<'div'> & {
commandGroupId?: string;
Expand Down Expand Up @@ -59,16 +60,19 @@ export const PresentationItem = observer<PresentationItemProps>(({ commandGroupI

if (!data?.commandGroup) return null;
return (
<CommentGroup
cy-test="presentation-item-root"
showPath="server"
commandGroupId={data.commandGroup.id}
toggleNewComment={state.toggleNewComment}
newComment={state.newComment}
expandedCommandIDs={state.expandedCommandIDs}
removeExpandedCommandID={state.removeExpandedCommandID}
css={{ border: 'unset' }}
{...props}
/>
<>
<PresentationItemHeader />
<CommentGroup
cy-test="presentation-item-root"
showPath="server"
commandGroupId={data.commandGroup.id}
toggleNewComment={state.toggleNewComment}
newComment={state.newComment}
expandedCommandIDs={state.expandedCommandIDs}
removeExpandedCommandID={state.removeExpandedCommandID}
css={{ border: 'unset' }}
{...props}
/>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { Tooltip } from '@blueprintjs/core';
import { dateTimeFormat, timeFormat } from '@redeye/client/components';
import { createState } from '@redeye/client/components/mobx-create-state';
import { useStore } from '@redeye/client/store';
import type { TxtProps } from '@redeye/ui-styles';
import { Header, Spacer, Txt } from '@redeye/ui-styles';
import { observer } from 'mobx-react-lite';
import type { ComponentProps } from 'react';

type PresentationItemHeaderProps = ComponentProps<'div'> & {};

export const PresentationItemHeader = observer<PresentationItemHeaderProps>(({}) => {
const store = useStore();

const state = createState({
get min() {
return store.settings.momentTz(store.campaign.presentation.currentSlide?.minDate);
},
get max() {
return store.settings.momentTz(store.campaign.presentation.currentSlide?.maxDate);
},
});

const beaconNames = store.campaign.presentation.currentSlide?.beacons.map((beacon) => beacon.computedName);

const hostNames = Array.from(
new Set(
store.campaign.presentation.currentSlide?.beacons
.map((beacon) => beacon.host?.current.computedName)
.filter((h) => h) as string[]
)
);

return (
<div css={{ padding: '2px 1rem' }}>
<Header withMargin css={{ display: 'flex', flexWrap: 'wrap' }}>
<Txt>
<PresentationHeaderPart names={hostNames} type="Host" />
</Txt>
<Spacer>/</Spacer>
<Txt normal>
<PresentationHeaderPart names={beaconNames} type="Beacon" />
</Txt>
</Header>
<Txt block monospace muted cy-test="slide-header">
{store.campaign.presentation.currentSlide?.minDate ? state.min.format(`ddd ${dateTimeFormat}`) : 'Unknown'}
{store.campaign.presentation.currentSlide?.commandIds?.length! > 1 && (
<>
<span> &mdash; </span>
{store.campaign.presentation.currentSlide?.maxDate
? state.max.format(state.max.dayOfYear() > state.min.dayOfYear() ? `ddd ${dateTimeFormat}` : timeFormat)
: 'Unknown'}
</>
)}
</Txt>
</div>
);
});

const PresentationHeaderPart = ({ names, type, ...props }: TxtProps & { names?: string[]; type: string }) => (
<>
{names == null ? (
<Txt disabled {...props}>
Unknown {type}
</Txt>
) : names.length === 1 ? (
<Txt {...props}>{names[0]}</Txt>
) : (
<Tooltip
placement="bottom-start"
interactionKind="hover"
content={
<ul css={{ margin: 0, padding: 0, listStyle: 'none' }}>
{names.map((name) => (
<li key={name}>{name}</li>
))}
</ul>
}
>
<Txt italic {...props}>
Multiple {type}s
</Txt>
</Tooltip>
)}
</>
);
Loading

0 comments on commit db2d4ab

Please sign in to comment.