Skip to content

Commit e71a19a

Browse files
committed
feat: examples onboarding finalization
1 parent 0afc030 commit e71a19a

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

docs/assets/js/bricss.js

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ const bricss = {
88
documentTitleOrigin: '',
99
messages: {
1010
buildFailed: `Failed to load XXX`,
11-
searchTitle: `Search XXX in class names`,
12-
downloadBtnTitle: `Download CSS file XXXKB uncompressed`,
1311
clickToCopyToClipboard: `Click to copy XXX to clipboard`,
12+
cssClass: `CSS class`,
13+
downloadBtnTitle: `Download CSS file XXXKB uncompressed`,
14+
emptyBuildJson: `XXX is empty.`,
15+
example: `Example`,
16+
failJsonExamplesList: `JSON examples list could not be loaded.`,
1417
goToMdn: `Learn more about XXX on Mozilla Developer Network`,
18+
listOfAllAvailableJsonExamples: `List of all JSON examples:`,
19+
openJsonInANewTab: `Open JSON file in a new tab`,
20+
reset: `Reset`,
1521
responsive: `Responsive`,
22+
searchTitle: `Search XXX in class names`,
1623
utility: `Utility`,
17-
cssClass: `CSS class`,
1824
value: `Value`,
19-
reset: `Reset`,
20-
openJsonInANewTab: `Open JSON file in a new tab`
2125
},
2226
getBuild: function(jsonUrl, callback) {
2327
if (typeof jsonUrl == 'string') {
@@ -39,6 +43,7 @@ const bricss = {
3943
bricss.elCopyCssBtn.disabled = false;
4044
bricss.elSearchInput.disabled = false;
4145
bricss.elDownloadLink.classList.remove('opa-5', 'pe-none');
46+
window.scroll({top: 0, behavior: 'smooth'});
4247
}
4348
// console.log(bricss.build);
4449
if (typeof callback == 'function') callback();
@@ -61,7 +66,9 @@ const bricss = {
6166
.catch(error => {
6267
// Handle the error
6368
console.log(error);
64-
alert(`Bad JSON examples URL`);
69+
bricss.elDocStandard.innerHTML = bricss.templates.docExampleWarningItem({
70+
content: bricss.messages.emptyBuildJson.replace(`XXX`, `<a href="./build.json">build.json</a>`) + ' ' + bricss.messages.failJsonExamplesList
71+
});
6572
});
6673
}
6774
},
@@ -322,8 +329,14 @@ const bricss = {
322329
const exampleData = bricss.messages.examples.list[examplesListIndex];
323330
if (typeof exampleData == 'object') {
324331
// Example warning
332+
const markup = bricss.templates.docWarningAdvancedContent({
333+
tag: bricss.messages.example,
334+
title: exampleData.title,
335+
description: exampleData.description,
336+
footer: bricss.messages.examples.warning
337+
});
325338
bricss._markupExampleWarningItem = bricss.templates.docExampleWarningItem({
326-
content: bricss.messages.examples.warning.replace(`XXX`, exampleData.title)
339+
content: markup
327340
});
328341
bricss.getBuild(exampleData.jsonUrl, bricss._insertExampleDoc);
329342
}
@@ -340,17 +353,27 @@ const bricss = {
340353
})
341354
});
342355
bricss.elDocStandard.innerHTML += `
343-
<li class="w-100">Other examples:</li>
356+
<li class="w-100">${bricss.messages.listOfAllAvailableJsonExamples}</li>
344357
${examplesChoicesMarkup}
345358
`;
346359
},
347360
templates: {
361+
docWarningAdvancedContent: function({tag, title, description, footer}) {
362+
return `
363+
<div class="d-flex fd-column">
364+
${tag !== undefined ? `<span class="fs-1 tt-uppercase | c-quaternary-500">${tag}</span>` : ``}
365+
${title !== undefined ? `<h2 class="m-0 pb-2 | ff-lead-700 fs-5 | bbwidth-1 bbstyle-solid bcolor-quaternary-700">${title}</h2>` : ``}
366+
${description !== undefined ? `<p class="mt-2 mb-2">${description}</p>` : ``}
367+
${footer !== undefined ? `<p class="m-0 | fs-3 | c-quaternary-700">${footer}</p>` : ``}
368+
</div>
369+
`;
370+
},
348371
docExampleWarningItem: function({content}) {
349372
return `
350-
<li class="d-flex gap-3 | w-100 p-4 | bc-primary-600 brad-2 bwidth-1 bstyle-solid bcolor-primary-500">
373+
<li class="d-flex gap-4 | w-100 p-4 | bc-primary-600 brad-2 bwidth-1 bstyle-solid bcolor-primary-500">
351374
<div class="pl-2 | brad-2 bc-quaternary-500"></div>
352375
<div class="d-flex ai-center jc-space-between fw-wrap fg-1 gap-3">
353-
<p class="m-0 | fs-4 lh-6">${content}</p>
376+
<div class="maxw-70ch | fs-4 lh-6">${content}</div>
354377
<button type="button"
355378
class="
356379
d-flex gap-2
@@ -367,7 +390,9 @@ const bricss = {
367390
},
368391
docExampleItem: function({title, description, examplesListIndex}) {
369392
return `
370-
<li class="w-6t | p-6 | bwidth-1 bstyle-solid bcolor-primary-500 bc-primary-600 brad-2" w-12t="xs,sm">
393+
<li class="w-4t | p-6 | bwidth-1 bstyle-solid bcolor-primary-500 bc-primary-600 brad-2"
394+
w-6t="md"
395+
w-12t="xs,sm">
371396
<div class="d-flex ai-start gap-6">
372397
<header class="d-flex fd-column gap-3 fg-1">
373398
<h3 class="m-0 pb-3 | ff-lead-700 fs-4 | bbwidth-1 bbstyle-solid bcolor-primary-400">${title}</h3>

json_examples/list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "You may get inspiration from these examples:",
44
"loadBtnTitle": "Load example",
55
"loadBtnText": "Load",
6-
"warning": "<strong>“XXX”</strong> JSON example,<br>the following documentation is generated from an example JSON just to help starting populating your <a href=\"./build.json\">./build.json</a>",
6+
"warning": "The following documentation is generated from an example JSON just to help starting populating your <a href=\"./build.json\" style=\"color: currentColor; text-decoration-color: currentColor\">./build.json</a>",
77
"list": [
88
{
99
"title": "Simpliest",

0 commit comments

Comments
 (0)