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

Guidance Update Feature #3502

Merged
merged 29 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9305778
initial commit
beahackman Jul 20, 2023
1ee06cb
inital commit 2
beahackman Jul 20, 2023
0249572
switching to PR method
beahackman Jul 24, 2023
b4446b8
added visitation tracking, search tags, and nav tags
beahackman Jul 27, 2023
e484cb1
fixed visitation tracking and revised sidebar nav
beahackman Aug 4, 2023
477915c
fixed page load bug and other small changes
beahackman Aug 9, 2023
02b02c0
fixed the conflict with the yarn file
beahackman Aug 9, 2023
1f0ff3d
revising update features
beahackman Aug 9, 2023
762d52b
editing and revising update feature
beahackman Aug 15, 2023
dc9566b
ran prettier and small changes
beahackman Aug 18, 2023
7cbc555
fixed yarn lock conflict
beahackman Aug 21, 2023
bf53395
fixed the rest of the yarn lock conflicts
beahackman Aug 21, 2023
9e32e49
fixed query name problem and abbreviated titles
beahackman Aug 21, 2023
6c3b176
next round of reviews and fixed search function to guidance bug
beahackman Aug 22, 2023
aaee83c
changed notification header variable in app.js
beahackman Aug 23, 2023
2585d08
cleaning up code readability
beahackman Aug 23, 2023
7573baf
cleaned up Identifier formatting
beahackman Aug 24, 2023
673dc02
revised variable names
beahackman Aug 29, 2023
6230335
updating yarn.lock
beahackman Aug 30, 2023
23a6599
revised for code readability
beahackman Aug 31, 2023
993476e
Merge branch 'master' into test2
beahackman Aug 31, 2023
0170ac6
fixed conflict and code readability revisions
beahackman Sep 1, 2023
9e36f5b
removing update-history in local storage
beahackman Sep 5, 2023
4645d9b
code readability fixes
beahackman Sep 7, 2023
4ea50c1
Update yarn.lock
taysea Sep 7, 2023
1e281b3
forgot to delete old local storage set
beahackman Sep 7, 2023
3265baf
Update aries-site/src/layouts/content/UpdateNotification.js
taysea Sep 7, 2023
09361b8
Fix linting errors
taysea Sep 8, 2023
402d3df
updating with master and fixing lint
beahackman Sep 8, 2023
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
3 changes: 1 addition & 2 deletions aries-core/src/js/components/core/Identifier/Identifier.js
jcfilben marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

import { Box, Heading, Text } from 'grommet';

export const Identifier = ({
Expand All @@ -13,7 +12,7 @@ export const Identifier = ({
}) => (
<Box align="center" {...rest}>
{children}
<Box>
<Box direction="row" align="center" justify="center" gap="xsmall">
{level ? (
<Heading level={level} margin="none">
{title}
Expand Down
2 changes: 1 addition & 1 deletion aries-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"main": "src/pages/index.js",
"private": true,
"dependencies": {
"aries-core": "*",
"@mdx-js/loader": "^2.3.0",
"@mdx-js/react": "^2.3.0",
"@next/mdx": "^13.4.4",
"aries-core": "*",
"next": "13.4.4",
"react-ga": "^2.7.0",
"react-syntax-highlighter": "^15.4.4",
Expand Down
46 changes: 42 additions & 4 deletions aries-site/src/components/cards/ContentCard.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import React, { forwardRef } from 'react';
import React, { forwardRef, useContext } from 'react';
import PropTypes from 'prop-types';
import { Box, CardBody, Image, Text } from 'grommet';
import { Identifier } from 'aries-core';
import { PreviewImageCard } from './PreviewCard';
import { LinkCard } from './LinkCard';
import { useDarkMode } from '../../utils';
import { pageVisitTracker } from '../../utils/pageVisitTracker';
import { NotificationTag } from '../../layouts/content/NotificationTag';
import { ViewContext } from '../../pages/_app';

export const ContentCard = forwardRef(
({ level, topic, minimal, ...rest }, ref) => {
const { description, name, parent, preview, render } = topic;
const darkMode = useDarkMode();

const { contentHistory } = useContext(ViewContext);
let showUpdate = false;
let changeKind;
if (contentHistory && name in contentHistory) {
// still run pageVisitTracker on it
showUpdate = pageVisitTracker(name, contentHistory);
changeKind = contentHistory[name].changeKind;
}

return (
<LinkCard fill pad="medium" ref={ref} {...rest}>
<CardBody gap="large">
Expand Down Expand Up @@ -51,9 +64,34 @@ export const ContentCard = forwardRef(
level={level}
>
{parent && parent.icon && !minimal && (
<Box direction="row" align="center" gap="xsmall">
{parent.icon('small', parent.color)}
<Text>{parent.name}</Text>
<Box
direction="row"
align="center"
fill="horizontal"
justify="between"
>
<Box gap="xsmall" direction="row" align="center">
{parent.icon('small', parent.color)}
<Text>{parent.name}</Text>
</Box>
{showUpdate && changeKind === 'Update' && (
<NotificationTag
backgroundColor="teal"
a11yTitle={`There have been updates for ${
render || name
}`}
value="Updated"
size="small"
/>
)}
{showUpdate && changeKind === 'New' && (
<NotificationTag
backgroundColor="purple"
a11yTitle={`There's a new item called ${render || name}`}
value="New!"
size="small"
/>
)}
</Box>
)}
</Identifier>
Expand Down
2 changes: 1 addition & 1 deletion aries-site/src/components/seo/Meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Meta = ({
const pageContent = 'products';
const csp = `default-src 'self' 'unsafe-eval';
style-src 'self' *.hpe.com/hfws-static/5/css/ 'unsafe-inline';
connect-src 'self' *.githubusercontent.com/grommet/hpe-design-system/ https://www.google-analytics.com https://www.github.com/grommet/ https://eyes.applitools.com *.hpe.com/hpe/api/ https://ca1.qualtrics.com/API/v3/surveys/ https://api.spacexdata.com/;
connect-src 'self' *.githubusercontent.com/grommet/hpe-design-system/ https://api.github.com/repos/grommet/hpe-design-system/pulls https://api.github.com/repos/grommet/hpe-design-system/commits https://www.google-analytics.com https://www.github.com/grommet/ https://eyes.applitools.com *.hpe.com/hpe/api/ https://ca1.qualtrics.com/API/v3/surveys/ https://api.spacexdata.com/;
media-src 'self' https://d3hq6blov2iije.cloudfront.net/media/;
img-src 'self' data: https://www.google-analytics.com https://images.unsplash.com/ http://s.gravatar.com/avatar/ *.hpe.com/hfws-static/5/ https://d3hq6blov2iije.cloudfront.net/images/textures/ https://d3hq6blov2iije.cloudfront.net/images/gradients/ https://d3hq6blov2iije.cloudfront.net/images/hpe-greenlake/;
script-src 'self' *.hpe.com https://www.google-analytics.com/analytics.js https://netlify-cdp-loader.netlify.app/netlify.js ${
Expand Down
37 changes: 36 additions & 1 deletion aries-site/src/layouts/content/InPageNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import Link from 'next/link';
import PropTypes from 'prop-types';
import { Box, Button, Nav, Text } from 'grommet';
import styled, { ThemeContext } from 'styled-components';
import { StatusGoodSmall } from 'grommet-icons';
import { nameToSlug } from '../../utils';
import { ViewContext } from '../../pages/_app';

const SectionButton = styled(Button)`
border-radius: 0 ${props => props.theme.global.edgeSize.xsmall}
Expand Down Expand Up @@ -44,7 +46,7 @@ const useActiveHeadingId = (headings, options) => {
return activeHeadingId;
};

export const InPageNavigation = ({ headings }) => {
export const InPageNavigation = ({ headings, title }) => {
const theme = useContext(ThemeContext);

let { large, medium } = theme.global.edgeSize;
Expand All @@ -61,6 +63,8 @@ export const InPageNavigation = ({ headings }) => {
// align "Jump to section" with page title at start
const marginTop = `${large + medium}px`;

const { pageUpdateReady, contentHistory } = useContext(ViewContext);

return (
<Box
pad={{ horizontal: 'xxsmall' }} // pad for keyboard focus
Expand Down Expand Up @@ -108,6 +112,23 @@ export const InPageNavigation = ({ headings }) => {
if (level.length > 3) subsectionPad = 'large';
else if (level.length === 3) subsectionPad = 'medium';

let sectionList;
let showUpdate = false;

if (
contentHistory &&
title in contentHistory &&
contentHistory[title].update &&
contentHistory[title].sections[0].length > 0
) {
sectionList = contentHistory[title].sections;
Object.values(sectionList).forEach(val => {
if (val.toLowerCase() === headingTitle.toLowerCase()) {
showUpdate = true;
}
});
}

return (
<Link key={index} href={`#${nameToSlug(headingTitle)}`} passHref>
<SectionButton theme={theme} hoverIndicator>
Expand All @@ -123,10 +144,23 @@ export const InPageNavigation = ({ headings }) => {
? undefined
: { left: theme.global.borderSize.small }
}
direction="row"
align="top"
gap="small"
>
<Text color="text-strong" size="small" weight="normal">
{headingTitle}
</Text>
{showUpdate && pageUpdateReady && (
<Box background={{ dark: true }} justify="top">
<StatusGoodSmall
a11yTitle="Section has been updated"
size="10px"
color="teal"
height="small"
/>
</Box>
)}
</Box>
</Box>
</SectionButton>
Expand All @@ -140,4 +174,5 @@ export const InPageNavigation = ({ headings }) => {

InPageNavigation.propTypes = {
headings: PropTypes.arrayOf(PropTypes.array),
title: PropTypes.string,
};
21 changes: 21 additions & 0 deletions aries-site/src/layouts/content/NotificationTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import PropTypes from 'prop-types';
import { Tag } from 'grommet';

export const NotificationTag = ({ backgroundColor, ...rest }) => {
return (
<Tag
border={{
color: 'border-weak',
size: 'xsmall',
style: 'solid',
side: 'all',
}}
background={{ dark: true, color: backgroundColor }}
{...rest}
/>
);
};

NotificationTag.propTypes = {
backgroundColor: PropTypes.string,
};
49 changes: 49 additions & 0 deletions aries-site/src/layouts/content/UpdateNotification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import PropTypes from 'prop-types';
import { Anchor, Text, Notification } from 'grommet';
import { useContext } from 'react';
import { ViewContext } from '../../pages/_app';

export const UpdateNotification = ({ name }) => {
const { contentHistory } = useContext(ViewContext);
const updateDate = contentHistory[name]?.date;

if (contentHistory && name in contentHistory) {
beahackman marked this conversation as resolved.
Show resolved Hide resolved
return (
<Notification
status="info"
margin={{ bottom: 'medium' }}
width="large"
message={
contentHistory[name]?.changeKind === 'Update' ? (
<Text>
{`${contentHistory[name]?.description} `}
{contentHistory[name]?.action?.length > 1 && (
<Anchor
label="Jump to section"
href={contentHistory[name]?.action}
/>
)}
</Text>
) : (
<Text>
This item is new. Let the Design System team know if you have any
feedback.
</Text>
)
}
title={`${
contentHistory[name]?.changeKind === 'Update'
? 'Updated '
: 'Added on '
}${Intl.DateTimeFormat(undefined, { dateStyle: 'long' }).format(
new Date(updateDate),
)}`}
/>
);
}
return null;
};

UpdateNotification.propTypes = {
name: PropTypes.string,
};
16 changes: 15 additions & 1 deletion aries-site/src/layouts/main/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import {
import { Config } from '../../../config';
import { getRelatedContent, getPageDetails } from '../../utils';
import { siteContents } from '../../data/search/contentForSearch';
import { UpdateNotification } from '../content/UpdateNotification';
import { ViewContext } from '../../pages/_app';

export const Layout = ({
backgroundImage,
Expand Down Expand Up @@ -127,6 +129,15 @@ export const Layout = ({
{ id: 'main', label: 'Main Content' },
].filter(link => link !== undefined);

const { contentHistory, pageUpdateReady, setPageUpdateReady } =
useContext(ViewContext);

// every time a new page loads, initalize ready
// state to false, until app.js declares otherwise
useEffect(() => {
beahackman marked this conversation as resolved.
Show resolved Hide resolved
setPageUpdateReady(false);
}, [setPageUpdateReady, title]);

return (
<>
{/* When a backgroundImage is present, the main page content becomes
Expand Down Expand Up @@ -164,7 +175,7 @@ export const Layout = ({
{showInPageNav ? (
<Box pad={{ left: 'large' }}>
<SkipLinkTarget id="toc" />
<InPageNavigation headings={headings} />
<InPageNavigation title={title} headings={headings} />
</Box>
) : undefined}
<Box
Expand All @@ -182,6 +193,9 @@ export const Layout = ({
topic={topic}
render={render}
/>
{pageUpdateReady && contentHistory[title]?.update && (
<UpdateNotification name={title} />
)}
{children}
</ContentSection>
{relatedContent.length > 0 && (
Expand Down
43 changes: 38 additions & 5 deletions aries-site/src/layouts/navigation/SearchResult.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import PropTypes from 'prop-types';
import { Box, Paragraph, Text } from 'grommet';

import { useContext } from 'react';
import { getPageDetails } from '../../utils';
import { HighlightPhrase } from '../../components';

import { pageVisitTracker } from '../../utils/pageVisitTracker';
import { NotificationTag } from '../content/NotificationTag';
import { ViewContext } from '../../pages/_app';

export const SearchResult = ({ query, result }) => {
const hub = result.url && result.url.split('/')[1];
const parent = getPageDetails(hub);

const { contentHistory } = useContext(ViewContext);
let showUpdate;
let changeKind;
if (result.title in contentHistory) {
showUpdate = pageVisitTracker(result.title, contentHistory);
changeKind = contentHistory[result.title].changeKind;
} else {
showUpdate = false;
}

return (
<Box gap="xsmall" pad={{ vertical: 'xxsmall' }} width="large">
<>
Expand All @@ -20,11 +35,29 @@ export const SearchResult = ({ query, result }) => {
</Box>
)}
{result.title && (
<Text size="large" color="text-strong">
<HighlightPhrase phrase={query} fade={false} size="large">
{result.title}
</HighlightPhrase>
</Text>
<Box direction="row" gap="medium" align="center">
<Text size="large" color="text-strong">
<HighlightPhrase phrase={query} fade={false} size="large">
{result.title}
</HighlightPhrase>
</Text>
{showUpdate && changeKind === 'New' && (
<NotificationTag
size="xsmall"
backgroundColor="purple"
value="New!"
a11yTitle={`There's a new item called ${result.title}`}
/>
)}
{showUpdate && changeKind === 'Update' && (
<NotificationTag
size="xsmall"
backgroundColor="teal"
value="Updated"
a11yTitle={`There have been updates for ${result.title}`}
/>
)}
</Box>
)}
</>
{result.matches?.length > 0 ? (
Expand Down
Loading
Loading