Skip to content

Commit

Permalink
perf(examples): refactor examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-capsule42 committed Feb 23, 2024
1 parent 36de6a9 commit 6549b3a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 32 deletions.
6 changes: 3 additions & 3 deletions demo/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
<script src="https://cdn.jsdelivr.net/npm@aurodesignsystem/auro-icon@latest/dist/auro-icon__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm@aurodesignsystem/auro-input@latest/dist/auro-input__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm@aurodesignsystem/auro-button@latest/dist/auro-button__bundled.js" type="module"></script>
<script src="./api.min.js"></script>
<script>
initMenuApiExamples();
<script type="module">
import { initExamples } from "./api.min.js"
initExamples();
</script>
</body>
</html>
10 changes: 7 additions & 3 deletions demo/api.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
/* eslint-disable jsdoc/require-jsdoc, no-magic-numbers, no-param-reassign */

import { auroMenuResetExample } from '../apiExamples/reset';
import { auroMenuMatchWordExample } from '../apiExamples/matchWord';
import { auroMenuCustomEventExample } from '../apiExamples/customEvent';

export function initMenuApiExamples(initCount) {
export function initExamples(initCount) {
initCount = initCount || 0;

try {
// javascript example function calls to be added here upon creation to test examples
auroMenuResetExample();
auroMenuMatchWordExample();
auroMenuCustomEventExample();
} catch {
} catch (err) {
if (initCount <= 20) {
// setTimeout handles issue where content is sometimes loaded after the functions get called
setTimeout(() => {
initMenuApiExamples(initCount + 1);
initExamples(initCount + 1);
}, 100);
}
}
}

12 changes: 8 additions & 4 deletions demo/api.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,25 @@ function auroMenuCustomEventExample() {
}
}

function initMenuApiExamples(initCount) {
/* eslint-disable jsdoc/require-jsdoc, no-magic-numbers, no-param-reassign */


function initExamples(initCount) {
initCount = initCount || 0;

try {
// javascript example function calls to be added here upon creation to test examples
auroMenuResetExample();
auroMenuMatchWordExample();
auroMenuCustomEventExample();
} catch {
} catch (err) {
if (initCount <= 20) {
// setTimeout handles issue where content is sometimes loaded after the functions get called
setTimeout(() => {
initMenuApiExamples(initCount + 1);
initExamples(initCount + 1);
}, 100);
}
}
}

export { initMenuApiExamples };
export { initExamples };
6 changes: 3 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
</script>

<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
<script src="./index.min.js"></script>
<script>
initMenuIndexExamples();
<script type="module">
import { initExamples } from "./index.min.js"
initExamples();
</script>
</body>
</html>
13 changes: 10 additions & 3 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
export function initMenuIndexExamples(initCount) {
/* eslint-disable jsdoc/require-jsdoc, no-magic-numbers, no-param-reassign */

// import { auroMenuResetExample } from '../apiExamples/reset';

export function initExamples(initCount) {
initCount = initCount || 0;

try {
} catch {
// javascript example function calls to be added here upon creation to test examples
// auroMenuResetExample();
} catch (err) {
if (initCount <= 20) {
// setTimeout handles issue where content is sometimes loaded after the functions get called
setTimeout(() => {
initMenuIndexExamples(initCount + 1);
initExamples(initCount + 1);
}, 100);
}
}
}

7 changes: 6 additions & 1 deletion demo/index.min.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
function initMenuIndexExamples(initCount) {
/* eslint-disable jsdoc/require-jsdoc, no-magic-numbers, no-param-reassign */

// import { auroMenuResetExample } from '../apiExamples/reset';

function initExamples(initCount) {
}

export { initExamples };
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@
"web components"
],
"scripts": {
"build": "npm-run-all build:sass linters sass:render dist:js bundler postinstall build:api build:docs build:demoScripts types",
"build": "npm-run-all build:sass linters sass:render dist:js bundler postinstall build:api build:docs types",
"build:ci": "npm-run-all sweep build",
"build:api": "wca analyze 'src/auro-menu.js' --outFiles docs/api.md",
"build:dev:assets": "npm-run-all build:sass:component postCss:component sass:render build:docs",
"build:demoScripts": "node scripts/prepExampleFiles.mjs",
"build:docs": "node scripts/generateDocs.mjs",
"build:sass": "npm-run-all build:sass:component postCss:component sass:render",
"build:sass:component": "sass --no-source-map src:src",
Expand Down
13 changes: 0 additions & 13 deletions scripts/prepExampleFiles.mjs

This file was deleted.

0 comments on commit 6549b3a

Please sign in to comment.