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

[WIP] feat: minimal plugin system PoC #135

Closed
wants to merge 29 commits into from
Closed
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
8b1a5d3
feat: basic plugin system PoC
ramboz Oct 18, 2022
2a75982
feat: basic plugin system PoC
ramboz Oct 18, 2022
7c895d0
feat: basic plugin system PoC
ramboz Oct 18, 2022
e8831fa
feat: basic plugin system PoC
ramboz Oct 18, 2022
feb0808
test: add/fix unit tests
ramboz Oct 18, 2022
b2cd247
feat: preload plugins
ramboz Oct 19, 2022
58b8119
feat: preload plugins
ramboz Oct 19, 2022
fa0054f
chore: fix linting issues
ramboz Oct 19, 2022
f99a97b
feat: extract decorator plugin
ramboz Oct 21, 2022
24b0c88
feat: do not preload plugins
ramboz Oct 21, 2022
14ed2dc
Revert "feat: do not preload plugins"
ramboz Oct 21, 2022
6255b3a
fix: move section and block decoration back into the protected area
ramboz Oct 21, 2022
7ad8c7b
refactor: some cleanup and dev docs
ramboz Oct 24, 2022
d3109ee
refactor: address PR feedback
ramboz Oct 24, 2022
ba5ef3b
refactor: automatically decorate template and theme in the plugin
ramboz Oct 24, 2022
11af6e6
refactor: some cleanup and dev docs
ramboz Oct 24, 2022
546f7d1
fix: linting issue
ramboz Oct 24, 2022
8779f34
fix: missing load RUM event
ramboz Oct 26, 2022
82b6cbe
fix(rum): merge conflict for #139
ramboz Oct 26, 2022
ebdee0d
fix: move RUM plugin back into lib-franklin to properly catch DOM events
ramboz Nov 2, 2022
d1c1fe3
fix: fix script references CORS in head
ramboz Nov 2, 2022
6641b32
Merge branch 'main' into poc-plugin-system
ramboz Nov 2, 2022
3484d36
fix: plugin loading
ramboz Nov 2, 2022
8bbfc15
fix: RUM plugin tests
ramboz Nov 2, 2022
976e088
refactor: clean up PR
ramboz Nov 2, 2022
2610642
refactor: clean up PR
ramboz Nov 2, 2022
1554df2
refactor: clean up PR
ramboz Nov 2, 2022
2e52b6c
refactor: clean up PR
ramboz Nov 2, 2022
4536720
fix: adjust plugin name logic
ramboz Nov 3, 2022
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
6 changes: 3 additions & 3 deletions blocks/footer/footer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { readBlockConfig, decorateIcons } from '../../scripts/lib-franklin.js';
import { readBlockConfig } from '../../scripts/lib-franklin.js';

/**
* loads and decorates the footer
* @param {Element} block The header block element
*/

export default async function decorate(block) {
export default async function decorate(block, plugins) {
const cfg = readBlockConfig(block);
block.textContent = '';

Expand All @@ -14,6 +14,6 @@ export default async function decorate(block) {
const html = await resp.text();
const footer = document.createElement('div');
footer.innerHTML = html;
await decorateIcons(footer);
await plugins.decorator.decorateIcons(footer);
block.append(footer);
}
8 changes: 4 additions & 4 deletions blocks/header/header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readBlockConfig, decorateIcons } from '../../scripts/lib-franklin.js';
import { readBlockConfig } from '../../scripts/lib-franklin.js';

/**
* collapses all open nav sections
Expand All @@ -16,7 +16,7 @@ function collapseAllNavSections(sections) {
* @param {Element} block The header block element
*/

export default async function decorate(block) {
export default async function decorate(block, plugins) {
const cfg = readBlockConfig(block);
block.textContent = '';

Expand All @@ -29,7 +29,7 @@ export default async function decorate(block) {
// decorate nav DOM
const nav = document.createElement('nav');
nav.innerHTML = html;
decorateIcons(nav);
plugins.decorator.decorateIcons(nav);

const classes = ['brand', 'sections', 'tools'];
classes.forEach((e, j) => {
Expand Down Expand Up @@ -60,7 +60,7 @@ export default async function decorate(block) {
});
nav.prepend(hamburger);
nav.setAttribute('aria-expanded', 'false');
decorateIcons(nav);
plugins.decorator.decorateIcons(nav);
block.append(nav);
}
}
1 change: 1 addition & 0 deletions head.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="modulepreload" href="/scripts/plugins/decorator.js"/>
<script src="/scripts/lib-franklin.js" type="module"></script>
<script src="/scripts/scripts.js" type="module"></script>
<link rel="stylesheet" href="/styles/styles.css"/>
Expand Down
8 changes: 1 addition & 7 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
// eslint-disable-next-line import/no-cycle
import { sampleRUM } from './lib-franklin.js';

// Core Web Vitals RUM collection
sampleRUM('cwv');

// add more delayed functionality here
// Execute anything that can be postponed to the latest here
Loading