30 Commits

Author SHA1 Message Date
f358266533 Fixes #17 - add variable for colour text 2024-09-16 09:53:49 -04:00
b5ab99da8d Fixes #12 in the tab 2024-09-13 11:00:52 -04:00
5fa631a903 Fixes #12 2024-09-13 10:45:55 -04:00
c201ff8f63 Fixes #11 Second Parameter to false will not add spacer li 2024-09-03 17:55:37 -04:00
2c117442af Fixes #10 Force status for core patterns to complete 2024-09-03 17:43:07 -04:00
b60c118e41 Add font to tooltip 2024-08-21 13:30:10 -04:00
acdb794971 Move get url to self referential function 2024-08-20 13:08:46 -04:00
140b239cfc Update to allow tab and space or enter to select a tab and change copyright info 2024-08-16 21:10:37 -04:00
a60f831900 Add getCSS 2024-08-07 08:08:59 -04:00
ea92f5e7ac Update patterns use paths to match what download.php gives 2024-07-29 19:12:22 -04:00
3292729d53 Update pattern documentation 2024-07-28 15:30:51 -04:00
77a13bbd46 Update to handle multiple level statuses. 2024-07-25 17:21:52 -04:00
bdb7f0e0aa Fixed typo 2024-07-23 21:18:17 -04:00
0b82aa4be6 Update div.tab-group to use tabset 2024-07-23 20:50:36 -04:00
fd53ee174a Fixes #2 for performances issues 2024-07-23 18:08:37 -04:00
c94d5e565f Fixes #5 Update sort 2024-07-22 18:39:14 -04:00
552a204edd Fixes #5 Update to include display text in status an alpha reports 2024-07-22 18:24:29 -04:00
e7d4e2ab48 Added bootstrap comment 2024-07-22 12:01:15 -04:00
fa165d530f Added XXL breakpoint to match bootstrap v5.0 2024-07-22 12:00:26 -04:00
74fc7a4c11 Fixes #3 - Added instructions to readme.md 2024-07-16 04:06:19 -04:00
9cba20c39c Completed descriptions for layout patterns 2024-07-16 03:57:34 -04:00
3c261881e9 Update switches to include breakpoints 2024-07-16 03:44:48 -04:00
c0ea225d03 Update tooltip, mark complete 2024-07-16 03:44:20 -04:00
ce98e0c488 Update switch - set to done 2024-07-16 03:11:51 -04:00
fa708175b7 Move pug pattern files to .pp, check tab order 2024-07-16 02:49:53 -04:00
0036bcf0fd Fixes #2 interaction observer unobserving and loading before on page. 2024-07-15 12:24:35 -04:00
0708328647 Move unobserve to unobserve all patterns after a load's ready state is done.
Safe to assume that unless you're still copying the design system to some place that the result won't be any different. Since that is such an edge case a page reload should suffice.
2024-07-15 09:27:06 -04:00
74abc40dc4 Stop observing loaded patterns 2024-07-15 09:17:22 -04:00
4c394e5215 Temp fix for compile bug 2024-07-15 07:57:46 -04:00
1c0186d4fe Update ajax to use intersection observer 2024-07-14 21:52:51 -04:00
46 changed files with 953 additions and 939 deletions

View File

@@ -34,3 +34,21 @@ The content variable in \_config.pug defines your array of patterns. It is made
By changing and resaving the \_config.pug file, (our change is often adding or removing a random space) all of the pug patterns will recompile. Note that md templates will not recompile automatically when config is saved and updated as markdown files don't have an include.
## Including PugJS in Pug files without compiling
If you wish to include Pug output as code in your instance, you can do this without manually creating a second 'dot container' version of the file. Including files with 'unrecognised' extensions does not compile them.
1. In your project config, create a Custom Tool called Pug pattern to pug file
1. Check Process automatically and set the command to 'cp {{input}} {{output}}' on Mac/Linux and 'copy {{input}} {{output}}' on Windows. (This is just your operating system's command line file copy executable.)
1. Set the Output to Relative to input
1. Set the Output Extension to .pug
In your design system implementation,
1. Create the files that you edit as _[pattern].pp files, and set them to auto compile. (You may wish to let your text editor know what they are, so the syntax highlighting works.
1. Save the file, ensure that it is set to in prepros it is set to process automatically.
1. Include the .pp file as your pug pattern with .language-pug and include the .pug file as your html output.
This will ensure that the .pug file will get processed and the .pp file will be handled as text will get compiled, but they should display correctly and remain in sync while maintaining the minimum number of files.
## Credits
This framework includes [PrismJS](https://prismjs.com/) for code syntax highlighting. PrismJS is released under the [MIT license](https://opensource.org/licenses/MIT)>

View File

@@ -2,7 +2,11 @@
"folders":
[
{
"path": "."
"path": ".",
"folder_exclude_patterns": ["src/pg/patterns"]
},
{
"path": "./src/pg/patterns"
}
],
}

View File

@@ -284,11 +284,7 @@
"/Users/am/Desktop/ds2-core/src",
"/Users/am/Desktop/ds2-core/src/pg",
"/Users/am/Desktop/ds2-core/src/pg/patterns",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/components",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/sticky-note",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/switch",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/tooltip"
"/Users/am/Desktop/ds2-core/src/pg/patterns/core"
],
"file_history":
[
@@ -423,7 +419,7 @@
],
"find":
{
"height": 26.0
"height": 24.0
},
"find_in_files":
{
@@ -511,7 +507,7 @@
],
"incremental_find":
{
"height": 26.0
"height": 24.0
},
"input":
{
@@ -556,7 +552,7 @@
"project": "ds2 core.sublime-project",
"replace":
{
"height": 68.0
"height": 44.0
},
"save_all_on_build": false,
"select_file":

View File

@@ -492,6 +492,9 @@
"resolveJsonModule": false,
"esModuleInterop": false,
"useDefineForClassFields": false
},
"custom-gzg6caunrh": {
"command": "cp {{input}} {{output}}"
}
},
"fileTypes": {
@@ -955,6 +958,26 @@
"type": "SOURCE_RELATIVE",
"relativePath": ""
}
},
"custom-sm9kzo2npr": {
"autoCompile": true,
"label": "Pug pattern to pug file",
"extensions": [
".pp"
],
"tasks": [
{
"task": "custom-gzg6caunrh",
"enable": true
}
],
"output": {
"extension": ".pug",
"type": "SOURCE_RELATIVE",
"relativePath": "",
"suffix": "-dist",
"alwaysSuffix": false
}
}
},
"files": [
@@ -1346,6 +1369,30 @@
}
}
},
{
"file": "src/pg/patterns/core/sticky-note/_sticky-note.pp",
"config": {
"autoCompile": true
}
},
{
"file": "src/pg/patterns/core/switch/_switch.pp",
"config": {
"autoCompile": true
}
},
{
"file": "src/pg/patterns/core/tabs/_tabs.pp",
"config": {
"autoCompile": true
}
},
{
"file": "src/pg/patterns/core/tooltip/_tooltip.pp",
"config": {
"autoCompile": true
}
},
{
"file": "src/pg/patterns/layouts/header-core/header.scss",
"config": {

View File

@@ -108,7 +108,19 @@ const getURLVars = () => {
}
module.exports = {
url: getURLVars(),
url: (() => {
var v = {};
if (location.search.length > 0) {
var qs = (location.search.substr(1)).split("&");
for (var i = 0; i < qs.length; i++) {
var t = qs[i].split("=");
if (t[1].length > 0) {
v[t[0]] = decodeURIComponent(t[1].replace(/\+/g, '%20'));
}
}
}
return v;
})(),
cookie: {
set: (name, value, expires, path, domain, secure) => {
switch(typeof expires) {
@@ -172,6 +184,9 @@ module.exports = {
})
}
},
// getCSS: (el, prop, b = false) {
// return window.getComputedStyle(el, null).getPropertyValue(prop);
// },
init: (args = {}) => {
const url = getURLVars();
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
@@ -187,96 +202,115 @@ module.exports = {
}
}
if (typeof args.beforeArticleLoad == "function") args.beforeArticleLoad(a);
if (typeof args.beforeArticleLoad == "function") args.beforeArticleLoad();
document.querySelectorAll("article").forEach((a) => {
if ( a.getAttribute("data-template") != "none" ) {
let path = a.getAttribute("data-path");
path = "patterns/" +
(a.getAttribute("data-core") == "true" ?
"core/" + path.substring(path.lastIndexOf("/") + 1) :
a.getAttribute("data-path"))
+ "/index.html";
const ASYNC = true;
let ajx = new XMLHttpRequest();
ajx.onreadystatechange = () => {
if (ajx.readyState == 4) {
switch (ajx.status) {
case 200:
a.innerHTML = a.innerHTML + ajx.responseText;
switch (a.getAttribute("data-template")) {
case "pug":
a.querySelectorAll("pre").forEach((aa) => {
aa.innerHTML = `<code class="${aa.getAttribute("class")}">${aa.innerHTML}</code>`;
})
break;
case "md":
a.querySelectorAll("code").forEach((aa) => {
aa.classList.add("language-html");
})
break;
}
const observer = new IntersectionObserver(articles => {
articles.forEach(article => {
let a = article.target;
a.querySelectorAll("code").forEach((c)=> {
c.classList.add("line-numbers");
c.innerHTML = c.innerHTML.replace(/</g, "&lt;");
c.classList.add("copy-to-clipboard-button");
})
if (typeof args.success == "function") args.success(a);
// console.log("observing: ", { id: a.getAttribute("id"), intersecting: a.isIntersecting } )
// if (article.intersectionRatio > 0) {
// console.log("Is interesecting: ", { id: article.target.getAttribute("id"), intersecting: article.isIntersecting, ratio: article.intersectionRatio } )
Prism.highlightAll();
if (article.isIntersecting == true) {
let path = a.getAttribute("data-path");
path = "patterns/" +
(a.getAttribute("data-core") == "true" ?
"core/" + path.substring(path.lastIndexOf("/") + 1) :
a.getAttribute("data-path"))
+ "/index.html";
const ASYNC = true;
let ajx = new XMLHttpRequest();
ajx.onreadystatechange = () => {
if (ajx.readyState == 4) {
observer.unobserve(article.target);
switch (ajx.status) {
case 200:
a.innerHTML = a.innerHTML + ajx.responseText;
a.style.height = "auto"
switch (a.getAttribute("data-template")) {
case "pug":
a.querySelectorAll("pre").forEach((aa) => {
aa.innerHTML = `<code class="${aa.getAttribute("class")}">${aa.innerHTML}</code>`;
})
break;
case "md":
a.querySelectorAll("code").forEach((aa) => {
aa.classList.add("language-html");
})
break;
}
a.querySelectorAll("code").forEach((c)=> {
c.onclick = (e) => {
oneClickSelect(e);
a.querySelectorAll("code").forEach((c)=> {
c.classList.add("line-numbers");
c.innerHTML = c.innerHTML.replace(/</g, "&lt;");
c.classList.add("copy-to-clipboard-button");
})
if (typeof args.success == "function") args.success(a);
Prism.highlightAll();
a.querySelectorAll("code").forEach((c)=> {
c.onclick = (e) => {
oneClickSelect(e);
}
})
module.exports.colour.positionTooltip();
window.onresize = () => {
module.exports.colour.positionTooltip();
}
a.querySelectorAll("name > span, color-pill > span").forEach((pill) => {
pill.onclick = (e) => {
e.preventDefault();
let w = "";
if (e.metaKey || e.ctrlKey || e.keyCode == 91 || e.keyCode == 224) {
w = "var";
} else if (e.altKey) {
w = "token"
} else if (e.shiftKey) {
w = "rgb";
} else {
w = "hex";
}
module.exports.colour.copy(w, pill);
}
})
break;
case 404:
if (typeof args.notFound == "function") args.notFound(a, path);
break;
default:
console.log("uncaught http error", { status: ajx.status, path: a.getAttribute("data-path") });
}
})
a.style.height = "auto";
if (typeof args.done == "function") args.done(a);
module.exports.colour.positionTooltip();
window.onresize = () => {
module.exports.colour.positionTooltip();
}
};
ajx.open("GET", path, ASYNC);
ajx.send();
a.querySelectorAll("name > span, color-pill > span").forEach((pill) => {
pill.onclick = (e) => {
e.preventDefault();
let w = "";
if (e.metaKey || e.ctrlKey || e.keyCode == 91 || e.keyCode == 224) {
w = "var";
} else if (e.altKey) {
w = "token"
} else if (e.shiftKey) {
w = "rgb";
} else {
w = "hex";
}
module.exports.colour.copy(w, pill);
}
})
break;
case 404:
if (typeof args.notFound == "function") args.notFound(a, path);
break;
default:
console.log("uncaught http error", { status: ajx.status, path: a.getAttribute("data-path") });
}
})
}, { threshold: 0, rootMargin: "100%" })
if (typeof args.done == "function") args.done(a);
observer.observe(a);
}
};
ajx.open("GET", path, ASYNC);
ajx.send();
} else {
a.style.height = "auto";
}
})
if (typeof args.afterArticleLoad == "function") args.afterArticleLoad(a);
if (typeof args.afterArticleLoad == "function") args.afterArticleLoad();
}
};
@@ -3168,11 +3202,17 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ init: function() { return /* binding */ init; }
/* harmony export */ });
/* DS2 core (c) 2024 Alexander McIlwraith
import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js";
tabs.init();
Released under Creative Commons Attribution-ShareAlike 4.0 International
*/
function init(p = document) {
// create a pure JS mouse click event
const click = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
});
function init(p = document, s = true) {
p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
if (tabGroup.querySelector("[role=tablist]") === null) {
@@ -3199,7 +3239,7 @@ function init(p = document) {
const ul = document.createElement('ul');
ul.setAttribute("role", "tablist");
ul.innerHTML = `${tablist}<li role="separator" class="separator"></li>`;
ul.innerHTML = s != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
tabGroup.insertBefore(ul, tabGroup.firstChild);
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
@@ -3215,8 +3255,15 @@ function init(p = document) {
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
document.getElementById(tabPanelId).classList.add("open");
});
tab.addEventListener("keypress", (e) => {
e.preventDefault();
if( e.which == 32 || e.which == 13 ) {
e.currentTarget.dispatchEvent(click);
}
})
});
}
});
}
@@ -3352,14 +3399,25 @@ _core_core_js__WEBPACK_IMPORTED_MODULE_0__.init({
}
});
// deprecated switch handler
const flipDeprecated = (e, s = e.currentTarget) => {
_core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/");
document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => {
a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated")
});
const flipInfoSwitch = (e, s = e.currentTarget) => {
switch(s.getAttribute("id")) {
case "deprecated" :
_core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/");
document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => {
a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated");
});
break;
case "breakpoints" :
console.log("here")
_core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.set("show-breakpoints", s.getAttribute("aria-checked"), 30, "/");
document.querySelector("html").classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-breakpoints");
break;
}
}
// create a pure JS mouse click event
@@ -3370,15 +3428,24 @@ const click = new MouseEvent('click', {
});
// get the switch, initialize it and add the handler
let switches = document.querySelector(".info-switches");
_pg_patterns_core_switch_switch_js__WEBPACK_IMPORTED_MODULE_8__.init(switches);
let deprecated = document.querySelector("#deprecated");
_pg_patterns_core_switch_switch_js__WEBPACK_IMPORTED_MODULE_8__.init(deprecated.parentNode)
deprecated.onclick = flipDeprecated;
deprecated.keypress = flipDeprecated;
let breakpoints = document.querySelector("#breakpoints");
deprecated.onclick = flipInfoSwitch;
deprecated.keypress = flipInfoSwitch;
breakpoints.onclick = flipInfoSwitch;
breakpoints.keypress = flipInfoSwitch;
// check a cookie to get the switch's state
if (_core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.get("show-deprecated") == "true") {
deprecated.dispatchEvent(click);
}
if (_core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.get("show-breakpoints") == "true") {
breakpoints.dispatchEvent(click);
}
// just for fun... We'll show deprecated if they match the path
// document.querySelector(`#${core.url.p.replace(/\//g, "-")}`).classList.add("show-deprecated");

File diff suppressed because one or more lines are too long

View File

@@ -38,52 +38,53 @@
<li><a href="./?p=status">Status</a></li>
</ul>
</nav>
<p class="deprecated-switch"><span></span><span id="deprecated" role="switch"></span>
<label for="deprecated">Show deprecated patterns</label>
<p class="info-switches"><span></span><span id="deprecated" role="switch"></span>
<label for="deprecated">Show deprecated patterns</label><span></span><span id="breakpoints" role="switch"></span>
<label for="breakpoints">Show breakpoint information</label>
</p>
<main id="main">
<h1>DS2 core</h1>
<article id="this-pattern-doesnt-exist" data-name="this pattern doesn't exist" data-status="deprecated" data-template="pug" data-core="false" data-path="this-pattern-doesnt-exist">
<article id="this-pattern-doesnt-exist" data-name="this pattern doesn't exist" data-status="deprecated" data-template="pug" data-core="false" data-path="this-pattern-doesnt-exist" style="height: 100vh">
<h1 class="status-deprecated"><span>This pattern doesn't exist
<tool-tip role="tooltip" inert="inert" tip-position="right">Deprecated</tool-tip></span></h1>
</article>
<article id="colours" data-name="colours" data-status="complete" data-template="pug" data-core="true" data-path="colours">
<article id="colours" data-name="colours" data-status="complete" data-template="pug" data-core="true" data-path="colours" style="height: 100vh">
<h1 class="status-complete"><span>Colours
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="components" data-name="components" data-status="complete" data-template="none" data-core="false" data-path="components">
<article id="components" data-name="components" data-status="complete" data-template="none" data-core="false" data-path="components" style="height: 100vh">
<h1 class="status-complete"><span>Components
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="components-sticky-note" data-name="sticky-note" data-status="complete" data-template="pug" data-core="true" data-path="components/sticky-note">
<article id="components-sticky-note" data-name="sticky-note" data-status="complete" data-template="pug" data-core="true" data-path="components/sticky-note" style="height: 100vh">
<h1 class="status-complete"><span>Sticky note
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="components-switch" data-name="switch" data-status="in-progress" data-template="pug" data-core="true" data-path="components/switch">
<h1 class="status-in-progress"><span>Switch
<tool-tip role="tooltip" inert="inert" tip-position="right">In progress</tool-tip></span></h1>
<article id="components-switch" data-name="switch" data-status="complete" data-template="pug" data-core="true" data-path="components/switch" style="height: 100vh">
<h1 class="status-complete"><span>Switch
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="components-tooltip" data-name="tooltip" data-status="in-progress" data-template="pug" data-core="true" data-path="components/tooltip">
<h1 class="status-in-progress"><span>Tooltip
<tool-tip role="tooltip" inert="inert" tip-position="right">In progress</tool-tip></span></h1>
<article id="components-tooltip" data-name="tooltip" data-status="complete" data-template="pug" data-core="true" data-path="components/tooltip" style="height: 100vh">
<h1 class="status-complete"><span>Tooltip
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="layouts" data-name="layouts" data-status="complete" data-template="none" data-core="true" data-path="layouts">
<article id="layouts" data-name="layouts" data-status="complete" data-template="none" data-core="true" data-path="layouts" style="height: 100vh">
<h1 class="status-complete"><span>Layouts
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="layouts-header" data-name="header" data-status="in-progress" data-template="pug" data-core="true" data-path="layouts/header">
<h1 class="status-in-progress"><span>Header
<tool-tip role="tooltip" inert="inert" tip-position="right">In progress</tool-tip></span></h1>
<article id="layouts-header" data-name="header" data-status="complete" data-template="pug" data-core="true" data-path="layouts/header" style="height: 100vh">
<h1 class="status-complete"><span>Header
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="layouts-breakpoints" data-name="breakpoints" data-status="in-progress" data-template="pug" data-core="true" data-path="layouts/breakpoints">
<h1 class="status-in-progress"><span>Breakpoints
<tool-tip role="tooltip" inert="inert" tip-position="right">In progress</tool-tip></span></h1>
<article id="layouts-breakpoints" data-name="breakpoints" data-status="complete" data-template="pug" data-core="true" data-path="layouts/breakpoints" style="height: 100vh">
<h1 class="status-complete"><span>Breakpoints
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="layouts-tabs" data-name="tabs" data-status="in-progress" data-template="pug" data-core="true" data-path="layouts/tabs">
<h1 class="status-in-progress"><span>Tabs
<tool-tip role="tooltip" inert="inert" tip-position="right">In progress</tool-tip></span></h1>
<article id="layouts-tabs" data-name="tabs" data-status="complete" data-template="pug" data-core="true" data-path="layouts/tabs" style="height: 100vh">
<h1 class="status-complete"><span>Tabs
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>
<article id="status" data-name="status" data-status="complete" data-template="pug" data-core="true" data-path="status">
<article id="status" data-name="status" data-status="complete" data-template="pug" data-core="true" data-path="status" style="height: 100vh">
<h1 class="status-complete"><span>Status
<tool-tip role="tooltip" inert="inert" tip-position="right">Complete</tool-tip></span></h1>
</article>

View File

@@ -5,14 +5,24 @@
</head>
<body data-prismjs-copy-timeout="1500">
<h2>What is it</h2>
<p>Breakpoints enable responsive mobile design.</p>
<h2>When to use it</h2>
<p>Use breakpoints when designing for different screen sizes. </p>
<p>The breakpoints SCSS mixin included implements media queries to allow for the change of the layout and design based on pre-defined screen sizes. </p>
<h2>How to use it</h2>
<p>This pattern is only available for SCSS breakpoints. The mixin is avai</p>
<p>When using this, use the default break points as they are set to the same as the Bootstrap framework. The grid for the design system at large break point has been widened to accompdate 3 colour cards across. </p>
<div class="tab-group" id="breakpoints">
<pre class="language-css" data-tab="scss">//- DS2 core (c) 2024 Alexander McIlwraith
<tabset id="breakpoints">
<div tab="scss">
<pre class="language-sass">@import "[path-to]/breakpoints";
@include break([breakpoint]) {
// css here
}</pre>
<pre class="language-sass">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
$grid-breakpoints: ( xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px ) !default;
// default breakpoints match bootstrap 5 breakpoints.
$grid-breakpoints: ( xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px ) !default;
@mixin breakpoint-debug {
body::before, body::after {
@@ -95,6 +105,7 @@ $grid-breakpoints: ( xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px ) !defau
}
}
}</pre>
</div>
</div>
</tabset>
</body>
</html>

View File

@@ -5,10 +5,13 @@
</head>
<body data-prismjs-copy-timeout="1500">
<h2>What is it</h2>
<p>A header is layout pattern that helps the user identify the site. </p>
<h2>When to use it</h2>
<p>Use a header at the top of every page. The 'front page' of a site may have a different header than the rest of the pages. </p>
<h2>How to use it</h2>
<div class="tab-group" id="header">
<pre class="language-html" data-tab="html">
<p>Place the header at the top of the page after the skip to main content link. You will likely want to replace core header should be replaced with your own site's header. To do this, remove the <code class="inline language-js">core: true </code> and create your own pattern in the location you wish it in your design system. </p>
<tabset id="header">
<pre class="language-html" tab="html">
<!-- create temp variables and store the design system values-->
<header>
<!-- The headline banner area -->
@@ -22,7 +25,28 @@
<!-- Other sections can go here, such as search and directory-->
</div>
</header></pre>
<pre class="language-sass" data-tab="scss">//- DS2 core (c) 2024 Alexander McIlwraith
<pre class="language-pug" tab="pug">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
//- required variables
//- site - the site name that goes in the site title
//- root - the path to the root of the site
header
// The headline banner area
svg(height='5.5rem' width='100%' xmlns='http://www.w3.org/2000/svg' aria-hidden='true')
text= site
div
div.header-title
h1
a(href="./")= site
// Other sections can go here, such as search and directory
</pre>
<pre class="language-css" tab="css">header{display:-ms-grid;display:grid;-ms-grid-rows:1.75rem 3.5rem;grid-template-rows:1.75rem 3.5rem;-ms-grid-column:2;-ms-grid-column-span:2;grid-column:2/4;overflow:hidden}header svg{grid-column:1/-1;grid-row:1/-1;-ms-grid-row-align:stretch;-ms-grid-column-align:stretch;place-self:stretch}header svg text{-webkit-transform:translate(-1rem,7.25rem);-ms-transform:translate(-1rem,7.25rem);transform:translate(-1rem,7.25rem);font-size:10rem;font-weight:1000;font-family:sans-serif;fill:var(--colour-grey-xxl)}header>div{-ms-grid-row:2;grid-row:2;grid-column:1/-1;display:-ms-grid;display:grid;grid-column-gap:1rem;-ms-grid-columns:auto -webkit-max-content -webkit-max-content;-ms-grid-columns:auto max-content max-content;grid-template-columns:auto -webkit-max-content -webkit-max-content;grid-template-columns:auto max-content max-content}header>div .header-title h1{margin:0;padding:0 1rem}header>div .header-title h1 a,header>div .header-title h1 a:visited{border-bottom:none;color:var(--colour-black);font-family:sans-serif;font-size:2.5rem;font-size:32px;font-weight:700;margin:0;padding:0;text-decoration:none}</pre>
<div class="language-sass" tab="scss">
<pre class="language-sass">@import "scss/core/header/header;
</pre>
<pre class="language-sass">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
$header-bg-color: var(--colour-grey-xxl) !default;
@@ -76,59 +100,7 @@ $font-weight: 700 !default;
}
}
}</pre>
<pre class="language-css" data-tab="css">header {
display: -ms-grid;
display: grid;
-ms-grid-rows: 1.75rem 3.5rem;
grid-template-rows: 1.75rem 3.5rem;
-ms-grid-column: 2;
-ms-grid-column-span: 2;
grid-column: 2/4;
overflow: hidden;
}
header svg {
grid-column: 1/-1;
grid-row: 1/-1;
-ms-grid-row-align: stretch;
-ms-grid-column-align: stretch;
place-self: stretch;
}
header svg text {
-webkit-transform: translate(-1rem, 7.25rem);
-ms-transform: translate(-1rem, 7.25rem);
transform: translate(-1rem, 7.25rem);
font-size: 10rem;
font-weight: 1000;
font-family: sans-serif;
fill: var(--colour-grey-xxl);
}
header > div {
-ms-grid-row: 2;
grid-row: 2;
grid-column: 1/-1;
display: -ms-grid;
display: grid;
grid-column-gap: 1rem;
-ms-grid-columns: auto -webkit-max-content -webkit-max-content;
-ms-grid-columns: auto max-content max-content;
grid-template-columns: auto -webkit-max-content -webkit-max-content;
grid-template-columns: auto max-content max-content;
}
header > div .header-title h1 {
margin: 0;
padding: 0 1rem;
}
header > div .header-title h1 a, header > div .header-title h1 a:visited {
border-bottom: none;
color: var(--colour-black);
font-family: sans-serif;
font-size: 2.5rem;
font-size: 32px;
font-weight: 700;
margin: 0;
padding: 0;
text-decoration: none;
}</pre>
</div>
</div>
</tabset>
</body>
</html>

View File

@@ -34,11 +34,11 @@
</tr>
<tr>
<td><a href="./?p=components/switch"> Switch</a></td>
<td><span class="status-in-progress">In progress</span></td>
<td><span class="status-complete">Complete</span></td>
</tr>
<tr>
<td><a href="./?p=components/tooltip"> Tooltip</a></td>
<td><span class="status-in-progress">In progress</span></td>
<td><span class="status-complete">Complete</span></td>
</tr>
</tr>
<tr>
@@ -49,15 +49,15 @@
<td><span class="status-complete">Complete</span></td>
<tr>
<td><a href="./?p=layouts/header"> Header</a></td>
<td><span class="status-in-progress">In progress</span></td>
<td><span class="status-complete">Complete</span></td>
</tr>
<tr>
<td><a href="./?p=layouts/breakpoints"> Breakpoints</a></td>
<td><span class="status-in-progress">In progress</span></td>
<td><span class="status-complete">Complete</span></td>
</tr>
<tr>
<td><a href="./?p=layouts/tabs"> Tabs</a></td>
<td><span class="status-in-progress">In progress</span></td>
<td><span class="status-complete">Complete</span></td>
</tr>
</tr>
<tr>
@@ -77,31 +77,15 @@
<td colspan="2"><span class="status-not-started">Not started (0)</span></td>
</tr>
<tr>
<td colspan="2"><span class="status-in-progress">In progress (5)</span></td>
<td colspan="2"><span class="status-in-progress">In progress (0)</span></td>
</tr>
<tr>
<td colspan="2"><span class="status-complete">Complete (10)</span></td>
</tr>
<tr>
<td> <a href="./?p=layouts/breakpoints">Breakpoints</a></td>
<td>Layouts</td>
</tr>
<tr>
<td> <a href="./?p=layouts/header">Header</a></td>
<td>Layouts</td>
</tr>
<tr>
<td> <a href="./?p=components/switch">Switch</a></td>
<td>Components</td>
</tr>
<tr>
<td> <a href="./?p=layouts/tabs">Tabs</a></td>
<td>Layouts</td>
</tr>
<tr>
<td> <a href="./?p=components/tooltip">Tooltip</a></td>
<td>Components</td>
</tr>
<tr>
<td colspan="2"><span class="status-complete">Complete (5)</span></td>
</tr>
<tr>
<td> <a href="./?p=colours">Colours</a></td>
<td></td>
@@ -110,6 +94,10 @@
<td> <a href="./?p=components">Components</a></td>
<td></td>
</tr>
<tr>
<td> <a href="./?p=layouts/header">Header</a></td>
<td>Layouts</td>
</tr>
<tr>
<td> <a href="./?p=layouts">Layouts</a></td>
<td></td>
@@ -122,6 +110,18 @@
<td> <a href="./?p=components/sticky-note">Sticky note</a></td>
<td>Components</td>
</tr>
<tr>
<td> <a href="./?p=components/switch">Switch</a></td>
<td>Components</td>
</tr>
<tr>
<td> <a href="./?p=layouts/tabs">Tabs</a></td>
<td>Layouts</td>
</tr>
<tr>
<td> <a href="./?p=components/tooltip">Tooltip</a></td>
<td>Components</td>
</tr>
<tr>
<td colspan="2"><span class="status-deprecated">Deprecated (1)</span></td>
</tr>
@@ -137,7 +137,7 @@
<tbody>
<tr>
<td> <a href="./?p=layouts/breakpoints">Breakpoints</a></td>
<td><span><span class="status-in-progress">In Progress</span></span></td>
<td><span><span class="status-complete">Complete</span></span></td>
<td>Layouts</td>
</tr>
<tr>
@@ -152,7 +152,7 @@
</tr>
<tr>
<td> <a href="./?p=layouts/header">Header</a></td>
<td><span><span class="status-in-progress">In Progress</span></span></td>
<td><span><span class="status-complete">Complete</span></span></td>
<td>Layouts</td>
</tr>
<tr>
@@ -172,12 +172,12 @@
</tr>
<tr>
<td> <a href="./?p=components/switch">Switch</a></td>
<td><span><span class="status-in-progress">In Progress</span></span></td>
<td><span><span class="status-complete">Complete</span></span></td>
<td>Components</td>
</tr>
<tr>
<td> <a href="./?p=layouts/tabs">Tabs</a></td>
<td><span><span class="status-in-progress">In Progress</span></span></td>
<td><span><span class="status-complete">Complete</span></span></td>
<td>Layouts</td>
</tr>
<tr>
@@ -187,7 +187,7 @@
</tr>
<tr>
<td> <a href="./?p=components/tooltip">Tooltip</a></td>
<td><span><span class="status-in-progress">In Progress</span></span></td>
<td><span><span class="status-complete">Complete</span></span></td>
<td>Components</td>
</tr>
</tbody>

View File

@@ -9,143 +9,23 @@
<h2>When to use it</h2>
<p>Use a sticky when you want to make a note without adding it to the content. </p>
<h2>How to use it</h2>
<p>Uses absolute positioning.
<sticky-note class="blue" float="right">This <strong>is</strong> a sample sticky. You can drag it out of the way if you need to see the content under it.</sticky-note>
<p>Uses absolute positioning. Passing an optional element to the init function will initialise tabs within that element. You can move the position using either <code class="language-html inline">float="&#91; right | left &#93;"</code> or <code class="language-html inline">offset="&#91; top | left &#93;"</code>. Offset will take negative values in any web measurement unit.
<sticky-note class="blue" offset="-10rem 1rem">This <strong>is</strong> a sample sticky. You can drag it out of the way if you need to see the content under it.</sticky-note>
<sticky-note float="right">You will notice when you hover over the sticky, it shows a dot in the colour of the sticky in the position where the sticky note refers to (assuming you haven't dragged it and scrolled that location off the screen).</sticky-note>
</p>
<p>If you wish to create a custom element, that extends another HTML element, the native element has to be extended in customElements.define(). Custom elements that inherit native elements are also known as "type extension custom elements". </p>
<sticky-note>You will notice when you hover over the sticky, it shows a dot in the colour of the sticky in the position where the sticky note refers to (assuming you haven't dragged it and scrolled that location off the screen).</sticky-note>
<tabset id="sticky-note">
<pre class="language-html" tab="html">
<sticky-note class="blue" float="right">This <strong>is</strong> a sample sticky. You can drag it out of the way if you need to see the content under it.</sticky-note></pre>
<pre class="language-pug" tab="pug">sticky-note(float="right").blue This <strong>is</strong> a sample sticky.
<pre class="language-pug" tab="pug">sticky-note(float="right").blue This #[strong is] a sample sticky.
| You can drag it out of the way if you need to see the content under it.</pre>
<pre class="language-css" data-tab="css"> @import url("https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap");
sticky-note-wrapper {
-webkit-box-sizing: border-box;
box-sizing: border-box;
border: 1px solid transparent;
border-radius: 50%;
display: inline-block;
height: 0.5rem;
position: relative;
width: 0.5rem;
}
sticky-note-wrapper * {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
sticky-note-wrapper sticky-note {
cursor: -webkit-grab;
cursor: grab;
display: -ms-grid;
display: grid;
float: left;
font-size: 1rem;
height: 13rem;
left: 0;
place-items: stretch;
position: absolute;
top: 0;
width: 13rem;
z-index: 100;
}
sticky-note-wrapper sticky-note:active {
cursor: -webkit-grabbing;
cursor: grabbing;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
sticky-note-wrapper sticky-note.right {
float: right;
}
sticky-note-wrapper sticky-note > div {
-ms-grid-row: 1;
grid-row: 1;
-ms-grid-column: 1;
grid-column: 1;
}
sticky-note-wrapper sticky-note > div:nth-child(1) {
background-color: rgba(0, 0, 0, 0.25);
-webkit-box-shadow: -2px 2px 15px 0 rgba(0, 0, 0, 0.5);
box-shadow: -2px 2px 15px 0 rgba(0, 0, 0, 0.5);
display: -ms-grid;
display: grid;
margin: 2rem 1rem 0.25rem 0.36rem;
width: calc(100% - 1rem);
}
sticky-note-wrapper sticky-note > div:nth-child(2) {
clip-path: url(#stickyClip);
display: -ms-grid;
display: grid;
font-family: "Kalam", cursive;
font-style: 1rem;
font-weight: 300;
line-height: 1.25rem;
padding: 1rem;
place-items: center;
text-align: center;
}
sticky-note-wrapper sticky-note > div:nth-child(2) > * {
font-family: "Kalam", cursive !important;
font-style: normal !important;
font-weight: 300 !important;
}
@media screen and (max-width: 1024px) {
sticky-note-wrapper sticky-note > div:nth-child(2) {
max-width: 13rem;
min-width: 13rem;
width: 1rem;
}
}
@media screen and (max-width: 768px) {
sticky-note-wrapper sticky-note > div:nth-child(2) {
font-size: 1.75rem;
max-width: 21rem;
min-height: 21rem;
}
}
@media screen and (max-width: 640px) {
sticky-note-wrapper sticky-note > div:nth-child(2) {
font-size: 2.5rem;
max-width: 26rem;
min-height: 26rem;
}
}
sticky-note-wrapper sticky-note > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#ffffdd), color-stop(2%, #ffffd3), color-stop(12%, #ffffd3), color-stop(75%, #ffffc9), to(#ffffba));
background: linear-gradient(180deg, #ffffdd 0%, #ffffd3 2%, #ffffd3 12%, #ffffc9 75%, #ffffba 100%);
}
sticky-note-wrapper sticky-note.blue > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#9dddec), color-stop(2%, #94daea), color-stop(12%, #94daea), color-stop(75%, #8bd7e8), to(#7fd3e6));
background: linear-gradient(180deg, #9dddec 0%, #94daea 2%, #94daea 12%, #8bd7e8 75%, #7fd3e6 100%);
}
sticky-note-wrapper sticky-note.pink > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#fa7c93), color-stop(2%, #fa728b), color-stop(12%, #fa728b), color-stop(75%, #fa6883), to(#f95977));
background: linear-gradient(180deg, #fa7c93 0%, #fa728b 2%, #fa728b 12%, #fa6883 75%, #f95977 100%);
}
sticky-note-wrapper sticky-note.green > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#c5fcc9), color-stop(2%, #bbfbc0), color-stop(12%, #bbfbc0), color-stop(75%, #b1fab7), to(#a3faaa));
background: linear-gradient(180deg, #c5fcc9 0%, #bbfbc0 2%, #bbfbc0 12%, #b1fab7 75%, #a3faaa 100%);
}
sticky-note-wrapper:has(sticky-note:hover) {
background-color: #ffffd3;
border: 1px solid black;
}
sticky-note-wrapper:has(sticky-note.yellow:hover) {
background-color: #ffffd3;
}
sticky-note-wrapper:has(sticky-note.blue:hover) {
background-color: #94daea;
}
sticky-note-wrapper:has(sticky-note.pink:hover) {
background-color: #fa728b;
}
sticky-note-wrapper:has(sticky-note.green:hover) {
background-color: #bbfbc0;
}</pre>
<pre class="language-css" data-tab="scss"> //- DS2 core (c) 2024 Alexander McIlwraith
<pre class="language-css" data-tab="css"> @import url("https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap");sticky-note-wrapper{-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid transparent;border-radius:50%;display:inline-block;height:0.5rem;position:relative;width:0.5rem}sticky-note-wrapper *{-webkit-box-sizing:border-box;box-sizing:border-box}sticky-note-wrapper sticky-note{cursor:-webkit-grab;cursor:grab;display:-ms-grid;display:grid;float:left;font-size:1rem;height:13rem;left:0;place-items:stretch;position:absolute;top:0;width:13rem;z-index:100}sticky-note-wrapper sticky-note:active{cursor:-webkit-grabbing;cursor:grabbing;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}sticky-note-wrapper sticky-note.right{float:right}sticky-note-wrapper sticky-note>div{-ms-grid-row:1;grid-row:1;-ms-grid-column:1;grid-column:1}sticky-note-wrapper sticky-note>div:first-child{background-color:rgba(0,0,0,0.25);-webkit-box-shadow:-2px 2px 15px 0 rgba(0,0,0,0.5);box-shadow:-2px 2px 15px 0 rgba(0,0,0,0.5);display:-ms-grid;display:grid;margin:2rem 1rem 0.25rem 0.36rem;width:calc(100% - 1rem)}sticky-note-wrapper sticky-note>div:nth-child(2){clip-path:url(#stickyClip);display:-ms-grid;display:grid;font-family:"Kalam",cursive;font-style:1rem;font-weight:300;line-height:1.25rem;padding:1rem;place-items:center;text-align:center}sticky-note-wrapper sticky-note>div:nth-child(2)>*{font-family:"Kalam",cursive!important;font-style:normal!important;font-weight:300!important}@media screen and (max-width:1024px){sticky-note-wrapper sticky-note>div:nth-child(2){max-width:13rem;min-width:13rem;width:1rem}}@media screen and (max-width:768px){sticky-note-wrapper sticky-note>div:nth-child(2){font-size:1.75rem;max-width:21rem;min-height:21rem}}@media screen and (max-width:640px){sticky-note-wrapper sticky-note>div:nth-child(2){font-size:2.5rem;max-width:26rem;min-height:26rem}}sticky-note-wrapper sticky-note>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#ffffdd),color-stop(2%,#ffffd3),color-stop(12%,#ffffd3),color-stop(75%,#ffffc9),to(#ffffba));background:linear-gradient(180deg,#ffffdd 0%,#ffffd3 2%,#ffffd3 12%,#ffffc9 75%,#ffffba 100%)}sticky-note-wrapper sticky-note.blue>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#9dddec),color-stop(2%,#94daea),color-stop(12%,#94daea),color-stop(75%,#8bd7e8),to(#7fd3e6));background:linear-gradient(180deg,#9dddec 0%,#94daea 2%,#94daea 12%,#8bd7e8 75%,#7fd3e6 100%)}sticky-note-wrapper sticky-note.pink>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#fa7c93),color-stop(2%,#fa728b),color-stop(12%,#fa728b),color-stop(75%,#fa6883),to(#f95977));background:linear-gradient(180deg,#fa7c93 0%,#fa728b 2%,#fa728b 12%,#fa6883 75%,#f95977 100%)}sticky-note-wrapper sticky-note.green>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#c5fcc9),color-stop(2%,#bbfbc0),color-stop(12%,#bbfbc0),color-stop(75%,#b1fab7),to(#a3faaa));background:linear-gradient(180deg,#c5fcc9 0%,#bbfbc0 2%,#bbfbc0 12%,#b1fab7 75%,#a3faaa 100%)}sticky-note-wrapper:has(sticky-note:hover){background-color:#ffffd3;border:1px solid black}sticky-note-wrapper:has(sticky-note.yellow:hover){background-color:#ffffd3}sticky-note-wrapper:has(sticky-note.blue:hover){background-color:#94daea}sticky-note-wrapper:has(sticky-note.pink:hover){background-color:#fa728b}sticky-note-wrapper:has(sticky-note.green:hover){background-color:#bbfbc0}</pre>
<div tab="scss">
<pre class="language-sass">$sticky-colors: ( [sass map with your own defined colours] );
@import "scss/core/switch/_sticky-note";
@include sticky-note;
</pre>
<pre class="language-sass">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
@use 'sass:color';
@@ -297,7 +177,12 @@ $sticky-colors: (
}
}
}</pre>
<pre class="language-js" data-tab="js"> //- DS2 core (c) 2024 Alexander McIlwraith
</div>
<div tab="js">
<pre class="language-js">import * as stickynote from ""./js/core/sticky-note/_sticky-note.js";
stickynote.init()
</pre>
<pre class="language-js">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
const font = {
@@ -428,6 +313,7 @@ export function init(p = document){
});
}
}</pre>
</div>
</tabset>
</body>
</html>

View File

@@ -5,50 +5,32 @@
</head>
<body data-prismjs-copy-timeout="1500">
<h2>What is it</h2>
<p>Switches are used to toggle application state between two mutually exlusive values. </p>
<p>Switches are used to toggle application state between two mutually exclusive values. </p>
<h2>When to use it</h2>
<p>Use a switch when the user will see an immediate visible state change. Do not use a switch when the state change will affect future results. The user should not have to perform another action (search, save, etc) for the result to take affect. If the change in state does not take effect immediately, consider a checkbox. </p>
<h2>How to use it</h2>
<p>The switch label should describe what will happen when the switch is turned to the on state. Frontload labels with keywords. </p>
<p>Include the CSS and JavaScript. An additional handler will need to be created for the actual state change. The CSS implements the visual design of the switch, which is based on the accessibility properties, which are implemented by the JavaScript.</p>
<h2>Example</h2>
<p class="switch">
<label for="example-switch">Switch label</label><span id="example-switch" role="switch"></span>
<label for="example-switch">Switch label (states the on state)</label><span id="example-switch" role="switch"></span>
</p>
<div class="tab-group" id="switches">
<pre class="language-html" data-tab="html"><span id="example-id" role="switch"></span></pre>
<pre class="language-pug" data-tab="pug">span#example-id(role="switch")</pre>
<pre class="language-css" data-tab="css">[role=switch] {
display: -ms-inline-grid;
display: inline-grid;
border: 1px solid var(--colour-blue);
background-color: var(--colour-grey-xl);
border-radius: 0.75rem;
height: 1.5rem;
width: 3rem;
-webkit-transition: all 500ms;
transition: all 500ms;
}
[role=switch] > span {
display: inline-block;
background-color: white;
border-radius: 50%;
margin: 2%;
width: calc(1.5rem - 2%);
-webkit-transition: all 500ms;
transition: all 500ms;
}
[role=switch][aria-checked=true] {
background-color: var(--colour-blue);
}
[role=switch][aria-checked=true] > span {
margin-left: calc(1.5rem - 5%);
}</pre>
<pre class="language-css" data-tab="scss">//- DS2 core (c) 2024 Alexander McIlwraith
<pre class="language-html" tab="html"><span id="example-id" role="switch"></span></pre>
<pre class="language-pug" tab="pug">span#example-id(role="switch")</pre>
<pre class="language-css" tab="css">[role=switch]{display:-ms-inline-grid;display:inline-grid;border:1px solid #2e51a1;background-color:#d8d8d8;border-radius:0.75rem;height:1.5rem;width:3rem;-webkit-transition:all 500ms;transition:all 500ms}[role=switch]>span{display:inline-block;background-color:white;border-radius:50%;margin:2%;width:calc(1.5rem - 2%);-webkit-transition:all 500ms;transition:all 500ms}[role=switch][aria-checked=true]{background-color:#2e51a1}[role=switch][aria-checked=true]>span{margin-left:calc(1.5rem - 5%)}</pre>
<div tab="scss">
<pre class="language-sass">@import "scss/core/switch/_switch";
@include switch;
</pre>
<pre class="language-sass">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
@use "sass:math";
$switch-accent: var(--colour-blue) !default; // switch background when switched right (on/ true)
$switch-background: var(--colour-grey-xl) !default; // switch background when switched left (off / false)
$switch-color: var(--colour-white) !default; // the colour of the switch
$switch-accent: #2e51a1 !default; // switch background when switched right (on/ true)
$switch-background: #d8d8d8 !default; // switch background when switched left (off / false)
$switch-color: white !default; // the colour of the switch
$switch-height: 1.5rem !default;
@mixin switch {
@@ -77,7 +59,13 @@ $switch-height: 1.5rem !default;
}
}
}</pre>
<pre class="language-js" data-tab="js">//- DS2 core (c) 2024 Alexander McIlwraith
</div>
<div tab="js">
<pre class="language-js">// Note that switch is a reserved word.
import * as swtch from "./js/core/switch/_switch.js";
swtch.init();
</pre>
<pre class="language-js">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
function flip(e) {
@@ -104,6 +92,7 @@ module.exports = {
}
}
</pre>
</div>
</div>
</body>
</html>

View File

@@ -5,8 +5,8 @@
</head>
<body data-prismjs-copy-timeout="1500">
<h2>What is it</h2>
<p>A tabs component that provides different sections of content that are displayed one at a time when the user selects that information. </p>
<h2>When to use it</h2>
<h2>How to use it</h2>
<p>The tabbed user interface enables users to jump to their target section quickly. Tabs present like logically group information on the same page. Information should </p>
<ul>
<li>be logically chunked and ordered</li>
@@ -15,13 +15,18 @@
<li>obvious where they begin and end </li>
</ul>
<p>Users should not need to see content of multiple tabs simultaneously and the user should be able to easily recognise where they are within the content. </p>
<p>The tab module can be initialised by importing a file with the javascript module using import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js"; contains a modularized version of the jQuery code, so that it can be called on demand. It is what is used in the design system so that the JavaScript can be called at run time (after loading content).</p>
<h2>How to use it</h2>
<p>The structure of the tab set is defined in html. There are two forms supported. Adding a class of <code class="inline">.tab-group</code> to the container element will work in place of the <code class="inline">tabset</code> tag, and the tab panels can be defined using either <code class="inline">tab=""</code> or <code class="inline">data-tab=""</code>. Passing an optional element to the init function will initialise tabs within that element. </p>
<tabset id="tabs">
<pre class="language-html" tab="html">
<div class="tab-group" id="uniqueID">
<div data-tab="[tab title]"></div>
<div data-tab="[tab title]"></div>
</div></pre>
<tabset id="uniqueID">
<div tab="[tab title]"></div>
<div tab="[tab title]"></div>
</tabset></pre>
<pre class="language-pug" tab="pug">tabset#uniqueID
div(tab="[tab title]")
div(tab="[tab title]")
</pre>
<pre class="language-css" tab="css">tabset, .tab-group {
margin: 2rem 0 1rem 0;
}
@@ -33,8 +38,8 @@ tabset > ul, .tab-group > ul {
padding: 0;
}
tabset > ul li.separator, .tab-group > ul li.separator {
border-bottom: 1px solid var(--colour-grey);
border-left: 1px solid var(--colour-grey);
border-bottom: 1px solid #7f7f7f;
border-left: 1px solid #7f7f7f;
display: inline-block;
margin: 0.45rem 0 0 0;
width: 100%;
@@ -43,9 +48,9 @@ tabset .tab-hidden, .tab-group .tab-hidden {
display: none;
}
tabset [role=tab], .tab-group [role=tab] {
background-color: var(--colour-white);
border-left: 1px solid var(--colour-grey);
border-top: 1px solid var(--colour-grey);
background-color: #FFF;
border-left: 1px solid #7f7f7f;
border-top: 1px solid #7f7f7f;
border-radius: 0.5rem 0.5rem 0 0;
cursor: pointer;
margin: 0;
@@ -54,19 +59,19 @@ tabset [role=tab], .tab-group [role=tab] {
z-index: 2;
}
tabset [role=tab]:last-of-type, .tab-group [role=tab]:last-of-type {
border-right: 1px solid var(--colour-grey);
border-right: 1px solid #7f7f7f;
}
tabset [role=tab]:not(.selected), .tab-group [role=tab]:not(.selected) {
background-color: var(--colour-grey-xxl);
border-bottom: 1px solid var(--colour-grey);
background-color: #f0f0f0;
border-bottom: 1px solid #7f7f7f;
}
tabset [role=tab] span, .tab-group [role=tab] span {
display: block;
margin: 0 0 0.5rem 0;
}
tabset [role=tabpanel], .tab-group [role=tabpanel] {
background-color: var(--colour-white);
border: 1px solid var(--colour-grey);
background-color: #FFF;
border: 1px solid #7f7f7f;
border-top: none;
padding: 1rem;
z-index: 1;
@@ -74,12 +79,18 @@ tabset [role=tabpanel], .tab-group [role=tabpanel] {
tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
display: none;
}</pre>
<pre class="language-css" tab="scss">// DS2 core (c) 2024 Alexander McIlwraith
<div tab="scss">
<pre class="language-sass">@import "scss/core/tabs/_tabs";
@include tabs{
// optional content block
};
</pre>
<pre class="language-sass">// DS2 core (c) 2024 Alexander McIlwraith
// Licensed under CC BY-SA 4.0
$tab-border: var(--colour-grey) !default;
$tab-selected: var(--colour-white) !default;
$tab-notselected: var(--colour-grey-xxl) !default;
$tab-border: #7f7f7f !default;
$tab-selected: #FFF !default;
$tab-notselected: #f0f0f0 !default;
@mixin tabs {
tabset, .tab-group {
@@ -143,12 +154,22 @@ $tab-notselected: var(--colour-grey-xxl) !default;
}
}
}</pre>
<pre class="language-css" tab="js">/* DS2 core (c) 2024 Alexander McIlwraith
import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js";
tabs.init();
</div>
<div tab="js">
<pre class="language-js">import * as tabs from "./js/core/tabs/_tabs.js";
tabs.init();</pre>
<pre class="language-js">/* DS2 core (c) 2024 Alexander McIlwraith
Released under Creative Commons Attribution-ShareAlike 4.0 International
*/
export function init(p = document) {
// create a pure JS mouse click event
const click = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
});
export function init(p = document, s = true) {
p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
if (tabGroup.querySelector("[role=tablist]") === null) {
@@ -175,7 +196,7 @@ export function init(p = document) {
const ul = document.createElement('ul');
ul.setAttribute("role", "tablist");
ul.innerHTML = `${tablist}<li role="separator" class="separator"></li>`;
ul.innerHTML = s != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
tabGroup.insertBefore(ul, tabGroup.firstChild);
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
@@ -191,12 +212,20 @@ export function init(p = document) {
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
document.getElementById(tabPanelId).classList.add("open");
});
tab.addEventListener("keypress", (e) => {
e.preventDefault();
if( e.which == 32 || e.which == 13 ) {
e.currentTarget.dispatchEvent(click);
}
})
});
}
});
}
</pre>
</div>
</tabset>
</body>
</html>

View File

@@ -5,9 +5,15 @@
</head>
<body data-prismjs-copy-timeout="1500">
<h2>What is it</h2>
<p>Tooltips provide brief information messaging through a mouse or keyboard hover. </p>
<h2>When to use it</h2>
<p>Use tool tips to provide additional information. Don't use tooltips for that is required to complete an interaction as the information disappears when it loses the hover state. </p>
<p>Use tooltips to help differentiate between multiple, close, similar options. </p>
<h2>How to use it</h2>
<p>Either form works. Place this inside another element for the tooltip to be "linked to that element."</p>
<p class="notification-box info">Currently, there is no easy way to activate a hover without with pure CSS without using a keyboard or mouse. Level4 media queries aim to solve that.</p>
<p>Either form works.
<sticky-note class="blue">"Either form works": What are the two forms.</sticky-note>Place the <code class="language-html inline">tooltip</code> inside another element for the tooltip to be 'linked to that element.' A container element may need to be added for a single tag element, such as a input field.
</p>
<p>Tool tip positions are: </p>
<ul>
<li>top / block-start</li>
@@ -15,16 +21,12 @@
<li>bottom / block-end</li>
<li>left / inline-start</li>
</ul>
<div class="tab-group" id="tooltip">
<pre class="language-html" data-tab="html"><a href="#">Link with a tool tip
<div role="tooltip" inert="inert" tip-position="bottom">Tool tip content</div></a><a href="#">Link with a tool tip
<tool-tip role="tooltip" inert="inert" tip-position="bottom">Tool tip content</tool-tip></a></pre>
<pre class="language-pug" data-tab="pug">a(href="#") Link with a tool tip
div(role="tooltip" inert tip-position="bottom") Tool tip content
a(href="#") Link with a tool tip
tool-tip(role="tooltip" inert tip-position="bottom") Tool tip content</pre>
<pre class="language-css" data-tab="css">/* Position Options
<p><a href="#">Link with a tool tip<span role="tooltip" inert="inert" tip-position="right">Tool tip content</span></a></p>
<tabset id="tooltip">
<pre class="language-html" tab="html"><a href="#">Link with a tool tip<span role="tooltip" inert="inert" tip-position="right">Tool tip content</span></a></pre>
<pre class="language-pug" tab="pug">a(href="#") Link with a tool tip
span(role="tooltip" inert tip-position="right") Tool tip content</pre>
<pre class="language-css" tab="css">/* Position Options
- top / block-start
- right / inline-end
- bottom / block-end
@@ -179,7 +181,10 @@ a(href="#") Link with a tool tip
--tooltip-x: calc(-1 * 3px * -1);
}
}</pre>
<pre class="language-css" data-tab="scss">//- DS2 core (c) 2024 Alexander McIlwraith
<div tab="scss">
<pre class="language-sass">@import "scss/core/tooltip/_tooltip";
@include tooltip;</pre>
<pre class="language-sass">//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
$tooltip-border-radius: .5rem !default;
@@ -356,6 +361,7 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
}
}</pre>
</div>
</div>
</tabset>
</body>
</html>

View File

@@ -102,7 +102,19 @@ const getURLVars = () => {
}
module.exports = {
url: getURLVars(),
url: (() => {
var v = {};
if (location.search.length > 0) {
var qs = (location.search.substr(1)).split("&");
for (var i = 0; i < qs.length; i++) {
var t = qs[i].split("=");
if (t[1].length > 0) {
v[t[0]] = decodeURIComponent(t[1].replace(/\+/g, '%20'));
}
}
}
return v;
})(),
cookie: {
set: (name, value, expires, path, domain, secure) => {
switch(typeof expires) {
@@ -166,6 +178,9 @@ module.exports = {
})
}
},
// getCSS: (el, prop, b = false) {
// return window.getComputedStyle(el, null).getPropertyValue(prop);
// },
init: (args = {}) => {
const url = getURLVars();
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
@@ -177,7 +192,11 @@ module.exports = {
if (url.p == -1) {
document.querySelector("title").innerHTML = `${url.p.toContent().toTitleCase()} | ${ document.querySelector("title").getAttribute("data-site") }`;
} else {
document.querySelector("title").innerHTML = `${url.p.substring(url.p.lastIndexOf("/")+1).toContent().toTitleCase()} | ${ document.querySelector("title").getAttribute("data-site") }`
let theTitle = docuemnt.querySelector("article").getAttribute("data-name").toContent().toTitleCase();
if (docuemnt.querySelector("article").getAttribute("data-display") !== null) {
theTitle = docuemnt.querySelector("article").getAttribute("data-display")
}
document.querySelector("title").innerHTML = `${theTitle} | ${ document.querySelector("title").getAttribute("data-site") }`
}
}
@@ -185,88 +204,107 @@ module.exports = {
document.querySelectorAll("article").forEach((a) => {
if ( a.getAttribute("data-template") != "none" ) {
let path = a.getAttribute("data-path");
path = "patterns/" +
(a.getAttribute("data-core") == "true" ?
"core/" + path.substring(path.lastIndexOf("/") + 1) :
a.getAttribute("data-path"))
+ "/index.html";
const ASYNC = true;
let ajx = new XMLHttpRequest();
ajx.onreadystatechange = () => {
if (ajx.readyState == 4) {
switch (ajx.status) {
case 200:
a.innerHTML = a.innerHTML + ajx.responseText;
switch (a.getAttribute("data-template")) {
case "pug":
a.querySelectorAll("pre").forEach((aa) => {
aa.innerHTML = `<code class="${aa.getAttribute("class")}">${aa.innerHTML}</code>`;
})
break;
case "md":
a.querySelectorAll("code").forEach((aa) => {
aa.classList.add("language-html");
})
break;
}
const observer = new IntersectionObserver(articles => {
articles.forEach(article => {
let a = article.target;
a.querySelectorAll("code").forEach((c)=> {
c.classList.add("line-numbers");
c.innerHTML = c.innerHTML.replace(/</g, "&lt;");
c.classList.add("copy-to-clipboard-button");
})
if (typeof args.success == "function") args.success(a);
// console.log("observing: ", { id: a.getAttribute("id"), intersecting: a.isIntersecting } )
// if (article.intersectionRatio > 0) {
// console.log("Is interesecting: ", { id: article.target.getAttribute("id"), intersecting: article.isIntersecting, ratio: article.intersectionRatio } )
Prism.highlightAll();
if (article.isIntersecting == true) {
let path = a.getAttribute("data-path");
path = "patterns/" +
(a.getAttribute("data-core") == "true" ?
"core/" + path.substring(path.lastIndexOf("/") + 1) :
a.getAttribute("data-path"))
+ "/index.html";
const ASYNC = true;
let ajx = new XMLHttpRequest();
ajx.onreadystatechange = () => {
if (ajx.readyState == 4) {
observer.unobserve(article.target);
switch (ajx.status) {
case 200:
a.innerHTML = a.innerHTML + ajx.responseText;
a.style.height = "auto"
switch (a.getAttribute("data-template")) {
case "pug":
a.querySelectorAll("pre").forEach((aa) => {
aa.innerHTML = `<code class="${aa.getAttribute("class")}">${aa.innerHTML}</code>`;
})
break;
case "md":
a.querySelectorAll("code").forEach((aa) => {
aa.classList.add("language-html");
})
break;
}
a.querySelectorAll("code").forEach((c)=> {
c.onclick = (e) => {
oneClickSelect(e);
a.querySelectorAll("code").forEach((c)=> {
c.classList.add("line-numbers");
c.innerHTML = c.innerHTML.replace(/</g, "&lt;");
c.classList.add("copy-to-clipboard-button");
})
if (typeof args.success == "function") args.success(a);
Prism.highlightAll();
a.querySelectorAll("code").forEach((c)=> {
c.onclick = (e) => {
oneClickSelect(e);
}
})
module.exports.colour.positionTooltip();
window.onresize = () => {
module.exports.colour.positionTooltip();
}
a.querySelectorAll("name > span, color-pill > span").forEach((pill) => {
pill.onclick = (e) => {
e.preventDefault();
let w = "";
if (e.metaKey || e.ctrlKey || e.keyCode == 91 || e.keyCode == 224) {
w = "var";
} else if (e.altKey) {
w = "token"
} else if (e.shiftKey) {
w = "rgb";
} else {
w = "hex";
}
module.exports.colour.copy(w, pill);
}
})
break;
case 404:
if (typeof args.notFound == "function") args.notFound(a, path);
break;
default:
console.log("uncaught http error", { status: ajx.status, path: a.getAttribute("data-path") });
}
})
a.style.height = "auto";
if (typeof args.done == "function") args.done(a);
module.exports.colour.positionTooltip();
window.onresize = () => {
module.exports.colour.positionTooltip();
}
};
ajx.open("GET", path, ASYNC);
ajx.send();
a.querySelectorAll("name > span, color-pill > span").forEach((pill) => {
pill.onclick = (e) => {
e.preventDefault();
let w = "";
if (e.metaKey || e.ctrlKey || e.keyCode == 91 || e.keyCode == 224) {
w = "var";
} else if (e.altKey) {
w = "token"
} else if (e.shiftKey) {
w = "rgb";
} else {
w = "hex";
}
module.exports.colour.copy(w, pill);
}
})
break;
case 404:
if (typeof args.notFound == "function") args.notFound(a, path);
break;
default:
console.log("uncaught http error", { status: ajx.status, path: a.getAttribute("data-path") });
}
})
}, { threshold: 0, rootMargin: "100%" })
if (typeof args.done == "function") args.done(a);
observer.observe(a);
}
};
ajx.open("GET", path, ASYNC);
ajx.send();
} else {
a.style.height = "auto";
}
})

View File

@@ -24,14 +24,25 @@ core.init({
}
});
// deprecated switch handler
const flipDeprecated = (e, s = e.currentTarget) => {
core.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/");
document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => {
a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated")
});
const flipInfoSwitch = (e, s = e.currentTarget) => {
switch(s.getAttribute("id")) {
case "deprecated" :
core.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/");
document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => {
a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated");
});
break;
case "breakpoints" :
console.log("here")
core.cookie.set("show-breakpoints", s.getAttribute("aria-checked"), 30, "/");
document.querySelector("html").classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-breakpoints");
break;
}
}
// create a pure JS mouse click event
@@ -42,15 +53,24 @@ const click = new MouseEvent('click', {
});
// get the switch, initialize it and add the handler
let switches = document.querySelector(".info-switches");
swtch.init(switches);
let deprecated = document.querySelector("#deprecated");
swtch.init(deprecated.parentNode)
deprecated.onclick = flipDeprecated;
deprecated.keypress = flipDeprecated;
let breakpoints = document.querySelector("#breakpoints");
deprecated.onclick = flipInfoSwitch;
deprecated.keypress = flipInfoSwitch;
breakpoints.onclick = flipInfoSwitch;
breakpoints.keypress = flipInfoSwitch;
// check a cookie to get the switch's state
if (core.cookie.get("show-deprecated") == "true") {
deprecated.dispatchEvent(click);
}
if (core.cookie.get("show-breakpoints") == "true") {
breakpoints.dispatchEvent(click);
}
// just for fun... We'll show deprecated if they match the path
// document.querySelector(`#${core.url.p.replace(/\//g, "-")}`).classList.add("show-deprecated");

View File

@@ -27,12 +27,12 @@
},
{
name: "switch",
status: "in-progress",
status: "complete",
core: true,
},
{
name: "tooltip",
status: "in-progress",
status: "complete",
core: true,
},
]
@@ -45,17 +45,17 @@
files: [
{
name: "header",
status: "in-progress",
status: "complete",
core: true,
},
{
name: "breakpoints",
status: "in-progress",
status: "complete",
core: true,
},
{
name: "tabs",
status: "in-progress",
status: "complete",
core: true,
},
]

View File

@@ -139,13 +139,16 @@
- return o;
- }
if !colortxt
- var colortxt = "color"
mixin accessibility-info(c)
div.acchb
span color & black
span #{colortxt} & black
small= getContrastRatio(color(c, "rgb"), "rgb(0,0,0)") + ":1"
div.acchw
span color & white
span #{colortxt} & white
small= getContrastRatio(color(c, "rgb"), "rgb(255,255,255)") + ":1"
div.aa WCAG 2.0 AA
div.accbaa.result

View File

@@ -1,93 +1,86 @@
//-
DS2 core (c) 2024 Alexander McIlwraith
Core licensed under CC BY-SA 4.0
- const getDate = function(){
- var d = new Date();
- return d.toLocaleDateString(lang, {day: "numeric", month: "long", year: "numeric"});
- }
- String.prototype.toTitleCase = function() {
- return this.replace(/\w\S*/g, function(txt) {
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
- });
- }
- String.prototype.toSentenceCase = function() {
- return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
- }
- String.prototype.toContent = function() {
- return this.replace(/-/g, " ");
- }
- String.prototype.toPath = function() {
- return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-");
- }
include ../_config
block config
mixin show-content(items, path)
- path = (path == "" ? "" : path + "/") + items.name.toPath()
article(id=path.replace(/\//g, "-").toPath()
data-name=items.name
data-status=items.status
data-display=items.display
data-template=(items.template == undefined ? "pug" : items.template)
data-core= (items.core ? "true" : "false")
data-path=path
)
h1(class="status-" + items.status )
span= items.name.toSentenceCase().toContent()
tool-tip(role="tooltip" inert tip-position="right")= items.status.toSentenceCase().toContent()
if items.files
each item in items.files
+show-content(item, path)
doctype html
html(lang= lang )
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1")
title(data-site= site )= site
block head
link( href="assets/scaffolding.css" rel="stylesheet" )
body
//
DS2 core (c) 2024 Alexander McIlwraith
Core licensed under CC BY-SA 4.0
a.skip(href="#main") Skip to main content
div.container
block header
main#main
h1= site
each category in content
+show-content(category, "")
script(src="assets/scaffolding-min.js")
//-
DS2 core (c) 2024 Alexander McIlwraith
Core licensed under CC BY-SA 4.0
- const getDate = function(){
- var d = new Date();
- return d.toLocaleDateString(lang, {day: "numeric", month: "long", year: "numeric"});
- }
- String.prototype.toTitleCase = function() {
- return this.replace(/\w\S*/g, function(txt) {
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
- });
- }
- String.prototype.toSentenceCase = function() {
- return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
- }
- String.prototype.toContent = function() {
- return this.replace(/-/g, " ");
- }
- String.prototype.toPath = function() {
- return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-");
- }
include ../_config
block config
mixin show-content(items, path)
- path = (path == "" ? "" : path + "/") + items.name.toPath()
if items.core == true
- items.status = "complete"
article(id=path.replace(/\//g, "-").toPath()
data-name=items.name
data-status=items.status
data-display=items.display
data-template=(items.template == undefined ? "pug" : items.template)
data-core= (items.core ? "true" : "false")
data-path=path
style="height: 100vh"
)
if items.display
h1(class="status-" + items.status )
span= items.display
tool-tip(role="tooltip" inert tip-position="right")= items.status.toSentenceCase().toContent()
else
h1(class="status-" + items.status )
span= items.name.toSentenceCase().toContent()
tool-tip(role="tooltip" inert tip-position="right")= items.status.toSentenceCase().toContent()
if items.files
each item in items.files
+show-content(item, path)
doctype html
html(lang= lang )
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1")
title(data-site= site )= site
block head
link( href="assets/scaffolding.css" rel="stylesheet" )
body
//
DS2 core (c) 2024 Alexander McIlwraith
Core licensed under CC BY-SA 4.0
a.skip(href="#main") Skip to main content
div.container
block header
main#main
h1= site
each category in content
+show-content(category, "")
script(src="assets/scaffolding-min.js")

View File

@@ -1,39 +1,43 @@
//-
DS2 core (c) 2024 Alexander McIlwraith
Core licensed under CC BY-SA 4.0
include ../_config
block config
mixin h(h)
if headings[h]
h2= headings[h]
- const getDate = function(){
- var d = new Date();
- return d.toLocaleDateString(lang, {day: "numeric", month: "long", year: "numeric"});
- }
- String.prototype.toTitleCase = function() {
- return this.replace(/\w\S*/g, function(txt) {
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
- });
- }
- String.prototype.toSentenceCase = function() {
- return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
- }
- String.prototype.toContent = function() {
- return this.replace(/-/g, " ");
- }
- String.prototype.toPath = function() {
- return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-");
- }
html
head
title Pattern
body(data-assetpath= assetpath data-prismjs-copy-timeout="1500")
//-
DS2 core (c) 2024 Alexander McIlwraith
Core licensed under CC BY-SA 4.0
include ../_config
block config
mixin h(h)
if headings[h]
if headings[h].indexOf("|") == -1
h2= headings[h]
else
- var cntnt = headings[h].split("|")
| <#{cntnt[0]}>#{cntnt[1]}</#{cntnt[0]}>
- const getDate = function(){
- var d = new Date();
- return d.toLocaleDateString(lang, {day: "numeric", month: "long", year: "numeric"});
- }
- String.prototype.toTitleCase = function() {
- return this.replace(/\w\S*/g, function(txt) {
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
- });
- }
- String.prototype.toSentenceCase = function() {
- return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
- }
- String.prototype.toContent = function() {
- return this.replace(/-/g, " ");
- }
- String.prototype.toPath = function() {
- return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-");
- }
html
head
title Pattern
body(data-assetpath= assetpath data-prismjs-copy-timeout="1500")
block content

View File

@@ -16,7 +16,10 @@ block header
li(class= navClass)
a(href="./?p=" + first.name.toPath() )= first.name.toContent().toSentenceCase()
p.deprecated-switch
p.info-switches
span
span#deprecated(role="switch")
label(for="deprecated") Show deprecated patterns
label(for="deprecated") Show deprecated patterns
span
span#breakpoints(role="switch")
label(for="breakpoints") Show breakpoint information

View File

@@ -1,7 +1,8 @@
//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
$grid-breakpoints: ( xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px ) !default;
// default breakpoints match bootstrap 5 breakpoints.
$grid-breakpoints: ( xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px ) !default;
@mixin breakpoint-debug {
body::before, body::after {
@@ -9,6 +10,7 @@ $grid-breakpoints: ( xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px ) !defau
color: white;
content: "bigger than extra large";
display: grid;
font-family: sans-serif;
font-size: 25px;
grid-template-columns: auto;
padding: 25px;

View File

@@ -5,11 +5,26 @@ extends ../../../core/_master-pattern
block content
+h(0)
p Breakpoints enable responsive mobile design.
+h(1)
p Use breakpoints when designing for different screen sizes.
p The breakpoints SCSS mixin included implements media queries to allow for the change of the layout and design based on pre-defined screen sizes.
+h(2)
p This pattern is only available for SCSS breakpoints. The mixin is avai
p When using this, use the default break points as they are set to the same as the Bootstrap framework. The grid for the design system at large break point has been widened to accompdate 3 colour cards across.
div.tab-group#breakpoints
pre.language-css(data-tab="scss")
include _breakpoints.scss
tabset#breakpoints
div(tab="scss")
+h(3)
pre.language-sass.
@import "scss/core/breakpoints/breakpoints";
@include break([breakpoint]) {
// css here
}
+h(4)
pre.language-sass
include _breakpoints.scss

View File

@@ -0,0 +1,16 @@
//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
//- required variables
//- site - the site name that goes in the site title
//- root - the path to the root of the site
header
// The headline banner area
svg(height='5.5rem' width='100%' xmlns='http://www.w3.org/2000/svg' aria-hidden='true')
text= site
div
div.header-title
h1
a(href="./")= site
// Other sections can go here, such as search and directory

View File

@@ -1,53 +1 @@
header {
display: -ms-grid;
display: grid;
-ms-grid-rows: 1.75rem 3.5rem;
grid-template-rows: 1.75rem 3.5rem;
-ms-grid-column: 2;
-ms-grid-column-span: 2;
grid-column: 2/4;
overflow: hidden;
}
header svg {
grid-column: 1/-1;
grid-row: 1/-1;
-ms-grid-row-align: stretch;
-ms-grid-column-align: stretch;
place-self: stretch;
}
header svg text {
-webkit-transform: translate(-1rem, 7.25rem);
-ms-transform: translate(-1rem, 7.25rem);
transform: translate(-1rem, 7.25rem);
font-size: 10rem;
font-weight: 1000;
font-family: sans-serif;
fill: var(--colour-grey-xxl);
}
header > div {
-ms-grid-row: 2;
grid-row: 2;
grid-column: 1/-1;
display: -ms-grid;
display: grid;
grid-column-gap: 1rem;
-ms-grid-columns: auto -webkit-max-content -webkit-max-content;
-ms-grid-columns: auto max-content max-content;
grid-template-columns: auto -webkit-max-content -webkit-max-content;
grid-template-columns: auto max-content max-content;
}
header > div .header-title h1 {
margin: 0;
padding: 0 1rem;
}
header > div .header-title h1 a, header > div .header-title h1 a:visited {
border-bottom: none;
color: var(--colour-black);
font-family: sans-serif;
font-size: 2.5rem;
font-size: 32px;
font-weight: 700;
margin: 0;
padding: 0;
text-decoration: none;
}
header{display:-ms-grid;display:grid;-ms-grid-rows:1.75rem 3.5rem;grid-template-rows:1.75rem 3.5rem;-ms-grid-column:2;-ms-grid-column-span:2;grid-column:2/4;overflow:hidden}header svg{grid-column:1/-1;grid-row:1/-1;-ms-grid-row-align:stretch;-ms-grid-column-align:stretch;place-self:stretch}header svg text{-webkit-transform:translate(-1rem,7.25rem);-ms-transform:translate(-1rem,7.25rem);transform:translate(-1rem,7.25rem);font-size:10rem;font-weight:1000;font-family:sans-serif;fill:var(--colour-grey-xxl)}header>div{-ms-grid-row:2;grid-row:2;grid-column:1/-1;display:-ms-grid;display:grid;grid-column-gap:1rem;-ms-grid-columns:auto -webkit-max-content -webkit-max-content;-ms-grid-columns:auto max-content max-content;grid-template-columns:auto -webkit-max-content -webkit-max-content;grid-template-columns:auto max-content max-content}header>div .header-title h1{margin:0;padding:0 1rem}header>div .header-title h1 a,header>div .header-title h1 a:visited{border-bottom:none;color:var(--colour-black);font-family:sans-serif;font-size:2.5rem;font-size:32px;font-weight:700;margin:0;padding:0;text-decoration:none}

View File

@@ -5,11 +5,15 @@ extends ../../../core/_master-pattern
block content
+h(0)
p A header is layout pattern that helps the user identify the site.
+h(1)
+h(2)
p Use a header at the top of every page. The 'front page' of a site may have a different header than the rest of the pages.
div.tab-group#header
pre.language-html(data-tab="html")
+h(2)
p Place the header at the top of the page after the skip to main content link. You will likely want to replace core header should be replaced with your own site's header. To do this, remove the #[code.inline.language-js core: true ] and create your own pattern in the location you wish it in your design system.
tabset#header
pre.language-html(tab="html")
// create temp variables and store the design system values
- var tmpsite= site
- var tmproot= root
@@ -21,8 +25,14 @@ block content
//- reset variables to original values
- site= tmpsite
- root= tmproot
pre.language-pug(tab="pug")
include _header.pp
pre.language-css(tab="css")
include header.css
div.language-sass(tab="scss")
pre.language-sass.
@import "scss/core/header/header;
pre.language-sass(data-tab="scss")
include _header.scss
pre.language-css(data-tab="css")
include header.css
pre.language-sass
include _header.scss

View File

@@ -6,23 +6,23 @@ block content
-
- let list = []
- for(let i = 0; i < content.length; i++) {
- list.push({ "name": content[i].name, "path": content[i].name, "status": content[i].status, "display": content[i].display } )
- list.push({ "name": content[i].name, "path": content[i].name, "status": content[i].status, "display": (content[i].hasOwnProperty("display") && content[i].display != "" ? content[i].display : content[i].name.toSentenceCase().toContent()) } )
- if (content[i].files != undefined) {
- for (let ii = 0; ii < content[i].files.length; ii++) {
- list.push({ "name": content[i].files[ii].name, "path": content[i].name +"."+ content[i].files[ii].name, "status": content[i].files[ii].status } )
- list.push({ "name": content[i].files[ii].name, "path": content[i].name +"."+ content[i].files[ii].name, "status": content[i].files[ii].status, "display": (content[i].files[ii].hasOwnProperty("display") && content[i].files[ii].display != "" ? content[i].files[ii].display : content[i].files[ii].name.toSentenceCase().toContent()) } )
- if (content[i].files[ii].files != undefined) {
- for (let iii = 0; iii < content[i].files[ii].files.length; iii++) {
- list.push({ "name": content[i].files[ii].files[iii].name, "path": content[i].name +"."+ content[i].files[ii].name + "." + content[i].files[ii].files[iii].name, "status": content[i].files[ii].files[iii].status } )
- list.push({ "name": content[i].files[ii].files[iii].name, "path": content[i].name +"."+ content[i].files[ii].name + "." + content[i].files[ii].files[iii].name, "status": content[i].files[ii].files[iii].status, "display": (content[i].files[ii].files[iii].hasOwnProperty("display") && content[i].files[ii].files[iii].display != "" ? content[i].files[ii].files[iii].display : content[i].files[ii].files[iii].name.toSentenceCase().toContent()) } )
- }
- }
- }
- }
- }
- list.sort((a, b) => {
- if (a.name < b.name) {
- if (a.display < b.display) {
- return -1;
- }
- if (a.name > b.name) {
- if (a.display > b.display) {
- return 1;
- }
- return 0;

View File

@@ -0,0 +1,2 @@
sticky-note(float="right").blue This #[strong is] a sample sticky.
| You can drag it out of the way if you need to see the content under it.

View File

@@ -0,0 +1,2 @@
sticky-note(float="right").blue This #[strong is] a sample sticky.
| You can drag it out of the way if you need to see the content under it.

View File

@@ -8,24 +8,36 @@ block content
+h(1)
p Use a sticky when you want to make a note without adding it to the content.
+h(2)
p Uses absolute positioning.
sticky-note(float="right").blue This #[strong is] a sample sticky.
| You can drag it out of the way if you need to see the content under it.
p Uses absolute positioning. Passing an optional element to the init function will initialise tabs within that element. You can move the position using either #[code.language-html.inline float="&#91; right | left &#93;"] or #[code.language-html.inline offset="&#91; top | left &#93;"]. Offset will take negative values in any web measurement unit.
sticky-note.blue(offset="-10rem 1rem") This #[strong is] a sample sticky. You can drag it out of the way if you need to see the content under it.
sticky-note(float="right") You will notice when you hover over the sticky, it shows a dot in the colour of the sticky in the position where the sticky note refers to (assuming you haven't dragged it and scrolled that location off the screen).
p If you wish to create a custom element, that extends another HTML element, the native element has to be extended in customElements.define(). Custom elements that inherit native elements are also known as "type extension custom elements".
sticky-note You will notice when you hover over the sticky, it shows a dot in the colour of the sticky in the position where the sticky note refers to (assuming you haven't dragged it and scrolled that location off the screen).
tabset#sticky-note
pre.language-html(tab="html")
sticky-note(float="right").blue This #[strong is] a sample sticky.
| You can drag it out of the way if you need to see the content under it.
pre.language-pug(tab="pug").
sticky-note(float="right").blue This #[strong is] a sample sticky.
| You can drag it out of the way if you need to see the content under it.
include _sticky-note.pug
pre.language-pug(tab="pug")
include _sticky-note.pp
pre.language-css(data-tab="css")
include sticky-note.css
pre.language-css(data-tab="scss")
include _sticky-note.scss
pre.language-js(data-tab="js")
include _sticky-note.js
div(tab="scss")
+h(3)
pre.language-sass.
$sticky-colors: ( [sass map with your own defined colours] );
@import "scss/core/switch/_sticky-note";
@include sticky-note;
+h(4)
pre.language-sass
include _sticky-note.scss
div(tab="js")
+h(3)
pre.language-js.
import * as stickynote from ""./js/core/sticky-note/_sticky-note.js";
stickynote.init()
+h(4)
pre.language-js
include _sticky-note.js

View File

@@ -1,126 +1 @@
@import url("https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap");
sticky-note-wrapper {
-webkit-box-sizing: border-box;
box-sizing: border-box;
border: 1px solid transparent;
border-radius: 50%;
display: inline-block;
height: 0.5rem;
position: relative;
width: 0.5rem;
}
sticky-note-wrapper * {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
sticky-note-wrapper sticky-note {
cursor: -webkit-grab;
cursor: grab;
display: -ms-grid;
display: grid;
float: left;
font-size: 1rem;
height: 13rem;
left: 0;
place-items: stretch;
position: absolute;
top: 0;
width: 13rem;
z-index: 100;
}
sticky-note-wrapper sticky-note:active {
cursor: -webkit-grabbing;
cursor: grabbing;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
sticky-note-wrapper sticky-note.right {
float: right;
}
sticky-note-wrapper sticky-note > div {
-ms-grid-row: 1;
grid-row: 1;
-ms-grid-column: 1;
grid-column: 1;
}
sticky-note-wrapper sticky-note > div:nth-child(1) {
background-color: rgba(0, 0, 0, 0.25);
-webkit-box-shadow: -2px 2px 15px 0 rgba(0, 0, 0, 0.5);
box-shadow: -2px 2px 15px 0 rgba(0, 0, 0, 0.5);
display: -ms-grid;
display: grid;
margin: 2rem 1rem 0.25rem 0.36rem;
width: calc(100% - 1rem);
}
sticky-note-wrapper sticky-note > div:nth-child(2) {
clip-path: url(#stickyClip);
display: -ms-grid;
display: grid;
font-family: "Kalam", cursive;
font-style: 1rem;
font-weight: 300;
line-height: 1.25rem;
padding: 1rem;
place-items: center;
text-align: center;
}
sticky-note-wrapper sticky-note > div:nth-child(2) > * {
font-family: "Kalam", cursive !important;
font-style: normal !important;
font-weight: 300 !important;
}
@media screen and (max-width: 1024px) {
sticky-note-wrapper sticky-note > div:nth-child(2) {
max-width: 13rem;
min-width: 13rem;
width: 1rem;
}
}
@media screen and (max-width: 768px) {
sticky-note-wrapper sticky-note > div:nth-child(2) {
font-size: 1.75rem;
max-width: 21rem;
min-height: 21rem;
}
}
@media screen and (max-width: 640px) {
sticky-note-wrapper sticky-note > div:nth-child(2) {
font-size: 2.5rem;
max-width: 26rem;
min-height: 26rem;
}
}
sticky-note-wrapper sticky-note > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#ffffdd), color-stop(2%, #ffffd3), color-stop(12%, #ffffd3), color-stop(75%, #ffffc9), to(#ffffba));
background: linear-gradient(180deg, #ffffdd 0%, #ffffd3 2%, #ffffd3 12%, #ffffc9 75%, #ffffba 100%);
}
sticky-note-wrapper sticky-note.blue > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#9dddec), color-stop(2%, #94daea), color-stop(12%, #94daea), color-stop(75%, #8bd7e8), to(#7fd3e6));
background: linear-gradient(180deg, #9dddec 0%, #94daea 2%, #94daea 12%, #8bd7e8 75%, #7fd3e6 100%);
}
sticky-note-wrapper sticky-note.pink > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#fa7c93), color-stop(2%, #fa728b), color-stop(12%, #fa728b), color-stop(75%, #fa6883), to(#f95977));
background: linear-gradient(180deg, #fa7c93 0%, #fa728b 2%, #fa728b 12%, #fa6883 75%, #f95977 100%);
}
sticky-note-wrapper sticky-note.green > div:nth-child(2) {
background: -webkit-gradient(linear, left top, left bottom, from(#c5fcc9), color-stop(2%, #bbfbc0), color-stop(12%, #bbfbc0), color-stop(75%, #b1fab7), to(#a3faaa));
background: linear-gradient(180deg, #c5fcc9 0%, #bbfbc0 2%, #bbfbc0 12%, #b1fab7 75%, #a3faaa 100%);
}
sticky-note-wrapper:has(sticky-note:hover) {
background-color: #ffffd3;
border: 1px solid black;
}
sticky-note-wrapper:has(sticky-note.yellow:hover) {
background-color: #ffffd3;
}
sticky-note-wrapper:has(sticky-note.blue:hover) {
background-color: #94daea;
}
sticky-note-wrapper:has(sticky-note.pink:hover) {
background-color: #fa728b;
}
sticky-note-wrapper:has(sticky-note.green:hover) {
background-color: #bbfbc0;
}
@import url("https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap");sticky-note-wrapper{-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid transparent;border-radius:50%;display:inline-block;height:0.5rem;position:relative;width:0.5rem}sticky-note-wrapper *{-webkit-box-sizing:border-box;box-sizing:border-box}sticky-note-wrapper sticky-note{cursor:-webkit-grab;cursor:grab;display:-ms-grid;display:grid;float:left;font-size:1rem;height:13rem;left:0;place-items:stretch;position:absolute;top:0;width:13rem;z-index:100}sticky-note-wrapper sticky-note:active{cursor:-webkit-grabbing;cursor:grabbing;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}sticky-note-wrapper sticky-note.right{float:right}sticky-note-wrapper sticky-note>div{-ms-grid-row:1;grid-row:1;-ms-grid-column:1;grid-column:1}sticky-note-wrapper sticky-note>div:first-child{background-color:rgba(0,0,0,0.25);-webkit-box-shadow:-2px 2px 15px 0 rgba(0,0,0,0.5);box-shadow:-2px 2px 15px 0 rgba(0,0,0,0.5);display:-ms-grid;display:grid;margin:2rem 1rem 0.25rem 0.36rem;width:calc(100% - 1rem)}sticky-note-wrapper sticky-note>div:nth-child(2){clip-path:url(#stickyClip);display:-ms-grid;display:grid;font-family:"Kalam",cursive;font-style:1rem;font-weight:300;line-height:1.25rem;padding:1rem;place-items:center;text-align:center}sticky-note-wrapper sticky-note>div:nth-child(2)>*{font-family:"Kalam",cursive!important;font-style:normal!important;font-weight:300!important}@media screen and (max-width:1024px){sticky-note-wrapper sticky-note>div:nth-child(2){max-width:13rem;min-width:13rem;width:1rem}}@media screen and (max-width:768px){sticky-note-wrapper sticky-note>div:nth-child(2){font-size:1.75rem;max-width:21rem;min-height:21rem}}@media screen and (max-width:640px){sticky-note-wrapper sticky-note>div:nth-child(2){font-size:2.5rem;max-width:26rem;min-height:26rem}}sticky-note-wrapper sticky-note>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#ffffdd),color-stop(2%,#ffffd3),color-stop(12%,#ffffd3),color-stop(75%,#ffffc9),to(#ffffba));background:linear-gradient(180deg,#ffffdd 0%,#ffffd3 2%,#ffffd3 12%,#ffffc9 75%,#ffffba 100%)}sticky-note-wrapper sticky-note.blue>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#9dddec),color-stop(2%,#94daea),color-stop(12%,#94daea),color-stop(75%,#8bd7e8),to(#7fd3e6));background:linear-gradient(180deg,#9dddec 0%,#94daea 2%,#94daea 12%,#8bd7e8 75%,#7fd3e6 100%)}sticky-note-wrapper sticky-note.pink>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#fa7c93),color-stop(2%,#fa728b),color-stop(12%,#fa728b),color-stop(75%,#fa6883),to(#f95977));background:linear-gradient(180deg,#fa7c93 0%,#fa728b 2%,#fa728b 12%,#fa6883 75%,#f95977 100%)}sticky-note-wrapper sticky-note.green>div:nth-child(2){background:-webkit-gradient(linear,left top,left bottom,from(#c5fcc9),color-stop(2%,#bbfbc0),color-stop(12%,#bbfbc0),color-stop(75%,#b1fab7),to(#a3faaa));background:linear-gradient(180deg,#c5fcc9 0%,#bbfbc0 2%,#bbfbc0 12%,#b1fab7 75%,#a3faaa 100%)}sticky-note-wrapper:has(sticky-note:hover){background-color:#ffffd3;border:1px solid black}sticky-note-wrapper:has(sticky-note.yellow:hover){background-color:#ffffd3}sticky-note-wrapper:has(sticky-note.blue:hover){background-color:#94daea}sticky-note-wrapper:has(sticky-note.pink:hover){background-color:#fa728b}sticky-note-wrapper:has(sticky-note.green:hover){background-color:#bbfbc0}

View File

@@ -0,0 +1 @@
span#example-id(role="switch")

View File

@@ -5,23 +5,44 @@ extends ../../../core/_master-pattern
block content
+h(0)
p Switches are used to toggle application state between two mutually exlusive values.
p Switches are used to toggle application state between two mutually exclusive values.
+h(1)
p Use a switch when the user will see an immediate visible state change. Do not use a switch when the state change will affect future results. The user should not have to perform another action (search, save, etc) for the result to take affect. If the change in state does not take effect immediately, consider a checkbox.
+h(2)
p The switch label should describe what will happen when the switch is turned to the on state. Frontload labels with keywords.
p Include the CSS and JavaScript. An additional handler will need to be created for the actual state change. The CSS implements the visual design of the switch, which is based on the accessibility properties, which are implemented by the JavaScript.
h2 Example
p.switch
label(for="example-switch") Switch label
label(for="example-switch") Switch label (states the on state)
span#example-switch(role="switch")
div#switches.tab-group
pre.language-html(data-tab="html")
pre.language-html(tab="html")
include _switch.pug
pre.language-pug(data-tab="pug")
include switch.pug
pre.language-css(data-tab="css")
pre.language-pug(tab="pug")
include _switch.pp
pre.language-css(tab="css")
include switch.css
pre.language-css(data-tab="scss")
include _switch.scss
pre.language-js(data-tab="js")
include _switch.js
div(tab="scss")
+h(3)
pre.language-sass.
@import "scss/core/switch/_switch";
@include switch;
+h(4)
pre.language-sass
include _switch.scss
div(tab="js")
+h(3)
pre.language-js.
// Note that switch is a reserved word.
import * as swtch from "./js/core/switch/_switch.js";
swtch.init();
+h(4)
pre.language-js
include _switch.js

View File

@@ -1,26 +1 @@
[role=switch] {
display: -ms-inline-grid;
display: inline-grid;
border: 1px solid var(--colour-blue);
background-color: var(--colour-grey-xl);
border-radius: 0.75rem;
height: 1.5rem;
width: 3rem;
-webkit-transition: all 500ms;
transition: all 500ms;
}
[role=switch] > span {
display: inline-block;
background-color: white;
border-radius: 50%;
margin: 2%;
width: calc(1.5rem - 2%);
-webkit-transition: all 500ms;
transition: all 500ms;
}
[role=switch][aria-checked=true] {
background-color: var(--colour-blue);
}
[role=switch][aria-checked=true] > span {
margin-left: calc(1.5rem - 5%);
}
[role=switch]{display:-ms-inline-grid;display:inline-grid;border:1px solid #2e51a1;background-color:#d8d8d8;border-radius:0.75rem;height:1.5rem;width:3rem;-webkit-transition:all 500ms;transition:all 500ms}[role=switch]>span{display:inline-block;background-color:white;border-radius:50%;margin:2%;width:calc(1.5rem - 2%);-webkit-transition:all 500ms;transition:all 500ms}[role=switch][aria-checked=true]{background-color:#2e51a1}[role=switch][aria-checked=true]>span{margin-left:calc(1.5rem - 5%)}

View File

@@ -1,2 +0,0 @@
.
span#example-id(role="switch")

View File

@@ -1,9 +1,15 @@
/* DS2 core (c) 2024 Alexander McIlwraith
import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js";
tabs.init();
Released under Creative Commons Attribution-ShareAlike 4.0 International
*/
export function init(p = document) {
// create a pure JS mouse click event
const click = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
});
export function init(p = document, s = true) {
p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
if (tabGroup.querySelector("[role=tablist]") === null) {
@@ -30,7 +36,7 @@ export function init(p = document) {
const ul = document.createElement('ul');
ul.setAttribute("role", "tablist");
ul.innerHTML = `${tablist}<li role="separator" class="separator"></li>`;
ul.innerHTML = s != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
tabGroup.insertBefore(ul, tabGroup.firstChild);
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
@@ -46,8 +52,15 @@ export function init(p = document) {
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
document.getElementById(tabPanelId).classList.add("open");
});
tab.addEventListener("keypress", (e) => {
e.preventDefault();
if( e.which == 32 || e.which == 13 ) {
e.currentTarget.dispatchEvent(click);
}
})
});
}
});
}

View File

@@ -0,0 +1,4 @@
tabset#uniqueID
div(tab="[tab title]")
div(tab="[tab title]")

View File

@@ -1,4 +1,4 @@
div#uniqueID.tab-group
div(data-tab="[tab title]")
div(data-tab="[tab title]")
tabset#uniqueID
div(tab="[tab title]")
div(tab="[tab title]")

View File

@@ -5,9 +5,9 @@ extends ../../../core/_master-pattern
block content
+h(0)
+h(1)
+h(2)
p A tabs component that provides different sections of content that are displayed one at a time when the user selects that information.
+h(1)
p The tabbed user interface enables users to jump to their target section quickly. Tabs present like logically group information on the same page. Information should
ul
@@ -19,24 +19,34 @@ block content
p Users should not need to see content of multiple tabs simultaneously and the user should be able to easily recognise where they are within the content.
p The tab module can be initialised by importing a file with the javascript module using import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js"; contains a modularized version of the jQuery code, so that it can be called on demand. It is what is used in the design system so that the JavaScript can be called at run time (after loading content).
+h(2)
p The structure of the tab set is defined in html. There are two forms supported. Adding a class of #[code.inline .tab-group] to the container element will work in place of the #[code.inline tabset] tag, and the tab panels can be defined using either #[code.inline tab=""] or #[code.inline data-tab=""]. Passing an optional element to the init function will initialise tabs within that element.
tabset#tabs
pre.language-html(tab="html")
include _tabs.pug
//- pre.language-pug(tab="pug").
include _tabs.pug
pre.language-pug(tab="pug")
include _tabs.pp
pre.language-css(tab="css")
include tabs.css
pre.language-css(tab="scss")
include _tabs.scss
div(tab="scss")
+h(3)
pre.language-sass.
@import "scss/core/tabs/_tabs";
@include tabs{
// optional content block
};
pre.language-css(tab="js")
include _tabs.js
+h(4)
pre.language-sass
include _tabs.scss
div(tab="js")
+h(3)
pre.language-js.
import * as tabs from "./js/core/tabs/_tabs.js";
tabs.init();
+h(4)
pre.language-js
include _tabs.js

View File

@@ -9,8 +9,8 @@ tabset > ul, .tab-group > ul {
padding: 0;
}
tabset > ul li.separator, .tab-group > ul li.separator {
border-bottom: 1px solid var(--colour-grey);
border-left: 1px solid var(--colour-grey);
border-bottom: 1px solid #7f7f7f;
border-left: 1px solid #7f7f7f;
display: inline-block;
margin: 0.45rem 0 0 0;
width: 100%;
@@ -19,9 +19,9 @@ tabset .tab-hidden, .tab-group .tab-hidden {
display: none;
}
tabset [role=tab], .tab-group [role=tab] {
background-color: var(--colour-white);
border-left: 1px solid var(--colour-grey);
border-top: 1px solid var(--colour-grey);
background-color: #FFF;
border-left: 1px solid #7f7f7f;
border-top: 1px solid #7f7f7f;
border-radius: 0.5rem 0.5rem 0 0;
cursor: pointer;
margin: 0;
@@ -30,19 +30,19 @@ tabset [role=tab], .tab-group [role=tab] {
z-index: 2;
}
tabset [role=tab]:last-of-type, .tab-group [role=tab]:last-of-type {
border-right: 1px solid var(--colour-grey);
border-right: 1px solid #7f7f7f;
}
tabset [role=tab]:not(.selected), .tab-group [role=tab]:not(.selected) {
background-color: var(--colour-grey-xxl);
border-bottom: 1px solid var(--colour-grey);
background-color: #f0f0f0;
border-bottom: 1px solid #7f7f7f;
}
tabset [role=tab] span, .tab-group [role=tab] span {
display: block;
margin: 0 0 0.5rem 0;
}
tabset [role=tabpanel], .tab-group [role=tabpanel] {
background-color: var(--colour-white);
border: 1px solid var(--colour-grey);
background-color: #FFF;
border: 1px solid #7f7f7f;
border-top: none;
padding: 1rem;
z-index: 1;

View File

@@ -0,0 +1,2 @@
a(href="#") Link with a tool tip
span(role="tooltip" inert tip-position="right") Tool tip content

View File

@@ -1,5 +1,2 @@
a(href="#") Link with a tool tip
div(role="tooltip" inert tip-position="bottom") Tool tip content
a(href="#") Link with a tool tip
tool-tip(role="tooltip" inert tip-position="bottom") Tool tip content
span(role="tooltip" inert tip-position="right") Tool tip content

View File

@@ -1,6 +1,7 @@
//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
$font-body: sans-serif !default;
$tooltip-border-radius: .5rem !default;
$tooltip-dark-allow: true !default;
$tooltip-dark-background: #1f2127 !default;
@@ -29,6 +30,7 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
border-radius: $tooltip-border-radius;
color: $tooltip-light-foreground;
filter: $tooltip-light-drop-shadow;
$font-family: $font-body;
font-size: 1rem;
font-weight: 400;
inline-size: max-content;

View File

@@ -5,13 +5,22 @@ extends ../../../core/_master-pattern
block content
+h(0)
p Tooltips provide brief information messaging through a mouse or keyboard hover.
+h(1)
p Use tool tips to provide additional information. Don't use tooltips for that is required to complete an interaction as the information disappears when it loses the hover state.
p Use tooltips to help differentiate between multiple, close, similar options.
+h(2)
p Either form works. Place this inside another element for the tooltip to be "linked to that element."
p.notification-box.info Currently, there is no easy way to activate a hover without with pure CSS without using a keyboard or mouse. Level4 media queries aim to solve that.
p Either form works.
sticky-note.blue "Either form works": What are the two forms.
| Place the #[code.language-html.inline tooltip] inside another element for the tooltip to be 'linked to that element.' A container element may need to be added for a single tag element, such as a input field.
p Tool tip positions are:
ul
@@ -20,14 +29,23 @@ block content
li bottom / block-end
li left / inline-start
p
include _tooltip.pug
div#tooltip.tab-group
pre.language-html(data-tab="html")
tabset#tooltip
pre.language-html(tab="html")
include _tooltip.pug
pre.language-pug(data-tab="pug")
include tooltip.pug
pre.language-css(data-tab="css")
pre.language-pug(tab="pug")
include _tooltip.pp
pre.language-css(tab="css")
include tooltip.css
pre.language-css(data-tab="scss")
include _tooltip.scss
div(tab="scss")
+h(3)
pre.language-sass.
@import "scss/core/tooltip/_tooltip";
@include tooltip;
+h(4)
pre.language-sass
include _tooltip.scss

View File

@@ -1,6 +0,0 @@
.
a(href="#") Link with a tool tip
div(role="tooltip" inert tip-position="bottom") Tool tip content
a(href="#") Link with a tool tip
tool-tip(role="tooltip" inert tip-position="bottom") Tool tip content

View File

@@ -35,6 +35,9 @@ html {
@include break(-md) {
font-size: calc($font-size + 2pt);
}
&.show-breakpoints {
@include breakpoint-debug;
}
}
@include core-colour-samples;
@@ -87,11 +90,18 @@ body {
}
p.deprecated-switch {
p.info-switches {
align-items: center;
display: grid;
gap: .25rem;
grid-column: 2 / 4;
grid-row: 3;
grid-template-columns: auto repeat(2, max-content);
text-align: right;
@include switch;
label {
text-align: left;;
}
}
main {