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 12 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
55 changes: 39 additions & 16 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,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { NotifTag } from '../../../../../../aries-site/src/layouts/content/NotifTag';

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

Expand All @@ -9,24 +10,46 @@ export const Identifier = ({
title,
subTitle,
size,
updates,
type,
beahackman marked this conversation as resolved.
Show resolved Hide resolved
...rest
}) => (
<Box align="center" {...rest}>
{children}
<Box>
{level ? (
<Heading level={level} margin="none">
{title}
</Heading>
) : (
<Text size={size} weight="bold" color="text-strong">
{title}
</Text>
)}
<Text size={size}>{subTitle}</Text>
}) => {
return (
beahackman marked this conversation as resolved.
Show resolved Hide resolved
beahackman marked this conversation as resolved.
Show resolved Hide resolved
<Box align="center" {...rest}>
<Box direction="row" justify="between" fill="horizontal">
{children}
{updates && type === 'Update' && (
beahackman marked this conversation as resolved.
Show resolved Hide resolved
<NotifTag
color="teal"
allyDes={`There's been updates for ${title}`}
textVal="Updated"
size="small"
/>
)}
{updates && type === 'New' && (
<NotifTag
color="purple"
allyDes={`There's a new item called ${title}`}
textVal="New!"
size="small"
/>
)}
</Box>
<Box direction="row" align="center" justify="center" gap="xsmall">
{level ? (
<Heading level={level} margin="none">
{title}
</Heading>
) : (
<Text size={size} weight="bold" color="text-strong">
{title}
</Text>
)}
<Text size={size}>{subTitle}</Text>
</Box>
</Box>
</Box>
);
);
};

Identifier.propTypes = {
children: PropTypes.node,
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
11 changes: 11 additions & 0 deletions aries-site/src/components/cards/ContentCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ import { Identifier } from 'aries-core';
import { PreviewImageCard } from './PreviewCard';
import { LinkCard } from './LinkCard';
import { useDarkMode } from '../../utils';
import pageVisitTracker from '../../utils/pageVisitTracker';

export const ContentCard = forwardRef(
({ level, topic, minimal, ...rest }, ref) => {
const { description, name, parent, preview, render } = topic;
const darkMode = useDarkMode();
const history = JSON.parse(window.localStorage.getItem('update-history'));
beahackman marked this conversation as resolved.
Show resolved Hide resolved
let newUpdate = false;
let type;
if (history && name in history) {
newUpdate = pageVisitTracker(name);
type = history[name].type;
}

return (
<LinkCard fill pad="medium" ref={ref} {...rest}>
<CardBody gap="large">
Expand Down Expand Up @@ -49,6 +58,8 @@ export const ContentCard = forwardRef(
align="start"
gap="xsmall"
level={level}
updates={newUpdate}
type={type}
beahackman marked this conversation as resolved.
Show resolved Hide resolved
>
{parent && parent.icon && !minimal && (
<Box direction="row" align="center" gap="xsmall">
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
33 changes: 32 additions & 1 deletion aries-site/src/layouts/content/InPageNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import { Box, Button, Nav, Text } from 'grommet';
import styled, { ThemeContext } from 'styled-components';
import { nameToSlug } from '../../utils';
import { StatusGoodSmall } from 'grommet-icons';
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 { wholeViewHistory } = useContext(ViewContext) || undefined;

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 newUpdate = false;

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

return (
<Link key={index} href={`#${nameToSlug(headingTitle)}`} passHref>
<SectionButton theme={theme} hoverIndicator>
Expand All @@ -123,10 +144,20 @@ 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>
{newUpdate && (
<Box justify="top">
beahackman marked this conversation as resolved.
Show resolved Hide resolved
<Text>
<StatusGoodSmall size="10px" color="#117B82" />
beahackman marked this conversation as resolved.
Show resolved Hide resolved
</Text>
</Box>
)}
</Box>
</Box>
</SectionButton>
Expand Down
18 changes: 18 additions & 0 deletions aries-site/src/layouts/content/NotifTag.js
beahackman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Tag } from 'grommet';

export const NotifTag = ({ size, color, allyDes, textVal }) => {
beahackman marked this conversation as resolved.
Show resolved Hide resolved
return (
<Tag
size={size}
border={{
color: 'border-weak',
size: 'xsmall',
style: 'solid',
side: 'all',
}}
background={{ dark: true, color: color }}
value={textVal}
beahackman marked this conversation as resolved.
Show resolved Hide resolved
a11yTitle={allyDes}
beahackman marked this conversation as resolved.
Show resolved Hide resolved
/>
);
};
58 changes: 58 additions & 0 deletions aries-site/src/layouts/content/UpdateNotification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Anchor, Text, Notification } from 'grommet';
import { CircleInformation } from 'grommet-icons';
import { ViewContext } from '../../pages/_app';
import { useContext } from 'react';

export const UpdateNotification = ({ name }) => {
const { wholeViewHistory } = useContext(ViewContext) || undefined;

function InlineNotif({ dateText, message }) {
beahackman marked this conversation as resolved.
Show resolved Hide resolved
return (
<Notification
width="large"
title={
dateText +
new Date(wholeViewHistory[name]?.date)
.toDateString()
.split(' ')
.slice(1)
.join(' ')
}
message={message}
margin={{ bottom: 'medium' }}
icon={<CircleInformation />}
/>
);
}

if (wholeViewHistory && name in wholeViewHistory) {
return (
<>
{wholeViewHistory[name]?.type === 'Update' && (
beahackman marked this conversation as resolved.
Show resolved Hide resolved
<InlineNotif
dateText="Updated "
message={
<Text>
{wholeViewHistory[name]?.description + ' '}
{wholeViewHistory[name]?.action?.length > 1 && (
<Anchor label="Link" href={wholeViewHistory[name]?.action} />
)}
</Text>
}
/>
)}
{wholeViewHistory[name]?.type === 'New' && (
<InlineNotif
dateText="Added on "
message={
<Text>
This item is new. Let the Design System team know if you have
any feedback.
</Text>
}
/>
)}
</>
);
}
};
17 changes: 16 additions & 1 deletion aries-site/src/layouts/main/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ import {
FeedbackButton,
Feedback,
Question,
components,
} from '../../components';
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 +130,14 @@ export const Layout = ({
{ id: 'main', label: 'Main Content' },
].filter(link => link !== undefined);

const { wholeViewHistory, pageUpdateReady, setPageUpdateReady } =
useContext(ViewContext) || undefined;

//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);
}, [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,10 @@ export const Layout = ({
topic={topic}
render={render}
/>
{pageUpdateReady &&
wholeViewHistory[title]?.update && (
<UpdateNotification name={title} />
)}
{children}
</ContentSection>
{relatedContent.length > 0 && (
Expand Down
42 changes: 36 additions & 6 deletions aries-site/src/layouts/navigation/SearchResult.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import PropTypes from 'prop-types';
import { Box, Paragraph, Text } from 'grommet';
import { Box, Paragraph, Text, Tag } from 'grommet';

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

import pageVisitTracker from '../../utils/pageVisitTracker';
import { NotifTag } from '../content/NotifTag';

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

const history = JSON.parse(window.localStorage.getItem('update-history'));
let newUpdate, type;
if (result.title in history) {
newUpdate = pageVisitTracker(result.title);
type = history[result.title].type;
} else {
newUpdate = false;
}

return (
<Box gap="xsmall" pad={{ vertical: 'xxsmall' }} width="large">
<>
Expand All @@ -20,11 +32,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>
{newUpdate && type === 'New' && (
<NotifTag
size="xsmall"
color="purple"
textVal="New!"
allyDes={`There's a new item called ${result.title}`}
/>
)}
{newUpdate && type === 'Update' && (
<NotifTag
size="xsmall"
color="teal"
textVal="Updated"
allyDes={`There's been updates for ${result.title}`}
/>
)}
</Box>
)}
</>
{result.matches?.length > 0 ? (
Expand Down
Loading
Loading