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

feat(support-pages): Add a new import script #275

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
23bc6d4
support pages import
amol-anand Jul 12, 2023
1e186a6
Get titles working properly
amol-anand Jul 12, 2023
256ca28
Merge branch 'main' into support-pages-import
amol-anand Jul 14, 2023
6d28bac
Merge branch 'main' into support-pages-import
proeung Jul 21, 2023
665647e
Merge branch 'main' into support-pages-import
proeung Jul 31, 2023
b3a7b33
Merge branch 'main' into support-pages-import
amol-anand Aug 1, 2023
c17632c
Breadcrumb block for support pages
amol-anand Aug 1, 2023
97d6e27
Initial search functionality
amol-anand Aug 1, 2023
745a97c
search title AND description
amol-anand Aug 1, 2023
5baa0f1
mobile styling
amol-anand Aug 1, 2023
58287c0
Style tweaks
amol-anand Aug 1, 2023
304b486
saving progress on right nav
amol-anand Aug 1, 2023
2cafe5d
Moved breadcrumb to autoblock based on metadata
amol-anand Aug 1, 2023
be96a86
moved breadcrumb to main and fixed right-nav
amol-anand Aug 1, 2023
f64fa28
adding breadcrumb and right nav to import script
amol-anand Aug 2, 2023
877493f
switched breadcrumb logic to only highlight
amol-anand Aug 2, 2023
7f47653
cleanup
amol-anand Aug 2, 2023
9f77f2b
handle tables
amol-anand Aug 3, 2023
28a166f
More finessing of text styles
amol-anand Aug 3, 2023
1c364de
bug fix
amol-anand Aug 7, 2023
ec7433d
fix bold spans issue
amol-anand Aug 7, 2023
7bd8139
fixed the issue
amol-anand Aug 7, 2023
0b60d17
fix for empty strong tag
amol-anand Aug 7, 2023
678fb70
fixing bugs
amol-anand Aug 7, 2023
a5f826d
clean up
amol-anand Aug 7, 2023
1cb298f
bug fix
amol-anand Aug 7, 2023
85d5c36
Merge branch 'main' into support-pages-import
amol-anand Aug 7, 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
54 changes: 54 additions & 0 deletions blocks/breadcrumb/breadcrumb.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* Breadcrumb CSS */

.section.breadcrumb-container > div.breadcrumb-wrapper {
padding: unset;
width: 100%;
background-color: #F3F1ED;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
background-color: #F3F1ED;
background-color: var(--neutral-40);

Let's add this neutral 40% hex color variable to our style.css - --neutral-40: F3F1ED;

}

.breadcrumb.block {
display: flex;
flex-direction: row;
margin: 0 auto;
justify-content: space-between;
align-items: center;
width: 100%;
padding: 0 24px;
}

.breadcrumb.block .breadcrumb-links {
padding: 19px 0 !important;
font-family: var(--sans-serif-font-regular);
font-size: var(--font-size-16);
font-weight: var(--font-weight-regular);
line-height: var(--line-height-160);
letter-spacing: var(--letter-spacing-001-em);
}

.breadcrumb.block .breadcrumb-links span.breadcrumb-link {
margin-right: 10px;
}

.breadcrumb.block .breadcrumb-links span.breadcrumb-link:not(.active) a {
text-decoration: none;
color: var(--neutral-carbon);
}

.breadcrumb.block .breadcrumb-links span.breadcrumb-link:hover,
.breadcrumb.block .breadcrumb-links span.breadcrumb-link.active {
color: var(--primary-purple);
}

.breadcrumb.block .breadcrumb-links span.breadcrumb-link:hover a,
.breadcrumb.block .breadcrumb-links span.breadcrumb-link.active a {
color: var(--primary-purple);
text-decoration: underline;
}

@media only screen and (min-width: 1200px) {
.breadcrumb.block {
margin: 0 auto;
padding: unset;
width: var(--section-width-desktop);
}
}
18 changes: 18 additions & 0 deletions blocks/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createTag } from '../../scripts/scripts.js';

export default async function decorate(block) {
const breadcrumbLinks = createTag('div', { class: 'breadcrumb-links' });
const links = block.querySelectorAll('a');
links.forEach((link) => {
link.parentElement.remove();
const newLink = createTag('span', { class: 'breadcrumb-link' }, link);
const linkUrl = new URL(link.href);
if (linkUrl.pathname === window.location.pathname) newLink.classList.add('active');
breadcrumbLinks.appendChild(newLink);
newLink.innerHTML += ' > ';
});
block.prepend(breadcrumbLinks);
const icon = block.querySelector('span.icon');
icon.parentElement.parentElement.remove();
block.append(icon);
}
15 changes: 1 addition & 14 deletions blocks/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,18 @@ import {
readBlockConfig,
decorateButtons,
decorateIcons,
loadBlocks,
} from '../../scripts/lib-franklin.js';

import {
createTag,
decorateMain,
fetchFragment,
} from '../../scripts/scripts.js';

const KEY_ENTER = 'Enter';

const mobileMedia = window.matchMedia('(max-width: 1199px)');
const desktopMedia = window.matchMedia('(min-width: 1200px)');

async function fetchFragment(path) {
const resp = await fetch(`${path}.plain.html`);
if (resp.ok) {
const container = document.createElement('main');
container.innerHTML = await resp.text();
decorateMain(container);
await loadBlocks(container);
return container.querySelector(':scope .section');
}
return null;
}

/**
* collapses all open nav sections
* @param {Element} sections The container element
Expand Down
26 changes: 26 additions & 0 deletions blocks/right-nav/right-nav.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Right Nav CSS */

@media only screen and (min-width: 1200px) {
main .section.right-nav-container > div {
width: unset;
}

.section.right-nav-container {
position: relative;
display: grid;
grid-template-columns: 3fr 1fr;
width: var(--section-width-desktop);
margin: 0 auto;
}

.section.right-nav-container > *:not(.right-nav-wrapper) {
grid-column-start: 1;
}

.section.right-nav-container > .right-nav-wrapper {
grid-column-start: 2;
grid-row-start: 1;
padding-top: var(--spacer-layout-07);
margin-left: 8%;
}
}
Comment on lines +1 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: I think we should rename this block right-nav to sidebar. "Right Nav" implies that it's navigational content, however, this is more supplemental info.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to change the name. whatever makes more sense for you

Empty file added blocks/right-nav/right-nav.js
Empty file.
76 changes: 76 additions & 0 deletions blocks/search/search.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* Search Block CSS */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We'll clean up some of the stylings to ensure that we're using the spacings and etc from the design specs.

.search.block {
width: 100%;
font-family: var(--sans-serif-font-light);
font-size: var(--font-size-16);
letter-spacing: var(--letter-spacing-001-em);
line-height: var(--line-height-160);
font-weight: var(--font-weight-light);
color: var(--neutral-carbon);
}

.search.block form {
position: relative;
display: flex;
width: 100%;
height: 44px;
background-color: var(--neutral-bone);
border-bottom: 1px solid var(--neutral-carbon);
}

.search.block form input {
position: relative;
width: 100%;
box-sizing: border-box;
background-position: 14px 12px;
background-repeat: no-repeat;
padding: 8px 16px;
border: 0;
background-color: var(--neutral-bone);
}

.search.block form span.search-icon {
display: block;
position: relative;
background: url('../../icons/search.svg') no-repeat;
color: #000;
height: 24px;
width: 24px;
margin: 13px 13px 0 0;
padding: 0 23px 0 0;
min-width: 14px;
}

.search.block div.results ul {
max-height: 280px;
overflow-y: auto;
padding: unset;
}

.search.block div.results ul li {
padding: 15px 16px;
text-decoration: none;
display: block;
border-bottom: 1px solid #e7e2da;
}

.search.block div.results ul li:hover {
background-color: #ebccff;
}

.search.block div.results ul li a {
text-decoration: none;
border: unset;
color: var(--neutral-carbon);
}

@media only screen and (min-width: 768px) {
/* Tablet styles */
.search.block {
width: 700px;
}
}

@media only screen and (min-width: 1200px) {
/* Desktop styles */
}
47 changes: 47 additions & 0 deletions blocks/search/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { createTag, getSearchIndex } from '../../scripts/scripts.js';
import { readBlockConfig } from '../../scripts/lib-franklin.js';

let index;
let searchTerm = '';
let results;

async function showResults() {
// clear the results
results.innerHTML = '';
// filter and redraw the results
const ul = createTag('ul');
index
.filter((row) => (row.title.toLowerCase().includes(searchTerm.toLowerCase())
|| row.description.toLowerCase().includes(searchTerm.toLowerCase())))
.forEach((row) => {
const link = createTag('a', { href: row.path, 'aria-label': row.title }, row.title);
const li = createTag('li', { class: 'search-result' }, link);
ul.append(li);
});
results.append(ul);
}

export default async function decorate(block) {
const cfg = await readBlockConfig(block);
block.textContent = '';
const filter = cfg.filter || '';
index = await getSearchIndex(filter);
const input = createTag('input', {
type: 'text',
placeholder: 'Type a search term or article type, such as release notes or news.',
});
const form = createTag('form', { onsubmit: 'event.preventDefault();' }, input);
const searchIcon = createTag('span', { class: 'search-icon' });
results = createTag('div', { class: 'results' });
form.append(searchIcon);
block.append(form);
block.append(results);

// Search input listener
input.addEventListener('input', async (e) => {
// saving the input value
searchTerm = e.target.value;
// re-displaying results based on the new search_term
await showResults();
});
}
Loading