Skip to content

Commit

Permalink
DESENG 631: Add Engagement Description Block
Browse files Browse the repository at this point in the history
  • Loading branch information
NatSquared committed Jun 17, 2024
1 parent 8512584 commit cfbc168
Show file tree
Hide file tree
Showing 21 changed files with 260 additions and 179 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## June 17, 2024

- **Feature** Add engagement description to the engagement page [🎟️ DESENG-631](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-631)
- Display engagement description on the new engagement page
- Display first widget of the engagement beside the description
- Limit text editor to remove disruptive formatting options

## June 11, 2024

- **Feature** Add new header to "new look" engagement page [🎟️ DESENG-630](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-630)
Expand Down
42 changes: 30 additions & 12 deletions met-web/src/components/appLayouts/PublicLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,38 @@ import { FeedbackModal } from 'components/feedback/FeedbackModal';
import Footer from 'components/layout/Footer';
import DocumentTitle from 'DocumentTitle';
import ScrollToTop from 'components/scrollToTop';
import { WidthLimiter } from 'components/common/Layout';
import { Box } from '@mui/material';
import { colors } from 'components/common';

export const PublicLayout = () => {
return (
<WidthLimiter>
<DocumentTitle />
<PageViewTracker />
<Notification />
<NotificationModal />
<PublicHeader />
<ScrollToTop />
<Outlet />
<FeedbackModal />
<Footer />
</WidthLimiter>
<Box
sx={{
width: '100%',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'transparent',
padding: 0,
margin: 0,
}}
>
<Box
sx={{
maxWidth: '1926px',
margin: '0 auto',
background: colors.surface.white,
}}
>
<DocumentTitle />
<PageViewTracker />
<Notification />
<NotificationModal />
<PublicHeader />
<ScrollToTop />
<Outlet />
<FeedbackModal />
<Footer />
</Box>
</Box>
);
};
28 changes: 0 additions & 28 deletions met-web/src/components/common/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,5 @@ export const ResponsiveWrapper: React.FC = () => {
);
};

export const WidthLimiter: React.FC<BoxProps & { innerProps?: BoxProps }> = ({ children, innerProps, ...props }) => {
return (
<Box
sx={{
width: '100%',
alignItems: 'center',
justifyContent: 'center',
background: 'transparent',
padding: 0,
margin: 0,
...props.sx,
}}
{...props}
>
<Box
sx={{
maxWidth: '1920px',
margin: '0 auto',
...innerProps?.sx,
}}
{...innerProps}
>
{children}
</Box>
</Box>
);
};

export { Table, TableHead, TableHeadRow, TableHeadCell, TableBody, TableRow, TableCell, TableContainer } from './Table';
export { DetailsContainer, Detail } from './Details';
13 changes: 1 addition & 12 deletions met-web/src/components/common/RichTextEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,7 @@ const RichTextEditor = ({
error = false,
helperText = '',
toolbar = {
options: [
'inline',
'blockType',
'fontSize',
'list',
'colorPicker',
'link',
'embedded',
'emoji',
'image',
'history',
],
options: ['inline', 'list', 'link', 'history'],
inline: {
options: ['bold', 'italic', 'underline', 'superscript', 'subscript'],
},
Expand Down
13 changes: 12 additions & 1 deletion met-web/src/components/common/Typography/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { colors } from '../../common';

export const BodyText = ({
bold,
thin,
size = 'regular',
children,
...props
}: {
bold?: boolean;
thin?: boolean;
size?: 'small' | 'regular' | 'large';
children: React.ReactNode;
} & TypographyProps) => {
Expand All @@ -22,13 +24,22 @@ export const BodyText = ({
regular: '24px',
large: '24px',
}[size];
const fontWeight = () => {
if (bold) {
return 700;
}
if (thin) {
return 300;
}
return 400;
};
return (
<Typography
{...props}
sx={{
fontSize,
lineHeight,
fontWeight: bold ? 700 : 400,
fontWeight: fontWeight(),
color: colors.type.regular.primary,
...props.sx,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const EngagementForm = () => {
<Grid item xs={12}>
<TextField
title="Call to Action URL"
instructions="This where the main button on the engagement page will link to."
instructions="This is where the main button on the engagement page will link to."
id="call-to-action-url"
data-testid="engagement-form/call-to-action-url"
name="cta_url"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import TreeItem, { treeItemClasses, TreeItemProps } from '@mui/lab/TreeItem';
import { MetBodyOld } from 'components/common';
import { BodyText } from 'components/common/Typography';
import { If, Then, Else } from 'react-if';
import { Box } from '@mui/material';
import { IconProp } from '@fortawesome/fontawesome-svg-core';
Expand Down Expand Up @@ -87,7 +87,7 @@ export function StyledTreeItem(props: StyledTreeItemProps & DocumentTreeItemProp
{LabelIcon && (
<FontAwesomeIcon icon={LabelIcon} style={{ fontSize: '20px', paddingRight: '8px' }} />
)}
<MetBodyOld bold>{labelText}</MetBodyOld>
<BodyText bold>{labelText}</BodyText>
</Else>
</If>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const RichTextToolbarConfig = {
options: ['inline', 'fontSize', 'list'],
options: ['inline', 'list', 'history'],
inline: {
options: ['bold', 'italic', 'underline'],
options: ['bold', 'italic', 'underline', 'superscript', 'subscript'],
},
list: { options: ['unordered', 'ordered'] },
};
Expand Down
107 changes: 107 additions & 0 deletions met-web/src/components/engagement/new/view/EngagementDescription.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import React, { Suspense } from 'react';
import { BodyText, Header2 } from 'components/common/Typography';
import { Link } from 'components/common/Navigation';
import { Engagement } from 'models/engagement';
import { Grid, Skeleton } from '@mui/material';
import { colors } from 'components/common';
import { Await, useLoaderData, useParams } from 'react-router-dom';
import { Editor } from 'react-draft-wysiwyg';
import { getEditorStateFromRaw } from 'components/common/RichTextEditor/utils';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faArrowLeftLong } from '@fortawesome/pro-light-svg-icons';
import { Widget } from 'models/widget';
import { WidgetSwitch } from 'components/engagement/view/widgets/WidgetSwitch';

export const EngagementDescription = ({ engagement }: { engagement: Engagement }) => {
const { slug, language } = useParams();
const oldLink = `/${slug}/${language}`;

Check warning on line 17 in met-web/src/components/engagement/new/view/EngagementDescription.tsx

View workflow job for this annotation

GitHub Actions / linting (16.x)

'oldLink' is assigned a value but never used
const { widgets } = useLoaderData() as { widgets: Widget[] };
return (
<section id="cta-section">
<Grid
container
justifyContent="space-between"
sx={{
width: '100%',
margin: 0,
background: colors.surface.blue[90],
color: colors.surface.white,
borderRadius: '0px 24px 0px 0px' /* upper right corner */,
padding: { xs: '43px 16px 75px 16px', md: '32px 5vw 88px 5vw', lg: '32px 156px 88px 156px' },
marginTop: '-56px',
zIndex: 10,
position: 'relative',
flexDirection: { xs: 'column', md: 'row' },
}}
>
<Grid
item
sx={{
width: '100%',
display: 'flex',
flexDirection: 'row',
marginBottom: { xs: '24px', md: '48px' },
}}
>
<Grid item component={Link} to={'/'} alignItems="center" display="flex">
<FontAwesomeIcon
icon={faArrowLeftLong}
color={colors.surface.white}
fontSize={'24px'}
style={{ paddingRight: '8px' }}
/>
<BodyText thin size="small" sx={{ color: colors.surface.white }}>
All engagements
</BodyText>
</Grid>
</Grid>
<Grid
item
sx={{
width: { xs: '100%', md: '47.5%' },
display: 'flex',
flexDirection: 'column',
minHeight: '120px',
}}
>
<Header2 decorated weight="thin" sx={{ color: colors.surface.white }}>
Engagement Description
</Header2>
<BodyText
sx={{
color: colors.surface.white,
'& .rdw-link-decorator-icon': { display: 'none' },
'& a': {
color: colors.surface.white,
textDecoration: 'underline',
},
}}
>
<Editor
editorState={getEditorStateFromRaw(engagement.rich_description)}
readOnly={true}
toolbarHidden
/>
</BodyText>
</Grid>
<Grid
item
sx={{
width: { xs: '100%', md: '47.5%' },
display: 'flex',
minHeight: '360px',
}}
>
<Suspense fallback={<Skeleton variant="rectangular" sx={{ width: '100%', height: '360px' }} />}>
<Await resolve={widgets}>
{(resolvedWidgets: Widget[]) => {
const widget = resolvedWidgets?.[0];
return widget && <WidgetSwitch widget={widget} />;
}}
</Await>
</Suspense>
</Grid>
</Grid>
</section>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const EngagementHero = ({ engagement }: { engagement: Engagement }) => {
<Button
href={engagement.cta_url || '#cta-section'}
variant="primary"
size="large"
icon={<FontAwesomeIcon fontSize={24} icon={faChevronRight} />}
iconPosition="right"
sx={{ borderRadius: '8px' }}
Expand Down
11 changes: 11 additions & 0 deletions met-web/src/components/engagement/new/view/EngagementLoader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Navigate, Params, Route, defer } from 'react-router-dom';

Check warning on line 1 in met-web/src/components/engagement/new/view/EngagementLoader.tsx

View workflow job for this annotation

GitHub Actions / linting (16.x)

'Navigate' is defined but never used

Check warning on line 1 in met-web/src/components/engagement/new/view/EngagementLoader.tsx

View workflow job for this annotation

GitHub Actions / linting (16.x)

'Route' is defined but never used
import { getEngagement } from 'services/engagementService';
import { getEngagementIdBySlug } from 'services/engagementSlugService';
import { getWidgets } from 'services/widgetService';

export const engagementLoader = async ({ params }: { params: Params<string> }) => {
const { slug } = params;
const engagement = getEngagementIdBySlug(slug ?? '').then((response) => getEngagement(response.engagement_id));
const widgets = engagement.then((response) => getWidgets(response.id));
return defer({ engagement, slug, widgets });
};
Loading

0 comments on commit cfbc168

Please sign in to comment.