Skip to content

Commit

Permalink
Merge pull request #6 from jacoblogan/link-checker-update
Browse files Browse the repository at this point in the history
Link checker update
  • Loading branch information
jacoblogan authored Aug 23, 2023
2 parents de3ec1d + ec5447f commit 448d66a
Show file tree
Hide file tree
Showing 66 changed files with 3,565 additions and 527 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ nbproject
.project
.settings
.vs
.vscode
composer.lock
*.swp
*.swo
Expand Down
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.insertSpaces": true,
"editor.tabSize": 2,
"files.insertFinalNewline": true,
"typescript.tsdk": "node_modules/typescript/lib",
"[css]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[mdx]": {
"editor.wordWrap": "on"
}
}
13 changes: 11 additions & 2 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,16 @@
"remoteloggingconstraints",
"remotelogging",
"cloudwatchlogs",
"userids"
"userids",
"xmark",
"refreshable"
],
"flagWords": ["hte", "full-stack", "Full-stack", "Full-Stack", "sudo"]
"flagWords": ["hte", "full-stack", "Full-stack", "Full-Stack", "sudo"],
"patterns": [
{
"name": "youtube-embed-ids",
"pattern": "/embedId=\".*\" /"
}
],
"ignoreRegExpList": ["youtube-embed-ids"]
}
2 changes: 1 addition & 1 deletion customHttp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ customHeaders:
- key: 'X-Content-Type-Options'
value: 'nosniff'
- key: 'Content-Security-Policy'
value: "upgrade-insecure-requests; default-src 'none'; prefetch-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; frame-src 'self' https://www.youtube-nocookie.com https://aws.demdex.net https://dpm.demdex.net; connect-src 'self' *.shortbread.aws.dev https://amazonwebservices.d2.sc.omtrdc.net https://aws.demdex.net https://dpm.demdex.net https://cm.everesttech.net https://a0.awsstatic.com/ https://d2c.aws.amazon.com https://vs.aws.amazon.com https://*.algolia.net https://*.algolianet.com *.amazonaws.com https://aws.amazon.com/ https://d2c-alpha.dse.marketing.aws.a2z.com https://aws-mktg-csds-alpha.integ.amazon.com/ https://alpha.d2c.marketing.aws.dev/ https://aa0.awsstatic.com/; img-src 'self' https://img.shields.io https://amazonwebservices.d2.sc.omtrdc.net https://aws.demdex.net https://dpm.demdex.net https://cm.everesttech.net https://a0.awsstatic.com/ https://alpha.d2c.marketing.aws.dev/ https://aa0.awsstatic.com/; media-src 'self'; script-src 'self' https://a0.awsstatic.com/ https://aa0.awsstatic.com/ https://alpha.d2c.marketing.aws.dev/ https://d2c.aws.amazon.com/;"
value: "upgrade-insecure-requests; default-src 'none'; prefetch-src 'self'; style-src 'self' 'unsafe-inline' *.shortbread.aws.dev; font-src 'self'; frame-src 'self' https://www.youtube-nocookie.com https://aws.demdex.net https://dpm.demdex.net; connect-src 'self' *.shortbread.aws.dev https://amazonwebservices.d2.sc.omtrdc.net https://aws.demdex.net https://dpm.demdex.net https://cm.everesttech.net https://a0.awsstatic.com/ https://d2c.aws.amazon.com https://vs.aws.amazon.com https://*.algolia.net https://*.algolianet.com *.amazonaws.com https://aws.amazon.com/ https://d2c-alpha.dse.marketing.aws.a2z.com https://aws-mktg-csds-alpha.integ.amazon.com/ https://alpha.d2c.marketing.aws.dev/ https://aa0.awsstatic.com/; img-src 'self' https://img.shields.io https://amazonwebservices.d2.sc.omtrdc.net https://aws.demdex.net https://dpm.demdex.net https://cm.everesttech.net https://a0.awsstatic.com/ https://alpha.d2c.marketing.aws.dev/ https://aa0.awsstatic.com/; media-src 'self'; script-src 'self' *.shortbread.aws.dev https://a0.awsstatic.com/ https://aa0.awsstatic.com/ https://alpha.d2c.marketing.aws.dev/ https://d2c.aws.amazon.com/;"
# CSP also set in _document.tsx meta tag
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"@algolia/autocomplete-shared": "^1.5.6",
"@algolia/autocomplete-theme-classic": "^1.6.1",
"@algolia/client-search": "^4.13.0",
"@aws-amplify/amplify-cli-core": "^4.2.4",
"@aws-amplify/ui-components": "latest",
"@aws-amplify/amplify-cli-core": "^4.2.5",
"@aws-amplify/ui-react": "^5.1.1",
"@cloudscape-design/components": "^3.0.238",
"@cloudscape-design/global-styles": "^1.0.8",
Expand Down Expand Up @@ -137,7 +136,7 @@
"refresh": "yarn clean && yarn",
"test": "jest",
"dev": "next dev",
"spellcheck": "cspell \"src/**/*.mdx\"",
"spellcheck": "cspell \"src/**/*.mdx\" --no-progress" ,
"spellcheck-diff": "git diff --name-only --cached | awk \"/src.*\\.mdx/{print}\" | npx cspell --no-must-find-files --file-list stdin",
"build": "node tasks/generate-sitemap.mjs && next build && next export -o client/www/next-build && next-image-export-optimizer --exportFolderPath client/www/next-build",
"next-build": "next build",
Expand Down
3 changes: 0 additions & 3 deletions public/scripts/aws-ux-shortbread-v1-0-14.js

This file was deleted.

3 changes: 0 additions & 3 deletions public/scripts/shortbreadv2.js

This file was deleted.

18 changes: 18 additions & 0 deletions src/components/Accordion/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Icon } from '@aws-amplify/ui-react';
import { MdHighlightAlt, MdExpandMore } from 'react-icons/md';

export const Expand = () => {
return (
<Icon aria-label="Expand">
<MdExpandMore size={32} />
</Icon>
);
};

export const DeepDive = () => {
return (
<Icon aria-label="Deep Dive">
<MdHighlightAlt size={'unset'} />
</Icon>
);
};
159 changes: 159 additions & 0 deletions src/components/Accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { useRef, useState, createElement, useEffect } from 'react';
import { Details, Summary } from './styles';
import { Expand, DeepDive } from './icons';
import { trackExpanderOpen } from '../../utils/track';

type AccordionProps = {
title?: string;
headingLevel?: string;
eyebrow?: string;
};

const Accordion: React.FC<AccordionProps> = ({
title,
headingLevel,
eyebrow,
children
}) => {
const [closeButton, setCloseButton] = useState(true);
const [initialHeight, setInitialHeight] = useState(0);
const [expandedHeight, setExpandedHeight] = useState(0);
const docsExpander = useRef<HTMLElement>(null);

useEffect(() => {
const expander = docsExpander.current;

const initHeight =
expander?.children['docs-expander__summary']?.offsetHeight;
const expHeight = getHiddenHeight(expander);

setInitialHeight(initHeight);
setExpandedHeight(expHeight);

// Current decision is to leave the footer close on all expanders
// if (expandedHeight > window.innerHeight) {
// setCloseButton(true);
// }
}, [initialHeight, expandedHeight, closeButton]);

function getHiddenHeight(el) {
if (!el?.cloneNode) {
return null;
}

const clone = el.cloneNode(true);
clone.setAttribute('open', '');
el.after(clone);
const height = clone.offsetHeight;
clone.remove();
return height;
}

const headingId = title?.replace(/\s+/g, '-').toLowerCase();
headingLevel = headingLevel ? 'h' + headingLevel : 'div';
const expanderTitle = createElement(
headingLevel,
{
id: headingId,
className: 'docs-expander__title'
},
title
);

const anchor = createElement(
'a',
{ href: window.location.pathname + '#' + headingId },
expanderTitle
);

const collapse = [
{
maxHeight: expandedHeight + 'px'
},
{ maxHeight: initialHeight + 'px' }
];

const expand = [
{ maxHeight: initialHeight + 'px' },
{
maxHeight: expandedHeight + 'px'
}
];

const animationTiming = {
duration: 700,
iterations: 1
};

const closeAccordion = () => {
const expander = docsExpander.current;
if (expander) {
const scrollToLoc = expander.offsetTop - 48 - 70 - 10; // account for nav heights and 10px buffer

expander.animate(collapse, animationTiming);
window.scrollTo({
left: 0,
top: scrollToLoc,
behavior: 'smooth'
});
setTimeout(function() {
expander.removeAttribute('open');
}, 700);
}
};

const toggleAccordion = (e) => {
e.preventDefault();

const expander = docsExpander.current;
// Close accordion
if (expander?.hasAttribute('open')) {
expander?.animate(collapse, animationTiming);
setTimeout(function() {
expander.removeAttribute('open');
}, 700);
} else {
// Open accordion
trackExpanderOpen(expander?.id.replace('-acc', ''));
expander?.setAttribute('open', '');
expander?.animate(expand, animationTiming);
}
};

return (
<Details
id={headingId + '-acc'}
className="docs-expander"
ref={docsExpander}
>
<Summary
id="docs-expander__summary"
className="docs-expander__summary"
onClick={toggleAccordion}
>
<div className="docs-expander__eyebrow">
<DeepDive />
{eyebrow}
</div>
{anchor}
<div className="docs-expander__title__indicator">
<Expand />
</div>
</Summary>
<div id="docs-expander__body" className="docs-expander__body">
{children}
</div>
{closeButton ? (
<button
id="docs-expander__body__button"
className="docs-expander__body__button"
onClick={closeAccordion}
>
<Expand />
</button>
) : null}
</Details>
);
};

export default Accordion;
127 changes: 127 additions & 0 deletions src/components/Accordion/styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import styled from '@emotion/styled';

export const Details = styled.details`
--border-color: var(--amplify-colors-teal-40);
--background-color: var(--amplify-colors-teal-10);
--background-color-hover: var(--amplify-colors-teal-20);
--border-radius: 0.25rem;
--padding-inline: 1.25rem;
--padding-block: 1rem;
--text-color: var(--amplify-colors-teal-90);
border-radius: var(--border-radius);
border: 1px solid var(--border-color);
text-align: left;
overflow: hidden;
&[open] .docs-expander__summary {
border-end-end-radius: 0;
border-end-start-radius: 0;
}
&[open] .docs-expander__title__indicator svg {
transform: rotate(-180deg);
}
.docs-expander__body {
padding-inline: var(--padding-inline);
padding-block: var(--padding-block);
background-color: white;
border-top: 1px solid var(--border-color);
border-end-end-radius: var(--border-radius);
border-end-start-radius: var(--border-radius);
}
.docs-expander__body__button {
outline: none;
width: 100%;
border-bottom: 1px solid var(--border-color);
background-color: var(--amplify-colors-teal-10);
transform: rotate(-180deg);
padding-inline: var(--padding-inline);
padding-block: var(--padding-block);
text-align: left;
.amplify-icon {
display: flex;
align-items: center;
}
}
.docs-expander__body__button:hover {
cursor: pointer;
}
button.tab-active {
border-bottom: 0.25rem solid var(--amplify-colors-teal-20);
}
`;

export const Summary = styled.summary`
position: relative;
background-color: var(--background-color);
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.25rem;
cursor: pointer;
padding-inline: var(--padding-inline);
padding-block: var(--padding-block);
color: var(--text-color);
transition: background-color 0.25s ease-in-out;
border-radius: var(--border-radius);
list-style: none;
&:hover {
cursor: pointer;
--background-color: var(--background-color-hover);
}
.docs-expander__eyebrow {
font-size: 0.625rem;
font-weight: bold;
text-transform: uppercase;
display: flex;
flex-direction: row;
align-items: center;
gap: 0.25rem;
.amplify-icon {
svg {
height: unset !important;
}
}
}
.docs-expander__title {
font-weight: bold;
font-size: 1rem;
margin: 0;
color: #000;
scroll-padding-top: 100px !important;
}
.docs-expander__button {
border: none;
appearance: none;
background-color: var(--amplify-colors-teal-20);
color: var(--amplify-colors-teal-90);
font-weight: bold;
font-size: 0.75rem;
border-radius: var(--border-radius);
padding-inline: 0.5rem;
padding-block: 0.25rem;
cursor: pointer;
}
.docs-expander__button:hover {
background-color: var(--amplify-colors-teal-40);
}
.docs-expander__title__indicator svg {
position: absolute;
right: var(--padding-inline);
top: 50%;
margin-top: -0.5rem;
transition: transform 0.25s ease-in-out;
}
`;
Loading

0 comments on commit 448d66a

Please sign in to comment.