Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Boles committed Oct 12, 2023
2 parents d914aa4 + 8383458 commit 24281de
Show file tree
Hide file tree
Showing 130 changed files with 828 additions and 291 deletions.
8 changes: 4 additions & 4 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Page not found">
<script src="/prisma/prisma-cloud/scripts/scripts.js" type="module" crossorigin="use-credentials"></script>
<script src="/scripts/scripts.js" type="module" crossorigin="use-credentials"></script>
<script type="module">
import { sampleRUM } from '/prisma/prisma-cloud/scripts/lib-franklin.js';
import { sampleRUM } from '/scripts/lib-franklin.js';

window.addEventListener('load', () => {
if (document.referrer) {
Expand All @@ -29,7 +29,7 @@
sampleRUM('404', { source: document.referrer, target: window.location.href });
});
</script>
<link rel="stylesheet" href="/prisma/prisma-cloud/styles/styles.css">
<link rel="stylesheet" href="/styles/styles.css">
<style>
main.error {
min-height: calc(100vh - var(--nav-height));
Expand All @@ -46,7 +46,7 @@
font-family: var(--fixed-font-family);
}
</style>
<link rel="stylesheet" href="/prisma/prisma-cloud/styles/lazy-styles.css">
<link rel="stylesheet" href="/styles/lazy-styles.css">
</head>

<body>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
See also: https://github.com/hlxsites/prisma-cloud-docs

## Environments
- Preview: https://main--prisma-cloud-docs-website--hlxsites.hlx.page/prisma/prisma-cloud/en
- Live: https://main--prisma-cloud-docs-website--hlxsites.hlx.live/prisma/prisma-cloud/en
- Preview: https://main--prisma-cloud-docs-website--hlxsites.hlx.page/en
- Live: https://main--prisma-cloud-docs-website--hlxsites.hlx.live/en


## Installation
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@
top: 50%;
text-decoration: none;
transition: background-color var(--theme-transition-ease-duration)
var(--theme-transition-ease-function),
var(--theme-transition-ease-function),
opacity var(--theme-transition-ease-duration)
var(--theme-transition-ease-function);
var(--theme-transition-ease-function);
height: var(--spacing--8);
width: var(--spacing--8);
}
Expand Down Expand Up @@ -225,12 +225,13 @@ article [data-docs-heading] span {
}

.pan-article .last-updated {
display: none;
display: flex;
opacity: 0;
color: var(--last-updated-text-color);
}

.pan-article .last-updated.is-visible {
display: flex;
opacity: 1;
}

.pan-article .banner {
Expand Down Expand Up @@ -290,14 +291,18 @@ article [data-docs-heading] span {
}

.pan-article .edit-github {
display: flex;
display: none;
justify-content: flex-end;
margin: 0;
/* position: absolute;
right: 49px;
top: 36px; */
}

.source-adoc .pan-article .edit-github {
display: flex;
}

.pan-article .edit-github a {
background: var(--small-action-background-color);
border-radius: var(--small-action-border-radius);
Expand Down Expand Up @@ -523,9 +528,9 @@ article [data-docs-heading] span {
}

.pan-article
.version-dropdown-menu.is-active
+ .version-button
.icon-container {
.version-dropdown-menu.is-active
+ .version-button
.icon-container {
transform: scale(-1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
SPA_NAVIGATION,
decorateMain,
getPlaceholders,
loadArticle,
loadBook,
parseFragment,
render,
Expand Down Expand Up @@ -338,7 +337,7 @@ const decorateTitles = (block) => {
outlineSlot.replaceWith(pageOutline.cloneNode(true));

// Only show outline if there are headings in the article
if (articleTitles?.length > 0) {
if (articleTitles.length > 0) {
const pageOutlineContainer = document.querySelector('.article-outline');
pageOutlineContainer.classList.add('is-visible');
}
Expand All @@ -349,7 +348,7 @@ const decorateTitles = (block) => {
scrollSpy.setAttribute('ready', true);
}

const hash = window.location?.hash;
const { hash } = window.location;
if (hash) {
const target = block.querySelector(`${hash}`);

Expand All @@ -363,16 +362,14 @@ const decorateTitles = (block) => {

/**
* @param {HTMLElement} block the container element
* @param {string} hrefOrRes href on render, html string on rerender
* @param {*} rerender whether this is a rerender
* @param {ArticleResponse} res defined on rerender
* @param {boolean} rerender whether this is a rerender
*/
async function renderContent(block, hrefOrRes, rerender = false) {
async function renderContent(block, res, rerender = false) {
let articleFound = true;
block.innerHTML = '';

let res = hrefOrRes;
if (!rerender) {
res = await loadArticle(hrefOrRes);
if (!res || !res.ok) {
console.error(`failed to load article (${res.status}): `, res);
if (res.status === 404 && shouldRedirectMissing()) {
Expand All @@ -383,21 +380,25 @@ async function renderContent(block, hrefOrRes, rerender = false) {
}
}

const isGdoc = res.source === 'gdoc';
const template = parseFragment(TEMPLATE);
const fragment = document.createElement('div');

const docTitle = document.createElement('a');
docTitle.setAttribute('slot', 'document');
docTitle.href = window.location.href.split('/').slice(0, -2).join('/');
docTitle.textContent = store?.mainBook?.title;
docTitle.textContent = isGdoc ? document.title : store.mainBook.title;
fragment.append(docTitle);

block.classList.remove(`source-${isGdoc ? 'adoc' : 'gdoc'}`);
block.classList.add(`source-${isGdoc ? 'gdoc' : 'adoc'}`);

if (articleFound) {
const { html, info } = res;
const article = parseFragment(html);

// Set last updated
const lastUpdated = res?.info?.lastModified;
const lastUpdated = res.info.lastModified;
if (lastUpdated) {
const lastUpdatedLocale = lastUpdated.toLocaleString('default', {
month: 'long',
Expand All @@ -413,21 +414,25 @@ async function renderContent(block, hrefOrRes, rerender = false) {
}

// Fixup images src
for (const image of article.querySelectorAll('img')) {
const imageURL = new URL(image.src);

if (store.branch) {
setBranch(imageURL, store.branch);
image.src = imageURL.toString();
} else {
image.src = `${store.docsOrigin}${imageURL.pathname}`;
}
if (!isGdoc) {
for (const image of article.querySelectorAll('img')) {
const imageURL = new URL(image.src);

if (store.branch) {
setBranch(imageURL, store.branch);
image.src = imageURL.toString();
} else {
// add /docs/ prefix if missing
const path = imageURL.pathname.startsWith('/docs/') ? imageURL.pathname : `/docs${imageURL.pathname}`;
image.src = `${store.docsOrigin}${path}${imageURL.search}`;
}

const picture = image.parentElement;
if (picture.tagName === 'PICTURE') {
for (const source of picture.querySelectorAll('source')) {
const search = source.srcset.split('?')[1];
source.srcset = `${image.src}?${search}`;
const picture = image.parentElement;
if (picture.tagName === 'PICTURE') {
for (const source of picture.querySelectorAll('source')) {
const search = source.srcset.split('?')[1];
source.srcset = `${image.src}?${search}`;
}
}
}
}
Expand Down Expand Up @@ -461,12 +466,14 @@ async function renderContent(block, hrefOrRes, rerender = false) {
localize(block);

// Post render
block.querySelector(
'.edit-github a',
).href = `https://github.com/hlxsites/prisma-cloud-docs/blob/main/${window.location.pathname.replace(
PATH_PREFIX,
'docs',
)}.adoc`;
if (!isGdoc) {
block.querySelector(
'.edit-github a',
).href = `https://github.com/hlxsites/prisma-cloud-docs/blob/main/${window.location.pathname.replace(
PATH_PREFIX,
'docs',
)}.adoc`;
}

// update dropdown links
const versionMenu = block.querySelector('.version-dropdown-menu');
Expand All @@ -485,14 +492,14 @@ async function renderContent(block, hrefOrRes, rerender = false) {
// Add link to division landing
const backHomeLink = block.querySelector('.back-home a');
if (backHomeLink) {
const locale = window.location.pathname.split('/')?.[3];
const locale = window.location.pathname.split('/')[3];
const divisionLandingUrl = `${window.location.origin}${window.hlx.codeBasePath}/${locale}`;
backHomeLink.setAttribute('href', divisionLandingUrl);
}

// Show last updated if it exisxts
const lastUpdated = res?.info?.lastModified;
if (lastUpdated) {
const hasLastMod = res && res.info && res.info.lastModified;
if (hasLastMod) {
const lastUpdatedWrapper = document.querySelector('.last-updated');
lastUpdatedWrapper.classList.add('is-visible');
}
Expand All @@ -512,14 +519,14 @@ async function renderContent(block, hrefOrRes, rerender = false) {
// Load sidenav, once
if (!rerender) {
renderSidenav(block);
await import('../theme-toggle/theme-toggle.js');
await import('../../scripts/scroll-spy.js');
import('../theme-toggle/theme-toggle.js');
import('../../scripts/scroll-spy.js');
}

if (articleFound) {
const bookContent = block.querySelector('.book-content div[slot="content"]');
if (bookContent) {
decorateMain(bookContent);
await decorateMain(bookContent);
await loadBlocks(bookContent);
updateSectionsStatus(bookContent);

Expand All @@ -540,29 +547,9 @@ const renderCurrentVersion = (block) => {

/** @param {HTMLDivElement} block */
export default async function decorate(block) {
const link = block.querySelector('a');

if (link) {
try {
const href = link.getAttribute('href') || link.innerText;
if (href) {
if (store.branch) {
const url = new URL(href);
setBranch(url, store.branch);

await renderContent(block, url.toString());
renderCurrentVersion(block);
initVersionDropdown(block);
} else {
await renderContent(block, href);
renderCurrentVersion(block);
initVersionDropdown(block);
}
}
} catch (e) {
console.error(e);
}
}
await renderContent(block, store.article);
renderCurrentVersion(block);
initVersionDropdown(block);

if (SPA_NAVIGATION) {
store.on('spa:navigate:article', async (res) => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

.card-carousel .card {
background: url("/prisma/prisma-cloud/assets/card-background.jpg") 0 0
background: url("/assets/card-background.jpg") 0 0
no-repeat;
background-size: cover;
border-radius: var(--spacing--5);
Expand Down Expand Up @@ -153,3 +153,9 @@
display: none;
}
}

@media (max-width: 1100px) {
.card-carousel {
overflow: hidden;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions blocks/category/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export const collapseSection = (element) => {
// Get the height of the element's inner content, regardless of its actual size
const sectionHeight = element.scrollHeight;

// Temporarily disable all css transitions
const elementTransition = element.style.transition;
element.style.transition = '';

/**
* On the next frame (as soon as the previous style change has taken effect),
* explicitly set the element's height to its current pixel height, so we
* aren't transitioning out of 'auto'
*/
requestAnimationFrame(() => {
element.style.height = `${sectionHeight}px`;
element.style.transition = elementTransition;

/**
* On the next frame (as soon as the previous style change has taken effect),
* have the element transition to height: 0
*/
requestAnimationFrame(() => {
element.style.height = '0px';
});
});

// Mark the section as "currently collapsed"
element.setAttribute('data-collapsed', 'true');
};

export const expandSection = (element) => {
// Get the height of the element's inner content, regardless of its actual size
const sectionHeight = element.scrollHeight;

// Have the element transition to the height of its inner content
element.style.height = `${sectionHeight}px`;

// When the next css transition finishes (which should be the one we just triggered)
element.addEventListener('transitionend', () => {
// Remove this event listener so it only gets triggered once
// eslint-disable-next-line no-caller, no-restricted-properties, no-undef
element.removeEventListener('transitionend', arguments.callee);

// Remove "height" from the element's inline styles, so it can return to its initial value
element.style.height = null;
});

// Mark the section as "currently not collapsed"
element.setAttribute('data-collapsed', 'false');
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function loadFragment(path, fromDocs) {
}
}

decorateMain(main);
await decorateMain(main);
await loadBlocks(main);
updateSectionsStatus(main);
return main;
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 24281de

Please sign in to comment.