Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 44b116860b | |||
| 2c2a45cb7b | |||
| a886d1a069 | |||
| 2d0cc46d2f | |||
| d6efdc59ff | |||
| 944b81e366 | |||
| 2567bb9275 | |||
| bd2e9f309b | |||
| 885adac795 | |||
| 023b626151 | |||
| 0e965a4978 | |||
| 76aebac4d1 | |||
| 2595836df2 | |||
| 11bc4f438f |
220
public/assets/scaffolding-min.js
vendored
220
public/assets/scaffolding-min.js
vendored
@@ -3194,9 +3194,9 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
/* harmony export */ init: function() { return /* binding */ init; }
|
/* harmony export */ init: function() { return /* binding */ init; }
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* DS2 core (c) 2024 Alexander McIlwraith
|
/* DS2 core (c) 2024-2026 Alexander McIlwraith
|
||||||
Released under Creative Commons Attribution-ShareAlike 4.0 International
|
Released under Creative Commons Attribution-ShareAlike 4.0 International
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// create a pure JS mouse click event
|
// create a pure JS mouse click event
|
||||||
var click = new MouseEvent('click', {
|
var click = new MouseEvent('click', {
|
||||||
@@ -3204,70 +3204,67 @@ var click = new MouseEvent('click', {
|
|||||||
bubbles: false,
|
bubbles: false,
|
||||||
cancelable: true
|
cancelable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// wait for an element to appear in the DOM
|
||||||
var waitForElement = function waitForElement(selector) {
|
var waitForElement = function waitForElement(selector) {
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
if (document.querySelector(selector)) {
|
if (document.querySelector(selector)) {
|
||||||
return resolve(document.querySelector(selector));
|
return resolve(document.querySelector(selector));
|
||||||
}
|
}
|
||||||
var observer = new MutationObserver(function (mutations) {
|
var observer = new MutationObserver(function () {
|
||||||
if (document.querySelector(selector)) {
|
if (document.querySelector(selector)) {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
resolve(document.querySelector(selector));
|
resolve(document.querySelector(selector));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
|
|
||||||
observer.observe(document.body, {
|
observer.observe(document.body, {
|
||||||
childList: true,
|
childList: true,
|
||||||
subtree: true
|
subtree: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Tab logic
|
||||||
|
var tabNamespace = "#tab:";
|
||||||
var chooseTab = function chooseTab(tab) {
|
var chooseTab = function chooseTab(tab) {
|
||||||
var siblings = Array.from(tab.parentNode.children);
|
var siblings = Array.from(tab.closest('[role="tablist"]').querySelectorAll('[role="tab"]'));
|
||||||
siblings.forEach(function (sibling) {
|
siblings.forEach(function (sibling) {
|
||||||
return sibling.classList.remove("selected");
|
return sibling.classList.remove("selected");
|
||||||
});
|
});
|
||||||
tab.classList.add("selected");
|
tab.classList.add("selected");
|
||||||
var tabPanels = Array.from(tab.parentNode.parentNode.children);
|
var tabGroup = tab.closest("tabset, .tab-group");
|
||||||
|
var tabPanels = Array.from(tabGroup.querySelectorAll('[role="tabpanel"]'));
|
||||||
tabPanels.forEach(function (panel) {
|
tabPanels.forEach(function (panel) {
|
||||||
return panel.classList.remove("open");
|
return panel.classList.remove("open");
|
||||||
});
|
});
|
||||||
var tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
|
var tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
|
||||||
document.getElementById(tabPanelId).classList.add("open");
|
document.getElementById(tabPanelId).classList.add("open");
|
||||||
};
|
};
|
||||||
var pushState = 0;
|
var pushStateCount = 0;
|
||||||
var tabsetCount = 0;
|
var tabsetCount = 0;
|
||||||
function init() {
|
function init() {
|
||||||
var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
||||||
var spacer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
var spacer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
||||||
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
||||||
container.querySelectorAll(".tab-group, tabset").forEach(function (tabGroup) {
|
container.querySelectorAll(".tab-group, tabset").forEach(function (tabGroup) {
|
||||||
if (tabGroup.querySelector("[role=tablist]") === null) {
|
if (tabGroup.querySelector('[role="tablist"]') === null) {
|
||||||
|
var _ul$querySelector;
|
||||||
if (tabGroup.getAttribute("id") == null) {
|
if (tabGroup.getAttribute("id") == null) {
|
||||||
tabGroup.setAttribute("id", "tab-group-" + tabsetCount);
|
tabGroup.setAttribute("id", "tab-group-".concat(tabsetCount++));
|
||||||
tabsetCount++;
|
|
||||||
}
|
}
|
||||||
var tabgroup = tabGroup.getAttribute("id");
|
var tabgroup = tabGroup.getAttribute("id");
|
||||||
var tablist = "";
|
var tablist = "";
|
||||||
Array.from(tabGroup.children).forEach(function (child) {
|
Array.from(tabGroup.children).forEach(function (child) {
|
||||||
// is details?
|
var _child$querySelector;
|
||||||
var dtls = child.nodeName == "DETAILS" ? true : false;
|
var isDetails = child.nodeName === "DETAILS";
|
||||||
|
var tabLabel = isDetails ? (_child$querySelector = child.querySelector("summary")) === null || _child$querySelector === void 0 ? void 0 : _child$querySelector.innerHTML : child.getAttribute("tab") || child.getAttribute("data-tab");
|
||||||
// get the tab text
|
if (tabLabel !== null) {
|
||||||
var tab = dtls ? child.querySelector("summary").innerHTML : child.getAttribute("tab") || child.getAttribute("data-tab");
|
var tabID = tabLabel.replace(/\W+/g, "-").toLowerCase();
|
||||||
|
var tabPanel;
|
||||||
// if the tab text is not blank
|
if (isDetails) {
|
||||||
if (tab !== null) {
|
|
||||||
var tabID = tab.replace(/\W+/g, "-").toLowerCase();
|
|
||||||
|
|
||||||
// define the tab panel content
|
|
||||||
var tabPanel = null;
|
|
||||||
if (dtls) {
|
|
||||||
tabPanel = child;
|
tabPanel = child;
|
||||||
tabPanel.setAttribute("open", "");
|
tabPanel.setAttribute("open", "");
|
||||||
} else {
|
} else {
|
||||||
tabPanel = document.createElement('div');
|
tabPanel = document.createElement("div");
|
||||||
tabPanel.appendChild(child.cloneNode(true));
|
tabPanel.appendChild(child.cloneNode(true));
|
||||||
}
|
}
|
||||||
tabPanel.id = "tab-panel-".concat(tabgroup, "-").concat(tabID);
|
tabPanel.id = "tab-panel-".concat(tabgroup, "-").concat(tabID);
|
||||||
@@ -3276,75 +3273,166 @@ function init() {
|
|||||||
tabPanel.setAttribute("tabindex", "0");
|
tabPanel.setAttribute("tabindex", "0");
|
||||||
tabPanel.setAttribute("aria-labelledby", "tab-".concat(tabgroup, "-").concat(tabID));
|
tabPanel.setAttribute("aria-labelledby", "tab-".concat(tabgroup, "-").concat(tabID));
|
||||||
child.parentNode.replaceChild(tabPanel, child);
|
child.parentNode.replaceChild(tabPanel, child);
|
||||||
tablist += "<li tabindex=\"0\" role=\"tab\" id=\"tab-".concat(tabgroup, "-").concat(tabID, "\"><span>").concat(tab, "</span></li>");
|
tablist += "<li tabindex=\"0\" role=\"tab\" id=\"tab-".concat(tabgroup, "-").concat(tabID, "\">\n\t\t\t\t\t\t\t<span>").concat(tabLabel, "</span>\n\t\t\t\t\t\t</li>");
|
||||||
} else {
|
} else {
|
||||||
child.classList.add("tab-hidden");
|
child.classList.add("tab-hidden");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var ul = document.createElement('ul');
|
var ul = document.createElement("ul");
|
||||||
ul.setAttribute("role", "tablist");
|
ul.setAttribute("role", "tablist");
|
||||||
tabGroup.insertBefore(ul, tabGroup.firstChild);
|
tabGroup.insertBefore(ul, tabGroup.firstChild);
|
||||||
ul.innerHTML = spacer != true ? "".concat(tablist) : "".concat(tablist, "<li role=\"separator\" class=\"separator\"></li>");
|
var wrapper = document.createElement("div");
|
||||||
|
wrapper.className = "tab-scroll-wrapper";
|
||||||
|
var scroller = document.createElement("div");
|
||||||
|
scroller.className = "tab-scroll";
|
||||||
|
var leftArrow = document.createElement("div");
|
||||||
|
leftArrow.className = "tab-scroll-arrow left";
|
||||||
|
leftArrow.setAttribute("aria-hidden", "true");
|
||||||
|
leftArrow.innerHTML = "\n\t\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"24\" height=\"24\">\n\t\t\t\t\t<path d=\"M400-80 0-480l400-400 71 71-329 329 329 329-71 71Z\"/>\n\t\t\t\t</svg>\n\t\t\t";
|
||||||
|
var rightArrow = document.createElement("div");
|
||||||
|
rightArrow.className = "tab-scroll-arrow right";
|
||||||
|
rightArrow.setAttribute("aria-hidden", "true");
|
||||||
|
rightArrow.innerHTML = "\n\t\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"24\" height=\"24\">\n\t\t\t\t\t<path d=\"m321-80-71-71 329-329-329-329 71-71 400 400L321-80Z\"/>\n\t\t\t\t</svg>\n\t\t\t";
|
||||||
|
ul.parentNode.insertBefore(wrapper, ul);
|
||||||
|
wrapper.appendChild(scroller);
|
||||||
|
wrapper.appendChild(leftArrow);
|
||||||
|
wrapper.appendChild(rightArrow);
|
||||||
|
scroller.appendChild(ul);
|
||||||
|
var updateScrollState = function updateScrollState() {
|
||||||
|
var isOverflowing = scroller.scrollWidth > scroller.clientWidth;
|
||||||
|
wrapper.classList.toggle("is-overflowing", isOverflowing);
|
||||||
|
var atStart = scroller.scrollLeft <= 1;
|
||||||
|
var atEnd = scroller.scrollLeft + scroller.clientWidth >= scroller.scrollWidth - 2;
|
||||||
|
leftArrow.classList.toggle("hidden", !isOverflowing || atStart);
|
||||||
|
rightArrow.classList.toggle("hidden", !isOverflowing || atEnd);
|
||||||
|
wrapper.classList.toggle("show-left", isOverflowing && !atStart);
|
||||||
|
wrapper.classList.toggle("show-right", isOverflowing && !atEnd);
|
||||||
|
};
|
||||||
|
var scrollAmount = 15; // smaller = smoother per frame
|
||||||
|
var scrollInterval = 16; // ~60fps
|
||||||
|
|
||||||
|
var scrollTimer = null;
|
||||||
|
var startScrolling = function startScrolling(direction) {
|
||||||
|
if (scrollTimer) return;
|
||||||
|
var speed = 0.1;
|
||||||
|
scrollTimer = setInterval(function () {
|
||||||
|
speed = Math.min(speed + 0.01, 5); // ramp up
|
||||||
|
scroller.scrollBy({
|
||||||
|
left: direction * scrollAmount * speed,
|
||||||
|
behavior: "auto"
|
||||||
|
});
|
||||||
|
}, scrollInterval);
|
||||||
|
};
|
||||||
|
var stopScrolling = function stopScrolling() {
|
||||||
|
clearInterval(scrollTimer);
|
||||||
|
scrollTimer = null;
|
||||||
|
};
|
||||||
|
leftArrow.addEventListener("mousedown", function () {
|
||||||
|
return startScrolling(-1);
|
||||||
|
});
|
||||||
|
leftArrow.addEventListener("mouseup", stopScrolling);
|
||||||
|
leftArrow.addEventListener("mouseleave", stopScrolling);
|
||||||
|
leftArrow.addEventListener("touchstart", function () {
|
||||||
|
return startScrolling(-1);
|
||||||
|
});
|
||||||
|
leftArrow.addEventListener("touchend", stopScrolling);
|
||||||
|
rightArrow.addEventListener("mousedown", function () {
|
||||||
|
return startScrolling(1);
|
||||||
|
});
|
||||||
|
rightArrow.addEventListener("mouseup", stopScrolling);
|
||||||
|
rightArrow.addEventListener("mouseleave", stopScrolling);
|
||||||
|
rightArrow.addEventListener("touchstart", function () {
|
||||||
|
return startScrolling(1);
|
||||||
|
});
|
||||||
|
rightArrow.addEventListener("touchend", stopScrolling);
|
||||||
|
var ARROW_ZONE = 40;
|
||||||
|
wrapper.addEventListener("contextmenu", function (e) {
|
||||||
|
var isOverflowing = wrapper.classList.contains("is-overflowing");
|
||||||
|
if (!isOverflowing) return;
|
||||||
|
var rect = wrapper.getBoundingClientRect();
|
||||||
|
var isLeftZone = e.clientX < rect.left + ARROW_ZONE;
|
||||||
|
var isRightZone = e.clientX > rect.right - ARROW_ZONE;
|
||||||
|
if (isLeftZone || isRightZone) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var scrollClickAmount = 150;
|
||||||
|
leftArrow.addEventListener("click", function () {
|
||||||
|
scroller.scrollBy({
|
||||||
|
left: -scrollClickAmount,
|
||||||
|
behavior: "smooth"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
rightArrow.addEventListener("click", function () {
|
||||||
|
scroller.scrollBy({
|
||||||
|
left: scrollClickAmount,
|
||||||
|
behavior: "smooth"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
scroller.addEventListener("scroll", updateScrollState);
|
||||||
|
window.addEventListener("resize", updateScrollState);
|
||||||
|
updateScrollState();
|
||||||
|
ul.innerHTML = spacer !== true ? tablist : "".concat(tablist, "<li aria-hidden=\"true\" class=\"separator\"></li>");
|
||||||
|
requestAnimationFrame(updateScrollState);
|
||||||
|
setTimeout(updateScrollState, 50);
|
||||||
|
ul.innerHTML = spacer !== true ? tablist : "".concat(tablist, "<li aria-hidden=\"true\" class=\"separator\"></li>");
|
||||||
|
|
||||||
|
// Tab ordering
|
||||||
if (tabGroup.hasAttribute("order") || tabGroup.hasAttribute("data-order")) {
|
if (tabGroup.hasAttribute("order") || tabGroup.hasAttribute("data-order")) {
|
||||||
var order = (tabGroup.getAttribute("order") || tabGroup.getAttribute("data-order")).split(",");
|
var order = (tabGroup.getAttribute("order") || tabGroup.getAttribute("data-order")).split(",");
|
||||||
var items = Array.from(ul.getElementsByTagName("li"));
|
var items = Array.from(ul.getElementsByTagName("li"));
|
||||||
items.sort(function (a, b) {
|
items.sort(function (a, b) {
|
||||||
console.log("here");
|
|
||||||
var aa = order.indexOf(a.textContent.trim());
|
var aa = order.indexOf(a.textContent.trim());
|
||||||
var bb = order.indexOf(b.textContent.trim());
|
var bb = order.indexOf(b.textContent.trim());
|
||||||
|
if (aa === -1) return 1;
|
||||||
// Check if both items exist in orderArray
|
if (bb === -1) return -1;
|
||||||
if (aa === -1) return 1; // Move to the end if not found
|
return aa - bb;
|
||||||
if (bb === -1) return -1; // Move to the end if not found
|
|
||||||
|
|
||||||
return aa - bb; // Sort based on the defined order
|
|
||||||
});
|
});
|
||||||
ul.innerHTML = '';
|
ul.innerHTML = "";
|
||||||
items.forEach(function (item) {
|
items.forEach(function (item) {
|
||||||
return ul.appendChild(item);
|
return ul.appendChild(item);
|
||||||
});
|
});
|
||||||
|
chooseTab(items[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tab event handlers
|
||||||
tabGroup.querySelectorAll('[role="tab"]').forEach(function (tab) {
|
tabGroup.querySelectorAll('[role="tab"]').forEach(function (tab) {
|
||||||
tab.addEventListener("click", function (evt) {
|
tab.addEventListener("click", function (evt) {
|
||||||
if (pushState == 0) {
|
var tabId = tab.getAttribute("id");
|
||||||
window.history.pushState({
|
var hash = "".concat(tabNamespace).concat(tabId);
|
||||||
rand: Math.random(),
|
|
||||||
pushState: pushState,
|
|
||||||
tab: tab.parentNode.firstChild.getAttribute("id")
|
|
||||||
}, "", "#".concat(tab.parentNode.firstChild.getAttribute("id")));
|
|
||||||
pushState++;
|
|
||||||
}
|
|
||||||
chooseTab(evt.currentTarget);
|
chooseTab(evt.currentTarget);
|
||||||
window.history.pushState({
|
window.history.pushState({
|
||||||
rand: Math.random(),
|
tab: tabId
|
||||||
pushState: pushState,
|
}, "", "".concat(location.pathname).concat(location.search).concat(hash));
|
||||||
tab: tab.getAttribute("id")
|
pushStateCount++;
|
||||||
}, "", "#".concat(tab.getAttribute("id")));
|
|
||||||
pushState++;
|
|
||||||
});
|
});
|
||||||
tab.addEventListener("keypress", function (e) {
|
tab.addEventListener("keypress", function (e) {
|
||||||
e.preventDefault();
|
if (e.which === 32 || e.which === 13) {
|
||||||
if (e.which == 32 || e.which == 13) {
|
e.preventDefault();
|
||||||
e.currentTarget.dispatchEvent(click);
|
e.currentTarget.dispatchEvent(click);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ul.querySelector("li").classList.add("selected");
|
(_ul$querySelector = ul.querySelector("li")) === null || _ul$querySelector === void 0 || _ul$querySelector.classList.add("selected");
|
||||||
}
|
|
||||||
if (document.location.hash != "" && document.location.hash.substring(0, 5) == "#tab-") {
|
|
||||||
waitForElement(document.location.hash).then(function (el) {
|
|
||||||
//el.scrollIntoView();
|
|
||||||
el.focus();
|
|
||||||
el.dispatchEvent(click);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Initial hash handling (tabs only)
|
||||||
|
if (location.hash.startsWith(tabNamespace)) {
|
||||||
|
var tabId = location.hash.replace(tabNamespace, "");
|
||||||
|
waitForElement("#".concat(tabId)).then(function (el) {
|
||||||
|
el.focus();
|
||||||
|
el.dispatchEvent(click);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// History navigation (tabs only)
|
||||||
window.addEventListener("popstate", function (e) {
|
window.addEventListener("popstate", function (e) {
|
||||||
e.preventDefault();
|
var _e$state;
|
||||||
if (e.state != null) {
|
if (!location.hash.startsWith(tabNamespace)) return;
|
||||||
chooseTab(document.querySelector("#".concat(e.state.tab)));
|
if ((_e$state = e.state) !== null && _e$state !== void 0 && _e$state.tab) {
|
||||||
} else {
|
var tab = document.querySelector("#".concat(e.state.tab));
|
||||||
history.go(-1);
|
if (tab) chooseTab(tab);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -38,6 +38,8 @@
|
|||||||
<li><a href="./?p=status">Status</a></li>
|
<li><a href="./?p=status">Status</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
<p class="info-switches"><span></span><span id="deprecated" role="switch"></span>
|
<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="deprecated">Show deprecated patterns</label><span></span><span id="breakpoints" role="switch"></span>
|
||||||
<label for="breakpoints">Show breakpoint information</label>
|
<label for="breakpoints">Show breakpoint information</label>
|
||||||
|
|||||||
@@ -42,45 +42,70 @@
|
|||||||
<pre class="language-css" tab="css">tabset, .tab-group {
|
<pre class="language-css" tab="css">tabset, .tab-group {
|
||||||
margin: 2rem 0 1rem 0;
|
margin: 2rem 0 1rem 0;
|
||||||
}
|
}
|
||||||
tabset [role=tablist], .tab-group [role=tablist] {
|
tabset [role=tablist] li.selected, .tab-group [role=tablist] li.selected {
|
||||||
|
background-color: var(--color-blue);
|
||||||
|
color: var(--color-white);
|
||||||
|
}
|
||||||
|
tabset > ul,
|
||||||
|
tabset .tab-scroll > ul, .tab-group > ul,
|
||||||
|
.tab-group .tab-scroll > ul {
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
tabset [role=tablist] li.separator, .tab-group [role=tablist] li.separator {
|
tabset > ul li.separator,
|
||||||
|
tabset .tab-scroll > ul li.separator, .tab-group > ul li.separator,
|
||||||
|
.tab-group .tab-scroll > ul li.separator {
|
||||||
border-bottom: 1px solid #7f7f7f;
|
border-bottom: 1px solid #7f7f7f;
|
||||||
display: inline-block;
|
|
||||||
margin: 0.45rem 0 0 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab], .tab-group [role=tablist] li[role=tab] {
|
|
||||||
background-color: #FFF;
|
|
||||||
border-left: 1px solid #7f7f7f;
|
border-left: 1px solid #7f7f7f;
|
||||||
border-right: 1px solid #7f7f7f;
|
display: inline-block;
|
||||||
border-radius: 0.5rem 0.5rem 0 0;
|
-webkit-box-flex: 1;
|
||||||
border-top: 1px solid #7f7f7f;
|
-ms-flex: 1 1 auto;
|
||||||
cursor: pointer;
|
flex: 1 1 auto;
|
||||||
display: inline;
|
margin: 0.45rem 0 0 0;
|
||||||
margin: 0;
|
width: auto;
|
||||||
padding: 1rem 1.5rem 0.14rem 1.5rem;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab]:last-of-type, .tab-group [role=tablist] li[role=tab]:last-of-type {
|
|
||||||
border-right: 1px solid #7f7f7f;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab]:not(.selected), .tab-group [role=tablist] li[role=tab]:not(.selected) {
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
border-bottom: 1px solid #7f7f7f;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab] span, .tab-group [role=tablist] li[role=tab] span {
|
|
||||||
display: block;
|
|
||||||
margin: 0 0 0.5rem 0;
|
|
||||||
}
|
}
|
||||||
tabset .tab-hidden, .tab-group .tab-hidden {
|
tabset .tab-hidden, .tab-group .tab-hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
tabset [role=tab], .tab-group [role=tab] {
|
||||||
|
background-color: #FFF;
|
||||||
|
border-left: 1px solid #7f7f7f;
|
||||||
|
border-radius: 0.5rem 0.5rem 0 0;
|
||||||
|
border-top: 1px solid #7f7f7f;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
-webkit-box-flex: 0;
|
||||||
|
-ms-flex: 0 0 auto;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 100vw;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 1rem 1.5rem 0.14rem 1.5rem;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
tabset [role=tab]:last-of-type, .tab-group [role=tab]:last-of-type {
|
||||||
|
border-right: 1px solid #7f7f7f;
|
||||||
|
}
|
||||||
|
tabset [role=tab]:not(.selected), .tab-group [role=tab]:not(.selected) {
|
||||||
|
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] {
|
tabset [role=tabpanel], .tab-group [role=tabpanel] {
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
border: 1px solid #7f7f7f;
|
border: 1px solid #7f7f7f;
|
||||||
@@ -90,6 +115,112 @@ tabset [role=tabpanel], .tab-group [role=tabpanel] {
|
|||||||
}
|
}
|
||||||
tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
|
tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
|
||||||
display: none;
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-scroll {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.tab-scroll::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.tab-scroll > ul {
|
||||||
|
-ms-flex-wrap: nowrap;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
min-width: 100%;
|
||||||
|
width: -webkit-max-content;
|
||||||
|
width: -moz-max-content;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-scroll-wrapper {
|
||||||
|
position: relative;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper::before, .tab-scroll-wrapper::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transition: opacity 0.2s ease;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper::before {
|
||||||
|
background: radial-gradient(circle at left center, rgb(255, 255, 255) 0%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 255, 0.5) 75%, rgba(255, 255, 255, 0.25) 95%, transparent 100%);
|
||||||
|
border-top-right-radius: 2.5rem;
|
||||||
|
border-bottom-right-radius: 2.5rem;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper::after {
|
||||||
|
right: 0;
|
||||||
|
background: radial-gradient(circle at right center, rgb(255, 255, 255) 0%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 255, 0.5) 75%, rgba(255, 255, 255, 0.25) 95%, transparent 100%);
|
||||||
|
border-top-left-radius: 2.5rem;
|
||||||
|
border-bottom-left-radius: 2.5rem;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing::before, .tab-scroll-wrapper.is-overflowing::after {
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transition: opacity 0.15s ease-out;
|
||||||
|
transition: opacity 0.15s ease-out;
|
||||||
|
-webkit-transition: opacity 0.12s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
transition: opacity 0.12s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing.show-left::before {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing.show-right::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow {
|
||||||
|
-webkit-box-align: center;
|
||||||
|
-ms-flex-align: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
-webkit-box-pack: center;
|
||||||
|
-ms-flex-pack: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
width: 2.5rem;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow path {
|
||||||
|
fill: #7f7f7f;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow.left {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow.right {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow.hidden {
|
||||||
|
display: none !important;
|
||||||
|
pointer-events: none;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing .tab-scroll-arrow {
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
}</pre>
|
}</pre>
|
||||||
<div tab="scss">
|
<div tab="scss">
|
||||||
<h2>Example</h2>
|
<h2>Example</h2>
|
||||||
@@ -98,70 +229,77 @@ tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
|
|||||||
// optional content block
|
// optional content block
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
<pre class="language-sass">// DS2 core (c) 2024 Alexander McIlwraith
|
<pre class="language-sass">$tab-border: #7f7f7f !default;
|
||||||
// Licensed under CC BY-SA 4.0
|
|
||||||
|
|
||||||
$tab-border: #7f7f7f !default;
|
|
||||||
$tab-panel-background-color: #FFF !default;
|
|
||||||
$tab-panel-top-border: #7f7f7f !default;
|
|
||||||
$tab-panel-top-border-width: 1px !default;
|
|
||||||
$tab-selected: #FFF !default;
|
$tab-selected: #FFF !default;
|
||||||
$tab-selected-text: #000 !default;
|
$tab-selected-text: #000 !default;
|
||||||
|
|
||||||
$tab-notselected: #f0f0f0 !default;
|
$tab-notselected: #f0f0f0 !default;
|
||||||
$tab-notselected-text: #000 !default;
|
$tab-notselected-text: #000 !default;
|
||||||
|
|
||||||
@mixin tabs {
|
@mixin tabs {
|
||||||
|
|
||||||
tabset, .tab-group {
|
tabset, .tab-group {
|
||||||
|
|
||||||
margin: 2rem 0 1rem 0;
|
margin: 2rem 0 1rem 0;
|
||||||
|
|
||||||
[role="tablist"] {
|
[role="tablist"] li.selected {
|
||||||
|
background-color: var(--color-blue);
|
||||||
|
color: var(--color-white);
|
||||||
|
}
|
||||||
|
|
||||||
|
> ul,
|
||||||
|
.tab-scroll > ul {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
li.separator {
|
||||||
li {
|
border-bottom: 1px solid $tab-border;
|
||||||
&.separator {
|
border-left: 1px solid $tab-border;
|
||||||
border-bottom: 1px solid $tab-border;
|
display: inline-block;
|
||||||
display: inline-block;
|
flex: 1 1 auto;
|
||||||
margin: .45rem 0 0 0;
|
margin: .45rem 0 0 0;
|
||||||
width: 100%;
|
width: auto;
|
||||||
}
|
|
||||||
|
|
||||||
&[role="tab"] {
|
|
||||||
background-color: $tab-selected;
|
|
||||||
border-left: 1px solid $tab-border;
|
|
||||||
border-right: 1px solid $tab-border;
|
|
||||||
border-radius: .5rem .5rem 0 0;
|
|
||||||
border-top: 1px solid $tab-border;
|
|
||||||
cursor:pointer;
|
|
||||||
display: inline;
|
|
||||||
margin: 0;
|
|
||||||
padding: 1rem 1.5rem .14rem 1.5rem;
|
|
||||||
z-index: 2;
|
|
||||||
|
|
||||||
&:last-of-type {
|
|
||||||
border-right: 1px solid $tab-border;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:not(.selected) {
|
|
||||||
background-color: $tab-notselected;
|
|
||||||
border-bottom: 1px solid $tab-border;
|
|
||||||
/// color
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
display: block;
|
|
||||||
margin: 0 0 .5rem 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-hidden {
|
.tab-hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[role="tab"] {
|
||||||
|
background-color: $tab-selected;
|
||||||
|
border-left: 1px solid $tab-border;
|
||||||
|
border-radius: .5rem .5rem 0 0;
|
||||||
|
border-top: 1px solid $tab-border;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 100vw;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 1rem 1.5rem .14rem 1.5rem;
|
||||||
|
user-select: none;
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-word;
|
||||||
|
|
||||||
|
&:last-of-type {
|
||||||
|
border-right: 1px solid $tab-border;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(.selected) {
|
||||||
|
background-color: $tab-notselected;
|
||||||
|
border-bottom: 1px solid $tab-border;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: block;
|
||||||
|
margin: 0 0 .5rem 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[role="tabpanel"] {
|
[role="tabpanel"] {
|
||||||
background-color: $tab-selected;
|
background-color: $tab-selected;
|
||||||
border: 1px solid $tab-border;
|
border: 1px solid $tab-border;
|
||||||
@@ -172,8 +310,138 @@ $tab-notselected-text: #000 !default;
|
|||||||
&:not(.open) {
|
&:not(.open) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scroller
|
||||||
|
.tab-scroll {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
> ul {
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
min-width: 100%;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrapper (now owns the fade)
|
||||||
|
.tab-scroll-wrapper {
|
||||||
|
position: relative;
|
||||||
|
user-select: none;
|
||||||
|
$radial: 2.5rem;
|
||||||
|
// edge fades (this is the fix)
|
||||||
|
&::before,
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
opacity: 0; // hidden by default
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
// left fade
|
||||||
|
&::before {
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at left center,
|
||||||
|
rgba(255,255,255,1) 0%,
|
||||||
|
rgba(255,255,255,0.9) 50%,
|
||||||
|
rgba(255,255,255,0.5) 75%,
|
||||||
|
rgba(255,255,255,0.25) 95%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
border-top-right-radius: $radial;
|
||||||
|
border-bottom-right-radius: $radial;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// right fade
|
||||||
|
&::after {
|
||||||
|
right: 0;
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at right center,
|
||||||
|
rgba(255,255,255,1) 0%,
|
||||||
|
rgba(255,255,255,0.9) 50%,
|
||||||
|
rgba(255,255,255,0.5) 75%,
|
||||||
|
rgba(255,255,255,0.25) 95%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
border-top-left-radius: $radial;
|
||||||
|
border-bottom-left-radius: $radial;
|
||||||
|
}
|
||||||
|
|
||||||
|
// show fade only when overflowing
|
||||||
|
&.is-overflowing {
|
||||||
|
&::before,
|
||||||
|
&::after {
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s ease-out;
|
||||||
|
transition: opacity 0.12s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.show-left {
|
||||||
|
&::before {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.show-right {
|
||||||
|
&::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// arrows
|
||||||
|
.tab-scroll-arrow {
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
user-select: none;
|
||||||
|
width: 2.5rem;
|
||||||
|
z-index: 3;
|
||||||
|
path {
|
||||||
|
fill: $tab-border;
|
||||||
|
}
|
||||||
|
&.left {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.right {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
display: none !important;
|
||||||
|
pointer-events: none;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// only show arrows when overflow
|
||||||
|
&.is-overflowing {
|
||||||
|
.tab-scroll-arrow {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@content;
|
|
||||||
}
|
}
|
||||||
}</pre>
|
}</pre>
|
||||||
</div>
|
</div>
|
||||||
@@ -181,9 +449,9 @@ $tab-notselected-text: #000 !default;
|
|||||||
<h2>Example</h2>
|
<h2>Example</h2>
|
||||||
<pre class="language-js">import * as tabs from "./js/core/tabs/_tabs.js";
|
<pre class="language-js">import * as tabs from "./js/core/tabs/_tabs.js";
|
||||||
tabs.init();</pre>
|
tabs.init();</pre>
|
||||||
<pre class="language-js">/* DS2 core (c) 2024 Alexander McIlwraith
|
<pre class="language-js">/* DS2 core (c) 2024-2026 Alexander McIlwraith
|
||||||
Released under Creative Commons Attribution-ShareAlike 4.0 International
|
Released under Creative Commons Attribution-ShareAlike 4.0 International
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// create a pure JS mouse click event
|
// create a pure JS mouse click event
|
||||||
const click = new MouseEvent('click', {
|
const click = new MouseEvent('click', {
|
||||||
@@ -192,48 +460,55 @@ const click = new MouseEvent('click', {
|
|||||||
cancelable: true
|
cancelable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// wait for an element to appear in the DOM
|
||||||
const waitForElement = (selector) => {
|
const waitForElement = (selector) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (document.querySelector(selector)) {
|
if (document.querySelector(selector)) {
|
||||||
return resolve(document.querySelector(selector));
|
return resolve(document.querySelector(selector));
|
||||||
}
|
}
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
if (document.querySelector(selector)) {
|
||||||
|
observer.disconnect();
|
||||||
|
resolve(document.querySelector(selector));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
observer.observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const observer = new MutationObserver(mutations => {
|
// Tab logic
|
||||||
if (document.querySelector(selector)) {
|
const tabNamespace = "#tab:";
|
||||||
observer.disconnect();
|
|
||||||
resolve(document.querySelector(selector));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
|
|
||||||
observer.observe(document.body, {
|
|
||||||
childList: true,
|
|
||||||
subtree: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const chooseTab = (tab) => {
|
const chooseTab = (tab) => {
|
||||||
const siblings = Array.from(tab.parentNode.children);
|
const siblings = Array.from(
|
||||||
|
tab.closest('[role="tablist"]').querySelectorAll('[role="tab"]')
|
||||||
|
);
|
||||||
siblings.forEach(sibling => sibling.classList.remove("selected"));
|
siblings.forEach(sibling => sibling.classList.remove("selected"));
|
||||||
tab.classList.add("selected");
|
tab.classList.add("selected");
|
||||||
|
|
||||||
const tabPanels = Array.from(tab.parentNode.parentNode.children)
|
|
||||||
tabPanels.forEach(panel => panel.classList.remove("open"));
|
|
||||||
|
|
||||||
|
const tabGroup = tab.closest("tabset, .tab-group");
|
||||||
|
const tabPanels = Array.from(
|
||||||
|
tabGroup.querySelectorAll('[role="tabpanel"]')
|
||||||
|
);
|
||||||
|
|
||||||
|
tabPanels.forEach(panel => panel.classList.remove("open"));
|
||||||
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
|
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
|
||||||
document.getElementById(tabPanelId).classList.add("open");
|
document.getElementById(tabPanelId).classList.add("open");
|
||||||
}
|
};
|
||||||
|
|
||||||
let pushState = 0;
|
let pushStateCount = 0;
|
||||||
let tabsetCount = 0;
|
let tabsetCount = 0;
|
||||||
|
|
||||||
export function init(container = document, spacer = true, args = {}) {
|
export function init(container = document, spacer = true) {
|
||||||
container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
|
container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
|
||||||
if (tabGroup.querySelector("[role=tablist]") === null) {
|
|
||||||
|
if (tabGroup.querySelector('[role="tablist"]') === null) {
|
||||||
|
|
||||||
if (tabGroup.getAttribute("id") == null) {
|
if (tabGroup.getAttribute("id") == null) {
|
||||||
tabGroup.setAttribute("id", "tab-group-" + tabsetCount);
|
tabGroup.setAttribute("id", `tab-group-${tabsetCount++}`);
|
||||||
tabsetCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const tabgroup = tabGroup.getAttribute("id");
|
const tabgroup = tabGroup.getAttribute("id");
|
||||||
@@ -241,24 +516,19 @@ export function init(container = document, spacer = true, args = {}) {
|
|||||||
|
|
||||||
Array.from(tabGroup.children).forEach(child => {
|
Array.from(tabGroup.children).forEach(child => {
|
||||||
|
|
||||||
// is details?
|
const isDetails = child.nodeName === "DETAILS";
|
||||||
let dtls = child.nodeName == "DETAILS" ? true : false;
|
const tabLabel = isDetails ? child.querySelector("summary")?.innerHTML : child.getAttribute("tab") || child.getAttribute("data-tab");
|
||||||
|
|
||||||
// get the tab text
|
if (tabLabel !== null) {
|
||||||
let tab = dtls ? child.querySelector("summary").innerHTML : child.getAttribute("tab") || child.getAttribute("data-tab");
|
|
||||||
|
|
||||||
// if the tab text is not blank
|
const tabID = tabLabel.replace(/\W+/g, "-").toLowerCase();
|
||||||
if (tab !== null) {
|
let tabPanel;
|
||||||
const tabID = tab.replace(/\W+/g, "-").toLowerCase();
|
|
||||||
|
|
||||||
|
|
||||||
// define the tab panel content
|
if (isDetails) {
|
||||||
let tabPanel = null;
|
|
||||||
if (dtls) {
|
|
||||||
tabPanel = child;
|
tabPanel = child;
|
||||||
tabPanel.setAttribute("open", "");
|
tabPanel.setAttribute("open", "");
|
||||||
} else {
|
} else {
|
||||||
tabPanel = document.createElement('div');
|
tabPanel = document.createElement("div");
|
||||||
tabPanel.appendChild(child.cloneNode(true));
|
tabPanel.appendChild(child.cloneNode(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,80 +536,225 @@ export function init(container = document, spacer = true, args = {}) {
|
|||||||
tabPanel.className = tablist === "" ? "open" : "";
|
tabPanel.className = tablist === "" ? "open" : "";
|
||||||
tabPanel.setAttribute("role", "tabpanel");
|
tabPanel.setAttribute("role", "tabpanel");
|
||||||
tabPanel.setAttribute("tabindex", "0");
|
tabPanel.setAttribute("tabindex", "0");
|
||||||
tabPanel.setAttribute("aria-labelledby", `tab-${tabgroup}-${tabID}`);
|
tabPanel.setAttribute(
|
||||||
|
"aria-labelledby",
|
||||||
|
`tab-${tabgroup}-${tabID}`
|
||||||
|
);
|
||||||
|
|
||||||
child.parentNode.replaceChild(tabPanel, child);
|
child.parentNode.replaceChild(tabPanel, child);
|
||||||
tablist += `<li tabindex="0" role="tab" id="tab-${tabgroup}-${tabID}"><span>${tab}</span></li>`;
|
|
||||||
|
tablist += `<li tabindex="0" role="tab" id="tab-${tabgroup}-${tabID}">
|
||||||
|
<span>${tabLabel}</span>
|
||||||
|
</li>`;
|
||||||
} else {
|
} else {
|
||||||
child.classList.add("tab-hidden");
|
child.classList.add("tab-hidden");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const ul = document.createElement('ul');
|
const ul = document.createElement("ul");
|
||||||
ul.setAttribute("role", "tablist");
|
ul.setAttribute("role", "tablist");
|
||||||
tabGroup.insertBefore(ul, tabGroup.firstChild);
|
tabGroup.insertBefore(ul, tabGroup.firstChild);
|
||||||
ul.innerHTML = spacer != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
|
|
||||||
|
|
||||||
if ( tabGroup.hasAttribute("order") || tabGroup.hasAttribute("data-order") ) {
|
|
||||||
let order = (tabGroup.getAttribute("order") || tabGroup.getAttribute("data-order")).split(",");
|
const wrapper = document.createElement("div");
|
||||||
|
wrapper.className = "tab-scroll-wrapper";
|
||||||
|
|
||||||
|
const scroller = document.createElement("div");
|
||||||
|
scroller.className = "tab-scroll";
|
||||||
|
|
||||||
|
const leftArrow = document.createElement("div");
|
||||||
|
leftArrow.className = "tab-scroll-arrow left";
|
||||||
|
|
||||||
|
leftArrow.setAttribute("aria-hidden", "true");
|
||||||
|
|
||||||
|
leftArrow.innerHTML = `
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" width="24" height="24">
|
||||||
|
<path d="M400-80 0-480l400-400 71 71-329 329 329 329-71 71Z"/>
|
||||||
|
</svg>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const rightArrow = document.createElement("div");
|
||||||
|
rightArrow.className = "tab-scroll-arrow right";
|
||||||
|
|
||||||
|
rightArrow.setAttribute("aria-hidden", "true");
|
||||||
|
|
||||||
|
rightArrow.innerHTML = `
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" width="24" height="24">
|
||||||
|
<path d="m321-80-71-71 329-329-329-329 71-71 400 400L321-80Z"/>
|
||||||
|
</svg>
|
||||||
|
`;
|
||||||
|
|
||||||
|
ul.parentNode.insertBefore(wrapper, ul);
|
||||||
|
wrapper.appendChild(scroller);
|
||||||
|
wrapper.appendChild(leftArrow);
|
||||||
|
wrapper.appendChild(rightArrow);
|
||||||
|
scroller.appendChild(ul);
|
||||||
|
|
||||||
|
const updateScrollState = () => {
|
||||||
|
const isOverflowing = scroller.scrollWidth > scroller.clientWidth;
|
||||||
|
|
||||||
|
wrapper.classList.toggle("is-overflowing", isOverflowing);
|
||||||
|
|
||||||
|
const atStart = scroller.scrollLeft <= 1;
|
||||||
|
const atEnd = scroller.scrollLeft + scroller.clientWidth >= scroller.scrollWidth - 2;
|
||||||
|
|
||||||
|
leftArrow.classList.toggle("hidden", !isOverflowing || atStart);
|
||||||
|
rightArrow.classList.toggle("hidden", !isOverflowing || atEnd);
|
||||||
|
|
||||||
|
|
||||||
|
wrapper.classList.toggle("show-left", isOverflowing && !atStart);
|
||||||
|
wrapper.classList.toggle("show-right", isOverflowing && !atEnd);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const scrollAmount = 15; // smaller = smoother per frame
|
||||||
|
const scrollInterval = 16; // ~60fps
|
||||||
|
|
||||||
|
let scrollTimer = null;
|
||||||
|
|
||||||
|
const startScrolling = (direction) => {
|
||||||
|
if (scrollTimer) return;
|
||||||
|
|
||||||
|
let speed = 0.1;
|
||||||
|
|
||||||
|
scrollTimer = setInterval(() => {
|
||||||
|
speed = Math.min(speed + 0.01, 5); // ramp up
|
||||||
|
scroller.scrollBy({
|
||||||
|
left: direction * scrollAmount * speed,
|
||||||
|
behavior: "auto"
|
||||||
|
});
|
||||||
|
}, scrollInterval);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const stopScrolling = () => {
|
||||||
|
clearInterval(scrollTimer);
|
||||||
|
scrollTimer = null;
|
||||||
|
};
|
||||||
|
leftArrow.addEventListener("mousedown", () => startScrolling(-1));
|
||||||
|
leftArrow.addEventListener("mouseup", stopScrolling);
|
||||||
|
leftArrow.addEventListener("mouseleave", stopScrolling);
|
||||||
|
|
||||||
|
leftArrow.addEventListener("touchstart", () => startScrolling(-1));
|
||||||
|
leftArrow.addEventListener("touchend", stopScrolling);
|
||||||
|
|
||||||
|
rightArrow.addEventListener("mousedown", () => startScrolling(1));
|
||||||
|
rightArrow.addEventListener("mouseup", stopScrolling);
|
||||||
|
rightArrow.addEventListener("mouseleave", stopScrolling);
|
||||||
|
|
||||||
|
rightArrow.addEventListener("touchstart", () => startScrolling(1));
|
||||||
|
rightArrow.addEventListener("touchend", stopScrolling);
|
||||||
|
|
||||||
|
const ARROW_ZONE = 40;
|
||||||
|
|
||||||
|
wrapper.addEventListener("contextmenu", (e) => {
|
||||||
|
const isOverflowing = wrapper.classList.contains("is-overflowing");
|
||||||
|
if (!isOverflowing) return;
|
||||||
|
|
||||||
|
const rect = wrapper.getBoundingClientRect();
|
||||||
|
|
||||||
|
const isLeftZone = e.clientX < rect.left + ARROW_ZONE;
|
||||||
|
const isRightZone = e.clientX > rect.right - ARROW_ZONE;
|
||||||
|
|
||||||
|
if (isLeftZone || isRightZone) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const scrollClickAmount = 150;
|
||||||
|
|
||||||
|
leftArrow.addEventListener("click", () => {
|
||||||
|
scroller.scrollBy({ left: -scrollClickAmount, behavior: "smooth" });
|
||||||
|
});
|
||||||
|
|
||||||
|
rightArrow.addEventListener("click", () => {
|
||||||
|
scroller.scrollBy({ left: scrollClickAmount, behavior: "smooth" });
|
||||||
|
});
|
||||||
|
|
||||||
|
scroller.addEventListener("scroll", updateScrollState);
|
||||||
|
window.addEventListener("resize", updateScrollState);
|
||||||
|
|
||||||
|
updateScrollState();
|
||||||
|
ul.innerHTML = spacer !== true ? tablist : `${tablist}<li aria-hidden="true" class="separator"></li>`;
|
||||||
|
|
||||||
|
requestAnimationFrame(updateScrollState);
|
||||||
|
setTimeout(updateScrollState, 50);
|
||||||
|
|
||||||
|
ul.innerHTML = spacer !== true ? tablist : `${tablist}<li aria-hidden="true" class="separator"></li>`;
|
||||||
|
|
||||||
|
// Tab ordering
|
||||||
|
if (tabGroup.hasAttribute("order") || tabGroup.hasAttribute("data-order")) {
|
||||||
|
|
||||||
|
const order = (
|
||||||
|
tabGroup.getAttribute("order") ||
|
||||||
|
tabGroup.getAttribute("data-order")
|
||||||
|
).split(",");
|
||||||
|
|
||||||
const items = Array.from(ul.getElementsByTagName("li"));
|
const items = Array.from(ul.getElementsByTagName("li"));
|
||||||
|
|
||||||
items.sort((a, b) => {
|
items.sort((a, b) => {
|
||||||
console.log("here")
|
|
||||||
const aa = order.indexOf(a.textContent.trim());
|
const aa = order.indexOf(a.textContent.trim());
|
||||||
const bb = order.indexOf(b.textContent.trim());
|
const bb = order.indexOf(b.textContent.trim());
|
||||||
|
if (aa === -1) return 1;
|
||||||
// Check if both items exist in orderArray
|
if (bb === -1) return -1;
|
||||||
if (aa === -1) return 1; // Move to the end if not found
|
return aa - bb;
|
||||||
if (bb === -1) return -1; // Move to the end if not found
|
|
||||||
|
|
||||||
return aa - bb; // Sort based on the defined order
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ul.innerHTML = '';
|
ul.innerHTML = "";
|
||||||
items.forEach(item => ul.appendChild(item));
|
items.forEach(item => ul.appendChild(item));
|
||||||
|
chooseTab(items[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tab event handlers
|
||||||
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
|
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
|
||||||
|
|
||||||
tab.addEventListener("click", (evt) => {
|
tab.addEventListener("click", (evt) => {
|
||||||
if (pushState == 0) {
|
|
||||||
window.history.pushState({rand: Math.random(), pushState: pushState, tab: tab.parentNode.firstChild.getAttribute("id")}, "", `#${tab.parentNode.firstChild.getAttribute("id")}`);
|
const tabId = tab.getAttribute("id");
|
||||||
pushState++;
|
const hash = `${tabNamespace}${tabId}`;
|
||||||
}
|
|
||||||
|
|
||||||
chooseTab(evt.currentTarget);
|
chooseTab(evt.currentTarget);
|
||||||
window.history.pushState({rand: Math.random(), pushState: pushState, tab: tab.getAttribute("id")}, "", `#${tab.getAttribute("id")}`);
|
|
||||||
pushState++;
|
window.history.pushState(
|
||||||
|
{ tab: tabId },
|
||||||
|
"",
|
||||||
|
`${location.pathname}${location.search}${hash}`
|
||||||
|
);
|
||||||
|
|
||||||
|
pushStateCount++;
|
||||||
});
|
});
|
||||||
|
|
||||||
tab.addEventListener("keypress", (e) => {
|
tab.addEventListener("keypress", (e) => {
|
||||||
e.preventDefault();
|
if (e.which === 32 || e.which === 13) {
|
||||||
if( e.which == 32 || e.which == 13 ) {
|
e.preventDefault();
|
||||||
e.currentTarget.dispatchEvent(click);
|
e.currentTarget.dispatchEvent(click);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
ul.querySelector("li").classList.add("selected");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.location.hash != "" && document.location.hash.substring(0,5) == "#tab-") {
|
ul.querySelector("li")?.classList.add("selected");
|
||||||
waitForElement(document.location.hash).then((el) => {
|
|
||||||
//el.scrollIntoView();
|
|
||||||
el.focus();
|
|
||||||
el.dispatchEvent(click);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("popstate", function (e) {
|
// Initial hash handling (tabs only)
|
||||||
e.preventDefault();
|
if (location.hash.startsWith(tabNamespace)) {
|
||||||
if (e.state != null) {
|
const tabId = location.hash.replace(tabNamespace, "");
|
||||||
chooseTab(document.querySelector(`#${e.state.tab}`));
|
waitForElement(`#${tabId}`).then(el => {
|
||||||
} else {
|
el.focus();
|
||||||
history.go(-1);
|
el.dispatchEvent(click);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// History navigation (tabs only)
|
||||||
|
window.addEventListener("popstate", (e) => {
|
||||||
|
if (!location.hash.startsWith(tabNamespace)) return;
|
||||||
|
if (e.state?.tab) {
|
||||||
|
const tab = document.querySelector(`#${e.state.tab}`);
|
||||||
|
if (tab) chooseTab(tab);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}</pre>
|
||||||
</pre>
|
|
||||||
</div>
|
</div>
|
||||||
</tabset>
|
</tabset>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -31,15 +31,57 @@
|
|||||||
<p><a href="#">Link with a tool tip<span role="tooltip" inert="inert" tip-position="right">Tool tip content</span></a></p>
|
<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">
|
<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-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
|
<pre class="language-pug" tab="pug">mixin tooltip(a)
|
||||||
span(role="tooltip" inert tip-position="right") Tool tip content</pre>
|
-
|
||||||
|
const required = ['text']
|
||||||
|
const optional = ['tip-position', 'tip-align', 'inert', 'role' ].concat(required)
|
||||||
|
|
||||||
|
// function to strip unallowed options.
|
||||||
|
const allowed = (obj, whitelist) => {
|
||||||
|
const set = new Set(whitelist);
|
||||||
|
const result = {};
|
||||||
|
for (const [k, v] of Object.entries(obj)) {
|
||||||
|
if (set.has(k)) result[k] = v;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default values
|
||||||
|
const defaults = {
|
||||||
|
"tip-position": "right",
|
||||||
|
inert: "inert",
|
||||||
|
role: "tooltip",
|
||||||
|
}
|
||||||
|
|
||||||
|
// unhyphenated to hypenated
|
||||||
|
const map = {
|
||||||
|
position: 'tip-position',
|
||||||
|
align: 'tip-align'
|
||||||
|
}
|
||||||
|
for (const [from, to] of Object.entries(map)) {
|
||||||
|
if (a[from] !== undefined) {
|
||||||
|
a[to] = a[from]
|
||||||
|
delete a[from]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// recheck for required and output if everything required is there.
|
||||||
|
if (a && required.some(key => !(key in a)))
|
||||||
|
p Missing keys: #{required.filter(key => !(key in a))}
|
||||||
|
else
|
||||||
|
-
|
||||||
|
text = a.text
|
||||||
|
a.text = undefined
|
||||||
|
a = allowed({...defaults, ...a}, optional)
|
||||||
|
|
||||||
|
tooltip&attributes(a)!= text</pre>
|
||||||
<pre class="language-css" tab="css">/* Position Options
|
<pre class="language-css" tab="css">/* Position Options
|
||||||
- top / block-start
|
- top / block-start
|
||||||
- right / inline-end
|
- right / inline-end
|
||||||
- bottom / block-end
|
- bottom / block-end
|
||||||
- left / inline-start
|
- left / inline-start
|
||||||
*/
|
*/
|
||||||
[role=tooltip] {
|
tooltip, tool-tip {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
color: #000;
|
color: #000;
|
||||||
@@ -73,7 +115,7 @@
|
|||||||
will-change: filter;
|
will-change: filter;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
[role=tooltip]::before {
|
tooltip::before, tool-tip::before {
|
||||||
clip-path: inset(50%);
|
clip-path: inset(50%);
|
||||||
clip: rect(1px, 1px, 1px, 1px);
|
clip: rect(1px, 1px, 1px, 1px);
|
||||||
content: "; Has tooltip: ";
|
content: "; Has tooltip: ";
|
||||||
@@ -84,7 +126,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
}
|
}
|
||||||
[role=tooltip]::after {
|
tooltip::after, tool-tip::after {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
content: "";
|
content: "";
|
||||||
inset: 0;
|
inset: 0;
|
||||||
@@ -93,21 +135,29 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=top],
|
tooltip:is([tip-position=top],
|
||||||
|
[tip-position=block-start],
|
||||||
|
:not([tip-position]),
|
||||||
|
[tip-position=bottom],
|
||||||
|
[tip-position=block-end]), tool-tip:is([tip-position=top],
|
||||||
[tip-position=block-start],
|
[tip-position=block-start],
|
||||||
:not([tip-position]),
|
:not([tip-position]),
|
||||||
[tip-position=bottom],
|
[tip-position=bottom],
|
||||||
[tip-position=block-end]) {
|
[tip-position=block-end]) {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=top],
|
tooltip:is([tip-position=top],
|
||||||
|
[tip-position=block-start],
|
||||||
|
:not([tip-position])), tool-tip:is([tip-position=top],
|
||||||
[tip-position=block-start],
|
[tip-position=block-start],
|
||||||
:not([tip-position])) {
|
:not([tip-position])) {
|
||||||
inset-inline-start: 50%;
|
inset-inline-start: 50%;
|
||||||
inset-block-end: calc(100% + 0.75rem + 1rem);
|
inset-block-end: calc(100% + 0.75rem + 1rem);
|
||||||
--tooltip-x: calc(50% * -1);
|
--tooltip-x: calc(50% * -1);
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=top],
|
tooltip:is([tip-position=top],
|
||||||
|
[tip-position=block-start],
|
||||||
|
:not([tip-position]))::after, tool-tip:is([tip-position=top],
|
||||||
[tip-position=block-start],
|
[tip-position=block-start],
|
||||||
:not([tip-position]))::after {
|
:not([tip-position]))::after {
|
||||||
--tooltip-pointer: conic-gradient(from -30deg at bottom, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) bottom/100% 50% no-repeat;
|
--tooltip-pointer: conic-gradient(from -30deg at bottom, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) bottom/100% 50% no-repeat;
|
||||||
@@ -115,39 +165,45 @@
|
|||||||
-webkit-border-after: 1rem solid transparent;
|
-webkit-border-after: 1rem solid transparent;
|
||||||
border-block-end: 1rem solid transparent;
|
border-block-end: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=right],
|
tooltip:is([tip-position=right],
|
||||||
|
[tip-position=inline-end]), tool-tip:is([tip-position=right],
|
||||||
[tip-position=inline-end]) {
|
[tip-position=inline-end]) {
|
||||||
inset-inline-start: calc(100% + 1.5rem + 1rem);
|
inset-inline-start: calc(100% + 1.5rem + 1rem);
|
||||||
inset-block-end: 50%;
|
inset-block-end: 50%;
|
||||||
--tooltip-y: 50%;
|
--tooltip-y: 50%;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=right],
|
tooltip:is([tip-position=right],
|
||||||
|
[tip-position=inline-end])::after, tool-tip:is([tip-position=right],
|
||||||
[tip-position=inline-end])::after {
|
[tip-position=inline-end])::after {
|
||||||
--tooltip-pointer: conic-gradient(from 60deg at left, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) left/50% 100% no-repeat;
|
--tooltip-pointer: conic-gradient(from 60deg at left, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) left/50% 100% no-repeat;
|
||||||
inset-inline-start: -1rem;
|
inset-inline-start: -1rem;
|
||||||
-webkit-border-start: 1rem solid transparent;
|
-webkit-border-start: 1rem solid transparent;
|
||||||
border-inline-start: 1rem solid transparent;
|
border-inline-start: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=bottom],
|
tooltip:is([tip-position=bottom],
|
||||||
|
[tip-position=block-end]), tool-tip:is([tip-position=bottom],
|
||||||
[tip-position=block-end]) {
|
[tip-position=block-end]) {
|
||||||
inset-inline-start: 50%;
|
inset-inline-start: 50%;
|
||||||
inset-block-start: calc(100% + 0.75rem + 1rem);
|
inset-block-start: calc(100% + 0.75rem + 1rem);
|
||||||
--tooltip-x: calc(50% * -1);
|
--tooltip-x: calc(50% * -1);
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=bottom],
|
tooltip:is([tip-position=bottom],
|
||||||
|
[tip-position=block-end])::after, tool-tip:is([tip-position=bottom],
|
||||||
[tip-position=block-end])::after {
|
[tip-position=block-end])::after {
|
||||||
--tooltip-pointer: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) top/100% 50% no-repeat;
|
--tooltip-pointer: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) top/100% 50% no-repeat;
|
||||||
inset-block-start: -1rem;
|
inset-block-start: -1rem;
|
||||||
-webkit-border-before: 1rem solid transparent;
|
-webkit-border-before: 1rem solid transparent;
|
||||||
border-block-start: 1rem solid transparent;
|
border-block-start: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=left],
|
tooltip:is([tip-position=left],
|
||||||
|
[tip-position=inline-start]), tool-tip:is([tip-position=left],
|
||||||
[tip-position=inline-start]) {
|
[tip-position=inline-start]) {
|
||||||
inset-inline-end: calc(100% + 1.5rem + 1rem);
|
inset-inline-end: calc(100% + 1.5rem + 1rem);
|
||||||
inset-block-end: 50%;
|
inset-block-end: 50%;
|
||||||
--tooltip-y: 50%;
|
--tooltip-y: 50%;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=left],
|
tooltip:is([tip-position=left],
|
||||||
|
[tip-position=inline-start])::after, tool-tip:is([tip-position=left],
|
||||||
[tip-position=inline-start])::after {
|
[tip-position=inline-start])::after {
|
||||||
--tooltip-pointer: conic-gradient(from -120deg at right, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) right/50% 100% no-repeat;
|
--tooltip-pointer: conic-gradient(from -120deg at right, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) right/50% 100% no-repeat;
|
||||||
inset-inline-end: -1rem;
|
inset-inline-end: -1rem;
|
||||||
@@ -155,21 +211,21 @@
|
|||||||
border-inline-end: 1rem solid transparent;
|
border-inline-end: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
[role=tooltip] {
|
tooltip, tool-tip {
|
||||||
background: #1f2127;
|
background: #1f2127;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
-webkit-filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
-webkit-filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
||||||
filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
||||||
}
|
}
|
||||||
[role=tooltip]::after {
|
tooltip::after, tool-tip::after {
|
||||||
background: #1f2127;
|
background: #1f2127;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:has(> [role=tooltip]) {
|
:has(> tooltip), :has(> tool-tip) {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]):is(:hover, :focus-visible, :active) > [role=tooltip] {
|
:has(> tooltip):is(:hover, :focus-visible, :active) > tool-tip, :has(> tooltip):is(:hover, :focus-visible, :active) > tooltip, :has(> tool-tip):is(:hover, :focus-visible, :active) > tool-tip, :has(> tool-tip):is(:hover, :focus-visible, :active) > tooltip {
|
||||||
display: block;
|
display: block;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
-webkit-transition-delay: 300ms;
|
-webkit-transition-delay: 300ms;
|
||||||
@@ -177,16 +233,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
:has(> [role=tooltip]:is([tip-position=top], [tip-position=block-start], :not([tip-position]))):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=top], [tip-position=block-start], :not([tip-position]))):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=top], [tip-position=block-start], :not([tip-position]))):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: 3px;
|
--tooltip-y: 3px;
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]:is([tip-position=right], [tip-position=inline-end])):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=right], [tip-position=inline-end])):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=right], [tip-position=inline-end])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * -3px * -1);
|
--tooltip-x: calc(-1 * -3px * -1);
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]:is([tip-position=bottom], [tip-position=block-end])):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=bottom], [tip-position=block-end])):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=bottom], [tip-position=block-end])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: -3px;
|
--tooltip-y: -3px;
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]:is([tip-position=left], [tip-position=inline-start])):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=left], [tip-position=inline-start])):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=left], [tip-position=inline-start])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * 3px * -1);
|
--tooltip-x: calc(-1 * 3px * -1);
|
||||||
}
|
}
|
||||||
}</pre>
|
}</pre>
|
||||||
@@ -221,7 +281,7 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@mixin tooltip {
|
@mixin tooltip {
|
||||||
[role="tooltip"] {
|
tooltip, tool-tip {
|
||||||
background: $tooltip-light-background;
|
background: $tooltip-light-background;
|
||||||
border-radius: $tooltip-border-radius;
|
border-radius: $tooltip-border-radius;
|
||||||
color: $tooltip-light-foreground;
|
color: $tooltip-light-foreground;
|
||||||
@@ -346,9 +406,10 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:has(> [role="tooltip"]) {
|
:has(> tooltip), :has(> tool-tip) {
|
||||||
position: relative;
|
position: relative;
|
||||||
&:is(:hover, :focus-visible, :active) > [role="tooltip"] {
|
&:is(:hover, :focus-visible, :active) > tool-tip,
|
||||||
|
&:is(:hover, :focus-visible, :active) > tooltip {
|
||||||
display: block;
|
display: block;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transition-delay: 300ms;
|
transition-delay: 300ms;
|
||||||
@@ -356,20 +417,20 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
:has(> tool-tip:is([tip-position="top"], [tip-position="block-start"], :not([tip-position]))):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="top"], [tip-position="block-start"], :not([tip-position]))):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="top"], [tip-position="block-start"], :not([tip-position]))):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: 3px;
|
--tooltip-y: 3px;
|
||||||
}
|
}
|
||||||
|
:has(> tool-tip:is([tip-position="right"], [tip-position="inline-end"])):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="right"], [tip-position="inline-end"])):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="right"], [tip-position="inline-end"])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * -3px * -1);
|
--tooltip-x: calc(-1 * -3px * -1);
|
||||||
}
|
}
|
||||||
|
:has(> tool-tip:is([tip-position="bottom"], [tip-position="block-end"])):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="bottom"], [tip-position="block-end"])):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="bottom"], [tip-position="block-end"])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: -3px;
|
--tooltip-y: -3px;
|
||||||
}
|
}
|
||||||
|
:has(> tool-tip:is([tip-position="left"], [tip-position="inline-start"])):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="left"], [tip-position="inline-start"])):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="left"], [tip-position="inline-start"])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * 3px * -1);
|
--tooltip-x: calc(-1 * 3px * -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,93 +1,85 @@
|
|||||||
//-
|
//-
|
||||||
DS2 core (c) 2024 Alexander McIlwraith
|
DS2 core (c) 2024 Alexander McIlwraith
|
||||||
Core licensed under CC BY-SA 4.0
|
Core licensed under CC BY-SA 4.0
|
||||||
|
|
||||||
- const getDate = function(){
|
- const getDate = function(){
|
||||||
- var d = new Date();
|
- var d = new Date();
|
||||||
- return d.toLocaleDateString(lang, {day: "numeric", month: "long", year: "numeric"});
|
- return d.toLocaleDateString(lang, {day: "numeric", month: "long", year: "numeric"});
|
||||||
- }
|
- }
|
||||||
- String.prototype.toTitleCase = function() {
|
- String.prototype.toTitleCase = function() {
|
||||||
- return this.replace(/\w\S*/g, function(txt) {
|
- return this.replace(/\w\S*/g, function(txt) {
|
||||||
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
- });
|
- });
|
||||||
- }
|
- }
|
||||||
- String.prototype.toSentenceCase = function() {
|
- String.prototype.toSentenceCase = function() {
|
||||||
- return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
|
- return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase();
|
||||||
- }
|
- }
|
||||||
- String.prototype.toContent = function() {
|
- String.prototype.toContent = function() {
|
||||||
- return this.replace(/-/g, " ");
|
- return this.replace(/-/g, " ");
|
||||||
- }
|
- }
|
||||||
- String.prototype.toPath = function() {
|
- String.prototype.toPath = function() {
|
||||||
- return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-");
|
- return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-");
|
||||||
- }
|
- }
|
||||||
|
|
||||||
include ../_config
|
include ../_config
|
||||||
block config
|
block config
|
||||||
|
|
||||||
|
|
||||||
mixin show-content(items, path)
|
mixin show-content(items, path)
|
||||||
|
|
||||||
- path = (path == "" ? "" : path + "/") + items.name.toPath()
|
- path = (path == "" ? "" : path + "/") + items.name.toPath()
|
||||||
|
|
||||||
if items.core == true
|
if items.core == true
|
||||||
- items.status = "complete"
|
- items.status = "complete"
|
||||||
|
|
||||||
article(id=path.replace(/\//g, "-").toPath()
|
article(id=path.replace(/\//g, "-").toPath()
|
||||||
data-name=items.name
|
data-name=items.name
|
||||||
data-status=items.status
|
data-status=items.status
|
||||||
data-display=items.display
|
data-display=items.display
|
||||||
data-template=(items.template == undefined ? "pug" : items.template)
|
data-template=(items.template == undefined ? "pug" : items.template)
|
||||||
data-core= (items.core ? "true" : "false")
|
data-core= (items.core ? "true" : "false")
|
||||||
data-path=path
|
data-path=path
|
||||||
style="height: 100vh"
|
style="height: 100vh"
|
||||||
)
|
)
|
||||||
if items.display
|
if items.display
|
||||||
h1(class="status-" + items.status )
|
h1(class="status-" + items.status )
|
||||||
span= items.display
|
span= items.display
|
||||||
tool-tip(role="tooltip" inert tip-position="right")= items.status.toSentenceCase().toContent()
|
tool-tip(role="tooltip" inert tip-position="right")= items.status.toSentenceCase().toContent()
|
||||||
else
|
else
|
||||||
h1(class="status-" + items.status )
|
h1(class="status-" + items.status )
|
||||||
span= items.name.toSentenceCase().toContent()
|
span= items.name.toSentenceCase().toContent()
|
||||||
tool-tip(role="tooltip" inert tip-position="right")= items.status.toSentenceCase().toContent()
|
tool-tip(role="tooltip" inert tip-position="right")= items.status.toSentenceCase().toContent()
|
||||||
if items.files
|
if items.files
|
||||||
each item in items.files
|
each item in items.files
|
||||||
+show-content(item, path)
|
+show-content(item, path)
|
||||||
|
|
||||||
|
|
||||||
doctype html
|
doctype html
|
||||||
html(lang= lang )
|
html(lang= lang )
|
||||||
head
|
head
|
||||||
meta(charset="utf-8")
|
meta(charset="utf-8")
|
||||||
meta(http-equiv="X-UA-Compatible" content="IE=edge")
|
meta(http-equiv="X-UA-Compatible" content="IE=edge")
|
||||||
meta(name="viewport" content="width=device-width, initial-scale=1")
|
meta(name="viewport" content="width=device-width, initial-scale=1")
|
||||||
|
|
||||||
title(data-site= site )= site
|
title(data-site= site )= site
|
||||||
|
|
||||||
block head
|
block head
|
||||||
link( href="assets/scaffolding.css" rel="stylesheet" )
|
link( href="assets/scaffolding.css" rel="stylesheet" )
|
||||||
|
|
||||||
body
|
body
|
||||||
//
|
//
|
||||||
DS2 core (c) 2024 Alexander McIlwraith
|
DS2 core (c) 2024 Alexander McIlwraith
|
||||||
Core licensed under CC BY-SA 4.0
|
Core licensed under CC BY-SA 4.0
|
||||||
|
|
||||||
|
|
||||||
a.skip(href="#main") Skip to main content
|
a.skip(href="#main") Skip to main content
|
||||||
|
|
||||||
block top
|
block header
|
||||||
|
div.container
|
||||||
div.container
|
main#main
|
||||||
|
h1= site
|
||||||
block header
|
each category in content
|
||||||
|
+show-content(category, "")
|
||||||
main#main
|
block footer
|
||||||
|
|
||||||
h1= site
|
script(src="assets/scaffolding-min.js")
|
||||||
each category in content
|
|
||||||
+show-content(category, "")
|
|
||||||
|
|
||||||
block footer
|
|
||||||
|
|
||||||
block bottom
|
|
||||||
|
|
||||||
script(src="assets/scaffolding-min.js")
|
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
include ../_config
|
include ../_config
|
||||||
block config
|
block config
|
||||||
|
|
||||||
mixin h(h)
|
mixin h(h, p = null)
|
||||||
if headings[h]
|
- text = headings[h]
|
||||||
if headings[h].indexOf("|") == -1
|
if p !== null
|
||||||
h2= headings[h]
|
- text = text.replace(/\*\*/g, p)
|
||||||
|
|
||||||
|
|
||||||
|
if text
|
||||||
|
if text.indexOf("|") == -1
|
||||||
|
h2= text
|
||||||
else
|
else
|
||||||
- var cntnt = headings[h].split("|")
|
- var cntnt = text.split("|")
|
||||||
| <#{cntnt[0]}>#{cntnt[1]}</#{cntnt[0]}>
|
| <#{cntnt[0]}>#{cntnt[1]}</#{cntnt[0]}>
|
||||||
|
|
||||||
- const getDate = function(){
|
- const getDate = function(){
|
||||||
|
|||||||
@@ -8,14 +8,17 @@ block head
|
|||||||
link(rel="icon" href="https://assets.gamv.ca/favicon-dark.svg" media="(prefers-color-scheme:dark)")
|
link(rel="icon" href="https://assets.gamv.ca/favicon-dark.svg" media="(prefers-color-scheme:dark)")
|
||||||
|
|
||||||
block header
|
block header
|
||||||
include patterns/core/header/_header.pug
|
div.container
|
||||||
|
include patterns/core/header/_header.pug
|
||||||
nav
|
|
||||||
ul
|
nav
|
||||||
each first in content
|
ul
|
||||||
li(class= navClass)
|
each first in content
|
||||||
a(href="./?p=" + first.name.toPath() )= first.name.toContent().toSentenceCase()
|
li(class= navClass)
|
||||||
|
a(href="./?p=" + first.name.toPath() )= first.name.toContent().toSentenceCase()
|
||||||
|
|
||||||
|
|
||||||
|
block body-top
|
||||||
p.info-switches
|
p.info-switches
|
||||||
span
|
span
|
||||||
span#deprecated(role="switch")
|
span#deprecated(role="switch")
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
jQuery(document).ready(function($){
|
|
||||||
$(".tab-group").each(function(){
|
|
||||||
if ($(this).children('[role="tablist"]').length > 0) {
|
|
||||||
let tabgroup = $(this).attr("id"),
|
|
||||||
tablist = "";
|
|
||||||
$(this).children("*").each(function(){
|
|
||||||
let tab = $(this).attr("data-tab");
|
|
||||||
if (typeof tab !== 'undefined' && tab !== false) {
|
|
||||||
let tabID = tab.replace(/\W+/g,"-").toLowerCase();
|
|
||||||
$(this).wrap(`<div id="tab-panel-${tabgroup + "-" + tabID }" ${(tablist == "" ? "class='open'" : "")} role="tabpanel" tabindex="0" aria-labeledby="tab-${tabgroup + "-" + tabID }"></div>`);
|
|
||||||
tablist += `<li role="tab" ${(tablist == "" ? "class='selected'" : "")} id="tab-${tabgroup + "-" + tab.replace(/\W+/g,"-").toLowerCase()}"><span>${tab}</span></li>`;
|
|
||||||
} else {
|
|
||||||
$(this).addClass("tab-hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
$(this).prepend(`<ul role="tablist">${tablist}<li role="separator" class="separator"></li></ul>`);
|
|
||||||
|
|
||||||
$(this).children('[role="tab"]').on("click", function(){
|
|
||||||
$(this).parent().children('[role="tab"]').removeClass("selected");
|
|
||||||
$(this).addClass("selected");
|
|
||||||
$(this).parent().parent().children('[role="tabpanel"]').removeClass("open");
|
|
||||||
$("#" + $(this).attr("id").replace("tab", "tab-panel")).addClass("open");
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,192 +1,306 @@
|
|||||||
/* DS2 core (c) 2024-2026 Alexander McIlwraith
|
/* DS2 core (c) 2024-2026 Alexander McIlwraith
|
||||||
Released under Creative Commons Attribution-ShareAlike 4.0 International
|
Released under Creative Commons Attribution-ShareAlike 4.0 International
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// create a pure JS mouse click event
|
// create a pure JS mouse click event
|
||||||
const click = new MouseEvent('click', {
|
const click = new MouseEvent('click', {
|
||||||
view: window,
|
view: window,
|
||||||
bubbles: false,
|
bubbles: false,
|
||||||
cancelable: true
|
cancelable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// wait for an element to appear in the DOM
|
// wait for an element to appear in the DOM
|
||||||
const waitForElement = (selector) => {
|
const waitForElement = (selector) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (document.querySelector(selector)) {
|
if (document.querySelector(selector)) {
|
||||||
return resolve(document.querySelector(selector));
|
return resolve(document.querySelector(selector));
|
||||||
}
|
}
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
if (document.querySelector(selector)) {
|
if (document.querySelector(selector)) {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
resolve(document.querySelector(selector));
|
resolve(document.querySelector(selector));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
observer.observe(document.body, {
|
observer.observe(document.body, {
|
||||||
childList: true,
|
childList: true,
|
||||||
subtree: true
|
subtree: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tab logic
|
// Tab logic
|
||||||
const tabNamespace = "#tab:";
|
const tabNamespace = "#tab:";
|
||||||
|
|
||||||
const chooseTab = (tab) => {
|
const chooseTab = (tab) => {
|
||||||
const siblings = Array.from(tab.parentNode.children);
|
const siblings = Array.from(
|
||||||
siblings.forEach(sibling => sibling.classList.remove("selected"));
|
tab.closest('[role="tablist"]').querySelectorAll('[role="tab"]')
|
||||||
tab.classList.add("selected");
|
);
|
||||||
|
siblings.forEach(sibling => sibling.classList.remove("selected"));
|
||||||
const tabPanels = Array.from(tab.parentNode.parentNode.children);
|
tab.classList.add("selected");
|
||||||
tabPanels.forEach(panel => panel.classList.remove("open"));
|
|
||||||
|
const tabGroup = tab.closest("tabset, .tab-group");
|
||||||
const tabPanelId = tab
|
const tabPanels = Array.from(
|
||||||
.getAttribute("id")
|
tabGroup.querySelectorAll('[role="tabpanel"]')
|
||||||
.replace("tab", "tab-panel");
|
);
|
||||||
|
|
||||||
document
|
tabPanels.forEach(panel => panel.classList.remove("open"));
|
||||||
.getElementById(tabPanelId)
|
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
|
||||||
.classList.add("open");
|
document.getElementById(tabPanelId).classList.add("open");
|
||||||
};
|
};
|
||||||
|
|
||||||
let pushStateCount = 0;
|
let pushStateCount = 0;
|
||||||
let tabsetCount = 0;
|
let tabsetCount = 0;
|
||||||
|
|
||||||
export function init(container = document, spacer = true) {
|
export function init(container = document, spacer = true) {
|
||||||
|
container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
|
||||||
container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
|
|
||||||
|
if (tabGroup.querySelector('[role="tablist"]') === null) {
|
||||||
if (tabGroup.querySelector('[role="tablist"]') === null) {
|
|
||||||
|
if (tabGroup.getAttribute("id") == null) {
|
||||||
if (tabGroup.getAttribute("id") == null) {
|
tabGroup.setAttribute("id", `tab-group-${tabsetCount++}`);
|
||||||
tabGroup.setAttribute("id", `tab-group-${tabsetCount++}`);
|
}
|
||||||
}
|
|
||||||
|
const tabgroup = tabGroup.getAttribute("id");
|
||||||
const tabgroup = tabGroup.getAttribute("id");
|
let tablist = "";
|
||||||
let tablist = "";
|
|
||||||
|
Array.from(tabGroup.children).forEach(child => {
|
||||||
Array.from(tabGroup.children).forEach(child => {
|
|
||||||
|
const isDetails = child.nodeName === "DETAILS";
|
||||||
const isDetails = child.nodeName === "DETAILS";
|
const tabLabel = isDetails ? child.querySelector("summary")?.innerHTML : child.getAttribute("tab") || child.getAttribute("data-tab");
|
||||||
const tabLabel =
|
|
||||||
isDetails
|
if (tabLabel !== null) {
|
||||||
? child.querySelector("summary")?.innerHTML
|
|
||||||
: child.getAttribute("tab") || child.getAttribute("data-tab");
|
const tabID = tabLabel.replace(/\W+/g, "-").toLowerCase();
|
||||||
|
let tabPanel;
|
||||||
if (tabLabel !== null) {
|
|
||||||
|
if (isDetails) {
|
||||||
const tabID = tabLabel.replace(/\W+/g, "-").toLowerCase();
|
tabPanel = child;
|
||||||
let tabPanel;
|
tabPanel.setAttribute("open", "");
|
||||||
|
} else {
|
||||||
if (isDetails) {
|
tabPanel = document.createElement("div");
|
||||||
tabPanel = child;
|
tabPanel.appendChild(child.cloneNode(true));
|
||||||
tabPanel.setAttribute("open", "");
|
}
|
||||||
} else {
|
|
||||||
tabPanel = document.createElement("div");
|
tabPanel.id = `tab-panel-${tabgroup}-${tabID}`;
|
||||||
tabPanel.appendChild(child.cloneNode(true));
|
tabPanel.className = tablist === "" ? "open" : "";
|
||||||
}
|
tabPanel.setAttribute("role", "tabpanel");
|
||||||
|
tabPanel.setAttribute("tabindex", "0");
|
||||||
tabPanel.id = `tab-panel-${tabgroup}-${tabID}`;
|
tabPanel.setAttribute(
|
||||||
tabPanel.className = tablist === "" ? "open" : "";
|
"aria-labelledby",
|
||||||
tabPanel.setAttribute("role", "tabpanel");
|
`tab-${tabgroup}-${tabID}`
|
||||||
tabPanel.setAttribute("tabindex", "0");
|
);
|
||||||
tabPanel.setAttribute(
|
|
||||||
"aria-labelledby",
|
child.parentNode.replaceChild(tabPanel, child);
|
||||||
`tab-${tabgroup}-${tabID}`
|
|
||||||
);
|
tablist += `<li tabindex="0" role="tab" id="tab-${tabgroup}-${tabID}">
|
||||||
|
<span>${tabLabel}</span>
|
||||||
child.parentNode.replaceChild(tabPanel, child);
|
</li>`;
|
||||||
|
} else {
|
||||||
tablist += `
|
child.classList.add("tab-hidden");
|
||||||
<li
|
}
|
||||||
tabindex="0"
|
});
|
||||||
role="tab"
|
|
||||||
id="tab-${tabgroup}-${tabID}"
|
const ul = document.createElement("ul");
|
||||||
>
|
ul.setAttribute("role", "tablist");
|
||||||
<span>${tabLabel}</span>
|
tabGroup.insertBefore(ul, tabGroup.firstChild);
|
||||||
</li>
|
|
||||||
`;
|
|
||||||
} else {
|
const wrapper = document.createElement("div");
|
||||||
child.classList.add("tab-hidden");
|
wrapper.className = "tab-scroll-wrapper";
|
||||||
}
|
|
||||||
});
|
const scroller = document.createElement("div");
|
||||||
|
scroller.className = "tab-scroll";
|
||||||
const ul = document.createElement("ul");
|
|
||||||
ul.setAttribute("role", "tablist");
|
const leftArrow = document.createElement("div");
|
||||||
tabGroup.insertBefore(ul, tabGroup.firstChild);
|
leftArrow.className = "tab-scroll-arrow left";
|
||||||
|
|
||||||
ul.innerHTML = spacer !== true
|
leftArrow.setAttribute("aria-hidden", "true");
|
||||||
? tablist
|
|
||||||
: `${tablist}<li role="separator" class="separator"></li>`;
|
leftArrow.innerHTML = `
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" width="24" height="24">
|
||||||
// Tab ordering
|
<path d="M400-80 0-480l400-400 71 71-329 329 329 329-71 71Z"/>
|
||||||
if (tabGroup.hasAttribute("order") || tabGroup.hasAttribute("data-order")) {
|
</svg>
|
||||||
|
`;
|
||||||
const order = (
|
|
||||||
tabGroup.getAttribute("order") ||
|
const rightArrow = document.createElement("div");
|
||||||
tabGroup.getAttribute("data-order")
|
rightArrow.className = "tab-scroll-arrow right";
|
||||||
).split(",");
|
|
||||||
|
rightArrow.setAttribute("aria-hidden", "true");
|
||||||
const items = Array.from(ul.getElementsByTagName("li"));
|
|
||||||
|
rightArrow.innerHTML = `
|
||||||
items.sort((a, b) => {
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" width="24" height="24">
|
||||||
const aa = order.indexOf(a.textContent.trim());
|
<path d="m321-80-71-71 329-329-329-329 71-71 400 400L321-80Z"/>
|
||||||
const bb = order.indexOf(b.textContent.trim());
|
</svg>
|
||||||
if (aa === -1) return 1;
|
`;
|
||||||
if (bb === -1) return -1;
|
|
||||||
return aa - bb;
|
ul.parentNode.insertBefore(wrapper, ul);
|
||||||
});
|
wrapper.appendChild(scroller);
|
||||||
|
wrapper.appendChild(leftArrow);
|
||||||
ul.innerHTML = "";
|
wrapper.appendChild(rightArrow);
|
||||||
items.forEach(item => ul.appendChild(item));
|
scroller.appendChild(ul);
|
||||||
chooseTab(items[0]);
|
|
||||||
}
|
const updateScrollState = () => {
|
||||||
|
const isOverflowing = scroller.scrollWidth > scroller.clientWidth;
|
||||||
// Tab event handlers
|
|
||||||
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
|
wrapper.classList.toggle("is-overflowing", isOverflowing);
|
||||||
|
|
||||||
tab.addEventListener("click", (evt) => {
|
const atStart = scroller.scrollLeft <= 1;
|
||||||
|
const atEnd = scroller.scrollLeft + scroller.clientWidth >= scroller.scrollWidth - 2;
|
||||||
const tabId = tab.getAttribute("id");
|
|
||||||
const hash = `${tabNamespace}${tabId}`;
|
leftArrow.classList.toggle("hidden", !isOverflowing || atStart);
|
||||||
|
rightArrow.classList.toggle("hidden", !isOverflowing || atEnd);
|
||||||
chooseTab(evt.currentTarget);
|
|
||||||
|
|
||||||
window.history.pushState(
|
wrapper.classList.toggle("show-left", isOverflowing && !atStart);
|
||||||
{ tab: tabId },
|
wrapper.classList.toggle("show-right", isOverflowing && !atEnd);
|
||||||
"",
|
|
||||||
`${location.pathname}${location.search}${hash}`
|
};
|
||||||
);
|
|
||||||
|
const scrollAmount = 15; // smaller = smoother per frame
|
||||||
pushStateCount++;
|
const scrollInterval = 16; // ~60fps
|
||||||
});
|
|
||||||
|
let scrollTimer = null;
|
||||||
tab.addEventListener("keypress", (e) => {
|
|
||||||
if (e.which === 32 || e.which === 13) {
|
const startScrolling = (direction) => {
|
||||||
e.preventDefault();
|
if (scrollTimer) return;
|
||||||
e.currentTarget.dispatchEvent(click);
|
|
||||||
}
|
let speed = 0.1;
|
||||||
});
|
|
||||||
});
|
scrollTimer = setInterval(() => {
|
||||||
|
speed = Math.min(speed + 0.01, 5); // ramp up
|
||||||
ul.querySelector("li")?.classList.add("selected");
|
scroller.scrollBy({
|
||||||
}
|
left: direction * scrollAmount * speed,
|
||||||
});
|
behavior: "auto"
|
||||||
|
});
|
||||||
// Initial hash handling (tabs only)
|
}, scrollInterval);
|
||||||
if (location.hash.startsWith(tabNamespace)) {
|
};
|
||||||
const tabId = location.hash.replace(tabNamespace, "");
|
|
||||||
waitForElement(`#${tabId}`).then(el => {
|
|
||||||
el.focus();
|
const stopScrolling = () => {
|
||||||
el.dispatchEvent(click);
|
clearInterval(scrollTimer);
|
||||||
});
|
scrollTimer = null;
|
||||||
}
|
};
|
||||||
|
leftArrow.addEventListener("mousedown", () => startScrolling(-1));
|
||||||
// History navigation (tabs only)
|
leftArrow.addEventListener("mouseup", stopScrolling);
|
||||||
window.addEventListener("popstate", (e) => {
|
leftArrow.addEventListener("mouseleave", stopScrolling);
|
||||||
if (!location.hash.startsWith(tabNamespace)) return;
|
|
||||||
if (e.state?.tab) {
|
leftArrow.addEventListener("touchstart", () => startScrolling(-1));
|
||||||
const tab = document.querySelector(`#${e.state.tab}`);
|
leftArrow.addEventListener("touchend", stopScrolling);
|
||||||
if (tab) chooseTab(tab);
|
|
||||||
}
|
rightArrow.addEventListener("mousedown", () => startScrolling(1));
|
||||||
});
|
rightArrow.addEventListener("mouseup", stopScrolling);
|
||||||
|
rightArrow.addEventListener("mouseleave", stopScrolling);
|
||||||
|
|
||||||
|
rightArrow.addEventListener("touchstart", () => startScrolling(1));
|
||||||
|
rightArrow.addEventListener("touchend", stopScrolling);
|
||||||
|
|
||||||
|
const ARROW_ZONE = 40;
|
||||||
|
|
||||||
|
wrapper.addEventListener("contextmenu", (e) => {
|
||||||
|
const isOverflowing = wrapper.classList.contains("is-overflowing");
|
||||||
|
if (!isOverflowing) return;
|
||||||
|
|
||||||
|
const rect = wrapper.getBoundingClientRect();
|
||||||
|
|
||||||
|
const isLeftZone = e.clientX < rect.left + ARROW_ZONE;
|
||||||
|
const isRightZone = e.clientX > rect.right - ARROW_ZONE;
|
||||||
|
|
||||||
|
if (isLeftZone || isRightZone) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const scrollClickAmount = 150;
|
||||||
|
|
||||||
|
leftArrow.addEventListener("click", () => {
|
||||||
|
scroller.scrollBy({ left: -scrollClickAmount, behavior: "smooth" });
|
||||||
|
});
|
||||||
|
|
||||||
|
rightArrow.addEventListener("click", () => {
|
||||||
|
scroller.scrollBy({ left: scrollClickAmount, behavior: "smooth" });
|
||||||
|
});
|
||||||
|
|
||||||
|
scroller.addEventListener("scroll", updateScrollState);
|
||||||
|
window.addEventListener("resize", updateScrollState);
|
||||||
|
|
||||||
|
updateScrollState();
|
||||||
|
ul.innerHTML = spacer !== true ? tablist : `${tablist}<li aria-hidden="true" class="separator"></li>`;
|
||||||
|
|
||||||
|
requestAnimationFrame(updateScrollState);
|
||||||
|
setTimeout(updateScrollState, 50);
|
||||||
|
|
||||||
|
ul.innerHTML = spacer !== true ? tablist : `${tablist}<li aria-hidden="true" class="separator"></li>`;
|
||||||
|
|
||||||
|
// Tab ordering
|
||||||
|
if (tabGroup.hasAttribute("order") || tabGroup.hasAttribute("data-order")) {
|
||||||
|
|
||||||
|
const order = (
|
||||||
|
tabGroup.getAttribute("order") ||
|
||||||
|
tabGroup.getAttribute("data-order")
|
||||||
|
).split(",");
|
||||||
|
|
||||||
|
const items = Array.from(ul.getElementsByTagName("li"));
|
||||||
|
|
||||||
|
items.sort((a, b) => {
|
||||||
|
const aa = order.indexOf(a.textContent.trim());
|
||||||
|
const bb = order.indexOf(b.textContent.trim());
|
||||||
|
if (aa === -1) return 1;
|
||||||
|
if (bb === -1) return -1;
|
||||||
|
return aa - bb;
|
||||||
|
});
|
||||||
|
|
||||||
|
ul.innerHTML = "";
|
||||||
|
items.forEach(item => ul.appendChild(item));
|
||||||
|
chooseTab(items[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tab event handlers
|
||||||
|
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
|
||||||
|
|
||||||
|
tab.addEventListener("click", (evt) => {
|
||||||
|
|
||||||
|
const tabId = tab.getAttribute("id");
|
||||||
|
const hash = `${tabNamespace}${tabId}`;
|
||||||
|
|
||||||
|
chooseTab(evt.currentTarget);
|
||||||
|
|
||||||
|
window.history.pushState(
|
||||||
|
{ tab: tabId },
|
||||||
|
"",
|
||||||
|
`${location.pathname}${location.search}${hash}`
|
||||||
|
);
|
||||||
|
|
||||||
|
pushStateCount++;
|
||||||
|
});
|
||||||
|
|
||||||
|
tab.addEventListener("keypress", (e) => {
|
||||||
|
if (e.which === 32 || e.which === 13) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.currentTarget.dispatchEvent(click);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ul.querySelector("li")?.classList.add("selected");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initial hash handling (tabs only)
|
||||||
|
if (location.hash.startsWith(tabNamespace)) {
|
||||||
|
const tabId = location.hash.replace(tabNamespace, "");
|
||||||
|
waitForElement(`#${tabId}`).then(el => {
|
||||||
|
el.focus();
|
||||||
|
el.dispatchEvent(click);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// History navigation (tabs only)
|
||||||
|
window.addEventListener("popstate", (e) => {
|
||||||
|
if (!location.hash.startsWith(tabNamespace)) return;
|
||||||
|
if (e.state?.tab) {
|
||||||
|
const tab = document.querySelector(`#${e.state.tab}`);
|
||||||
|
if (tab) chooseTab(tab);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -1,78 +1,215 @@
|
|||||||
// DS2 core (c) 2024 Alexander McIlwraith
|
$tab-border: #7f7f7f !default;
|
||||||
// Licensed under CC BY-SA 4.0
|
|
||||||
|
$tab-selected: #FFF !default;
|
||||||
$tab-border: #7f7f7f !default;
|
$tab-selected-text: #000 !default;
|
||||||
$tab-panel-background-color: #FFF !default;
|
|
||||||
$tab-panel-top-border: #7f7f7f !default;
|
$tab-notselected: #f0f0f0 !default;
|
||||||
$tab-panel-top-border-width: 1px !default;
|
$tab-notselected-text: #000 !default;
|
||||||
$tab-selected: #FFF !default;
|
|
||||||
$tab-selected-text: #000 !default;
|
@mixin tabs {
|
||||||
$tab-notselected: #f0f0f0 !default;
|
|
||||||
$tab-notselected-text: #000 !default;
|
tabset, .tab-group {
|
||||||
|
|
||||||
@mixin tabs {
|
margin: 2rem 0 1rem 0;
|
||||||
tabset, .tab-group {
|
|
||||||
margin: 2rem 0 1rem 0;
|
[role="tablist"] li.selected {
|
||||||
|
background-color: var(--color-blue);
|
||||||
[role="tablist"] {
|
color: var(--color-white);
|
||||||
display: flex;
|
}
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
> ul,
|
||||||
|
.tab-scroll > ul {
|
||||||
|
display: flex;
|
||||||
li {
|
margin: 0;
|
||||||
&.separator {
|
padding: 0;
|
||||||
border-bottom: 1px solid $tab-border;
|
user-select: none;
|
||||||
display: inline-block;
|
|
||||||
margin: .45rem 0 0 0;
|
li.separator {
|
||||||
width: 100%;
|
border-bottom: 1px solid $tab-border;
|
||||||
}
|
border-left: 1px solid $tab-border;
|
||||||
|
display: inline-block;
|
||||||
&[role="tab"] {
|
flex: 1 1 auto;
|
||||||
background-color: $tab-selected;
|
margin: .45rem 0 0 0;
|
||||||
border-left: 1px solid $tab-border;
|
width: auto;
|
||||||
border-right: 1px solid $tab-border;
|
}
|
||||||
border-radius: .5rem .5rem 0 0;
|
}
|
||||||
border-top: 1px solid $tab-border;
|
|
||||||
cursor:pointer;
|
.tab-hidden {
|
||||||
display: inline;
|
display: none;
|
||||||
margin: 0;
|
}
|
||||||
padding: 1rem 1.5rem .14rem 1.5rem;
|
|
||||||
z-index: 2;
|
[role="tab"] {
|
||||||
|
background-color: $tab-selected;
|
||||||
&:last-of-type {
|
border-left: 1px solid $tab-border;
|
||||||
border-right: 1px solid $tab-border;
|
border-radius: .5rem .5rem 0 0;
|
||||||
}
|
border-top: 1px solid $tab-border;
|
||||||
|
cursor: pointer;
|
||||||
&:not(.selected) {
|
display: block;
|
||||||
background-color: $tab-notselected;
|
flex: 0 0 auto;
|
||||||
border-bottom: 1px solid $tab-border;
|
margin: 0;
|
||||||
/// color
|
max-width: 100vw;
|
||||||
}
|
overflow: hidden;
|
||||||
|
padding: 1rem 1.5rem .14rem 1.5rem;
|
||||||
span {
|
user-select: none;
|
||||||
display: block;
|
white-space: normal;
|
||||||
margin: 0 0 .5rem 0;
|
word-break: break-word;
|
||||||
}
|
|
||||||
}
|
&:last-of-type {
|
||||||
}
|
border-right: 1px solid $tab-border;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-hidden {
|
&:not(.selected) {
|
||||||
display: none;
|
background-color: $tab-notselected;
|
||||||
}
|
border-bottom: 1px solid $tab-border;
|
||||||
|
}
|
||||||
[role="tabpanel"] {
|
|
||||||
background-color: $tab-selected;
|
span {
|
||||||
border: 1px solid $tab-border;
|
display: block;
|
||||||
border-top: none;
|
margin: 0 0 .5rem 0;
|
||||||
padding: 1rem;
|
}
|
||||||
z-index: 1;
|
}
|
||||||
|
|
||||||
&:not(.open) {
|
[role="tabpanel"] {
|
||||||
display: none;
|
background-color: $tab-selected;
|
||||||
}
|
border: 1px solid $tab-border;
|
||||||
}
|
border-top: none;
|
||||||
@content;
|
padding: 1rem;
|
||||||
}
|
z-index: 1;
|
||||||
|
|
||||||
|
&:not(.open) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scroller
|
||||||
|
.tab-scroll {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
> ul {
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
min-width: 100%;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrapper (now owns the fade)
|
||||||
|
.tab-scroll-wrapper {
|
||||||
|
position: relative;
|
||||||
|
user-select: none;
|
||||||
|
$radial: 2.5rem;
|
||||||
|
// edge fades (this is the fix)
|
||||||
|
&::before,
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
opacity: 0; // hidden by default
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
// left fade
|
||||||
|
&::before {
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at left center,
|
||||||
|
rgba(255,255,255,1) 0%,
|
||||||
|
rgba(255,255,255,0.9) 50%,
|
||||||
|
rgba(255,255,255,0.5) 75%,
|
||||||
|
rgba(255,255,255,0.25) 95%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
border-top-right-radius: $radial;
|
||||||
|
border-bottom-right-radius: $radial;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// right fade
|
||||||
|
&::after {
|
||||||
|
right: 0;
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at right center,
|
||||||
|
rgba(255,255,255,1) 0%,
|
||||||
|
rgba(255,255,255,0.9) 50%,
|
||||||
|
rgba(255,255,255,0.5) 75%,
|
||||||
|
rgba(255,255,255,0.25) 95%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
border-top-left-radius: $radial;
|
||||||
|
border-bottom-left-radius: $radial;
|
||||||
|
}
|
||||||
|
|
||||||
|
// show fade only when overflowing
|
||||||
|
&.is-overflowing {
|
||||||
|
&::before,
|
||||||
|
&::after {
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s ease-out;
|
||||||
|
transition: opacity 0.12s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.show-left {
|
||||||
|
&::before {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.show-right {
|
||||||
|
&::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// arrows
|
||||||
|
.tab-scroll-arrow {
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
user-select: none;
|
||||||
|
width: 2.5rem;
|
||||||
|
z-index: 3;
|
||||||
|
path {
|
||||||
|
fill: $tab-border;
|
||||||
|
}
|
||||||
|
&.left {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.right {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
display: none !important;
|
||||||
|
pointer-events: none;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// only show arrows when overflow
|
||||||
|
&.is-overflowing {
|
||||||
|
.tab-scroll-arrow {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -53,5 +53,4 @@ block content
|
|||||||
tabs.init();
|
tabs.init();
|
||||||
+h(4)
|
+h(4)
|
||||||
pre.language-js
|
pre.language-js
|
||||||
include _tabs.js
|
include _tabs.js
|
||||||
|
|
||||||
@@ -1,45 +1,70 @@
|
|||||||
tabset, .tab-group {
|
tabset, .tab-group {
|
||||||
margin: 2rem 0 1rem 0;
|
margin: 2rem 0 1rem 0;
|
||||||
}
|
}
|
||||||
tabset [role=tablist], .tab-group [role=tablist] {
|
tabset [role=tablist] li.selected, .tab-group [role=tablist] li.selected {
|
||||||
|
background-color: var(--color-blue);
|
||||||
|
color: var(--color-white);
|
||||||
|
}
|
||||||
|
tabset > ul,
|
||||||
|
tabset .tab-scroll > ul, .tab-group > ul,
|
||||||
|
.tab-group .tab-scroll > ul {
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
tabset [role=tablist] li.separator, .tab-group [role=tablist] li.separator {
|
tabset > ul li.separator,
|
||||||
|
tabset .tab-scroll > ul li.separator, .tab-group > ul li.separator,
|
||||||
|
.tab-group .tab-scroll > ul li.separator {
|
||||||
border-bottom: 1px solid #7f7f7f;
|
border-bottom: 1px solid #7f7f7f;
|
||||||
display: inline-block;
|
|
||||||
margin: 0.45rem 0 0 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab], .tab-group [role=tablist] li[role=tab] {
|
|
||||||
background-color: #FFF;
|
|
||||||
border-left: 1px solid #7f7f7f;
|
border-left: 1px solid #7f7f7f;
|
||||||
border-right: 1px solid #7f7f7f;
|
display: inline-block;
|
||||||
border-radius: 0.5rem 0.5rem 0 0;
|
-webkit-box-flex: 1;
|
||||||
border-top: 1px solid #7f7f7f;
|
-ms-flex: 1 1 auto;
|
||||||
cursor: pointer;
|
flex: 1 1 auto;
|
||||||
display: inline;
|
margin: 0.45rem 0 0 0;
|
||||||
margin: 0;
|
width: auto;
|
||||||
padding: 1rem 1.5rem 0.14rem 1.5rem;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab]:last-of-type, .tab-group [role=tablist] li[role=tab]:last-of-type {
|
|
||||||
border-right: 1px solid #7f7f7f;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab]:not(.selected), .tab-group [role=tablist] li[role=tab]:not(.selected) {
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
border-bottom: 1px solid #7f7f7f;
|
|
||||||
}
|
|
||||||
tabset [role=tablist] li[role=tab] span, .tab-group [role=tablist] li[role=tab] span {
|
|
||||||
display: block;
|
|
||||||
margin: 0 0 0.5rem 0;
|
|
||||||
}
|
}
|
||||||
tabset .tab-hidden, .tab-group .tab-hidden {
|
tabset .tab-hidden, .tab-group .tab-hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
tabset [role=tab], .tab-group [role=tab] {
|
||||||
|
background-color: #FFF;
|
||||||
|
border-left: 1px solid #7f7f7f;
|
||||||
|
border-radius: 0.5rem 0.5rem 0 0;
|
||||||
|
border-top: 1px solid #7f7f7f;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
-webkit-box-flex: 0;
|
||||||
|
-ms-flex: 0 0 auto;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 100vw;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 1rem 1.5rem 0.14rem 1.5rem;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
tabset [role=tab]:last-of-type, .tab-group [role=tab]:last-of-type {
|
||||||
|
border-right: 1px solid #7f7f7f;
|
||||||
|
}
|
||||||
|
tabset [role=tab]:not(.selected), .tab-group [role=tab]:not(.selected) {
|
||||||
|
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] {
|
tabset [role=tabpanel], .tab-group [role=tabpanel] {
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
border: 1px solid #7f7f7f;
|
border: 1px solid #7f7f7f;
|
||||||
@@ -49,4 +74,110 @@ tabset [role=tabpanel], .tab-group [role=tabpanel] {
|
|||||||
}
|
}
|
||||||
tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
|
tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
|
||||||
display: none;
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-scroll {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.tab-scroll::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.tab-scroll > ul {
|
||||||
|
-ms-flex-wrap: nowrap;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
min-width: 100%;
|
||||||
|
width: -webkit-max-content;
|
||||||
|
width: -moz-max-content;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-scroll-wrapper {
|
||||||
|
position: relative;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper::before, .tab-scroll-wrapper::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transition: opacity 0.2s ease;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper::before {
|
||||||
|
background: radial-gradient(circle at left center, rgb(255, 255, 255) 0%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 255, 0.5) 75%, rgba(255, 255, 255, 0.25) 95%, transparent 100%);
|
||||||
|
border-top-right-radius: 2.5rem;
|
||||||
|
border-bottom-right-radius: 2.5rem;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper::after {
|
||||||
|
right: 0;
|
||||||
|
background: radial-gradient(circle at right center, rgb(255, 255, 255) 0%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 255, 0.5) 75%, rgba(255, 255, 255, 0.25) 95%, transparent 100%);
|
||||||
|
border-top-left-radius: 2.5rem;
|
||||||
|
border-bottom-left-radius: 2.5rem;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing::before, .tab-scroll-wrapper.is-overflowing::after {
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transition: opacity 0.15s ease-out;
|
||||||
|
transition: opacity 0.15s ease-out;
|
||||||
|
-webkit-transition: opacity 0.12s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
transition: opacity 0.12s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing.show-left::before {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing.show-right::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow {
|
||||||
|
-webkit-box-align: center;
|
||||||
|
-ms-flex-align: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
-webkit-box-pack: center;
|
||||||
|
-ms-flex-pack: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
width: 2.5rem;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow path {
|
||||||
|
fill: #7f7f7f;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow.left {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow.right {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper .tab-scroll-arrow.hidden {
|
||||||
|
display: none !important;
|
||||||
|
pointer-events: none;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
.tab-scroll-wrapper.is-overflowing .tab-scroll-arrow {
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,44 @@
|
|||||||
a(href="#") Link with a tool tip
|
mixin tooltip(a)
|
||||||
span(role="tooltip" inert tip-position="right") Tool tip content
|
-
|
||||||
|
const required = ['text']
|
||||||
|
const optional = ['tip-position', 'tip-align', 'inert', 'role' ].concat(required)
|
||||||
|
|
||||||
|
// function to strip unallowed options.
|
||||||
|
const allowed = (obj, whitelist) => {
|
||||||
|
const set = new Set(whitelist);
|
||||||
|
const result = {};
|
||||||
|
for (const [k, v] of Object.entries(obj)) {
|
||||||
|
if (set.has(k)) result[k] = v;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default values
|
||||||
|
const defaults = {
|
||||||
|
"tip-position": "right",
|
||||||
|
inert: "inert",
|
||||||
|
role: "tooltip",
|
||||||
|
}
|
||||||
|
|
||||||
|
// unhyphenated to hypenated
|
||||||
|
const map = {
|
||||||
|
position: 'tip-position',
|
||||||
|
align: 'tip-align'
|
||||||
|
}
|
||||||
|
for (const [from, to] of Object.entries(map)) {
|
||||||
|
if (a[from] !== undefined) {
|
||||||
|
a[to] = a[from]
|
||||||
|
delete a[from]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// recheck for required and output if everything required is there.
|
||||||
|
if (a && required.some(key => !(key in a)))
|
||||||
|
p Missing keys: #{required.filter(key => !(key in a))}
|
||||||
|
else
|
||||||
|
-
|
||||||
|
text = a.text
|
||||||
|
a.text = undefined
|
||||||
|
a = allowed({...defaults, ...a}, optional)
|
||||||
|
|
||||||
|
tooltip&attributes(a)!= text
|
||||||
@@ -25,7 +25,7 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@mixin tooltip {
|
@mixin tooltip {
|
||||||
[role="tooltip"] {
|
tooltip, tool-tip {
|
||||||
background: $tooltip-light-background;
|
background: $tooltip-light-background;
|
||||||
border-radius: $tooltip-border-radius;
|
border-radius: $tooltip-border-radius;
|
||||||
color: $tooltip-light-foreground;
|
color: $tooltip-light-foreground;
|
||||||
@@ -150,9 +150,10 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:has(> [role="tooltip"]) {
|
:has(> tooltip), :has(> tool-tip) {
|
||||||
position: relative;
|
position: relative;
|
||||||
&:is(:hover, :focus-visible, :active) > [role="tooltip"] {
|
&:is(:hover, :focus-visible, :active) > tool-tip,
|
||||||
|
&:is(:hover, :focus-visible, :active) > tooltip {
|
||||||
display: block;
|
display: block;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transition-delay: 300ms;
|
transition-delay: 300ms;
|
||||||
@@ -160,20 +161,20 @@ $tooltip-pointer-top: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
:has(> tool-tip:is([tip-position="top"], [tip-position="block-start"], :not([tip-position]))):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="top"], [tip-position="block-start"], :not([tip-position]))):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="top"], [tip-position="block-start"], :not([tip-position]))):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: 3px;
|
--tooltip-y: 3px;
|
||||||
}
|
}
|
||||||
|
:has(> tool-tip:is([tip-position="right"], [tip-position="inline-end"])):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="right"], [tip-position="inline-end"])):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="right"], [tip-position="inline-end"])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * -3px * -1);
|
--tooltip-x: calc(-1 * -3px * -1);
|
||||||
}
|
}
|
||||||
|
:has(> tool-tip:is([tip-position="bottom"], [tip-position="block-end"])):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="bottom"], [tip-position="block-end"])):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="bottom"], [tip-position="block-end"])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: -3px;
|
--tooltip-y: -3px;
|
||||||
}
|
}
|
||||||
|
:has(> tool-tip:is([tip-position="left"], [tip-position="inline-start"])):not(:hover):not(:active) tool-tip,
|
||||||
:has(> [role="tooltip"]:is([tip-position="left"], [tip-position="inline-start"])):not(:hover):not(:active) [role="tooltip"] {
|
:has(> tooltip:is([tip-position="left"], [tip-position="inline-start"])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * 3px * -1);
|
--tooltip-x: calc(-1 * 3px * -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
- bottom / block-end
|
- bottom / block-end
|
||||||
- left / inline-start
|
- left / inline-start
|
||||||
*/
|
*/
|
||||||
[role=tooltip] {
|
tooltip, tool-tip {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
color: #000;
|
color: #000;
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
will-change: filter;
|
will-change: filter;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
[role=tooltip]::before {
|
tooltip::before, tool-tip::before {
|
||||||
clip-path: inset(50%);
|
clip-path: inset(50%);
|
||||||
clip: rect(1px, 1px, 1px, 1px);
|
clip: rect(1px, 1px, 1px, 1px);
|
||||||
content: "; Has tooltip: ";
|
content: "; Has tooltip: ";
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
}
|
}
|
||||||
[role=tooltip]::after {
|
tooltip::after, tool-tip::after {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
content: "";
|
content: "";
|
||||||
inset: 0;
|
inset: 0;
|
||||||
@@ -58,21 +58,29 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=top],
|
tooltip:is([tip-position=top],
|
||||||
|
[tip-position=block-start],
|
||||||
|
:not([tip-position]),
|
||||||
|
[tip-position=bottom],
|
||||||
|
[tip-position=block-end]), tool-tip:is([tip-position=top],
|
||||||
[tip-position=block-start],
|
[tip-position=block-start],
|
||||||
:not([tip-position]),
|
:not([tip-position]),
|
||||||
[tip-position=bottom],
|
[tip-position=bottom],
|
||||||
[tip-position=block-end]) {
|
[tip-position=block-end]) {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=top],
|
tooltip:is([tip-position=top],
|
||||||
|
[tip-position=block-start],
|
||||||
|
:not([tip-position])), tool-tip:is([tip-position=top],
|
||||||
[tip-position=block-start],
|
[tip-position=block-start],
|
||||||
:not([tip-position])) {
|
:not([tip-position])) {
|
||||||
inset-inline-start: 50%;
|
inset-inline-start: 50%;
|
||||||
inset-block-end: calc(100% + 0.75rem + 1rem);
|
inset-block-end: calc(100% + 0.75rem + 1rem);
|
||||||
--tooltip-x: calc(50% * -1);
|
--tooltip-x: calc(50% * -1);
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=top],
|
tooltip:is([tip-position=top],
|
||||||
|
[tip-position=block-start],
|
||||||
|
:not([tip-position]))::after, tool-tip:is([tip-position=top],
|
||||||
[tip-position=block-start],
|
[tip-position=block-start],
|
||||||
:not([tip-position]))::after {
|
:not([tip-position]))::after {
|
||||||
--tooltip-pointer: conic-gradient(from -30deg at bottom, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) bottom/100% 50% no-repeat;
|
--tooltip-pointer: conic-gradient(from -30deg at bottom, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) bottom/100% 50% no-repeat;
|
||||||
@@ -80,39 +88,45 @@
|
|||||||
-webkit-border-after: 1rem solid transparent;
|
-webkit-border-after: 1rem solid transparent;
|
||||||
border-block-end: 1rem solid transparent;
|
border-block-end: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=right],
|
tooltip:is([tip-position=right],
|
||||||
|
[tip-position=inline-end]), tool-tip:is([tip-position=right],
|
||||||
[tip-position=inline-end]) {
|
[tip-position=inline-end]) {
|
||||||
inset-inline-start: calc(100% + 1.5rem + 1rem);
|
inset-inline-start: calc(100% + 1.5rem + 1rem);
|
||||||
inset-block-end: 50%;
|
inset-block-end: 50%;
|
||||||
--tooltip-y: 50%;
|
--tooltip-y: 50%;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=right],
|
tooltip:is([tip-position=right],
|
||||||
|
[tip-position=inline-end])::after, tool-tip:is([tip-position=right],
|
||||||
[tip-position=inline-end])::after {
|
[tip-position=inline-end])::after {
|
||||||
--tooltip-pointer: conic-gradient(from 60deg at left, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) left/50% 100% no-repeat;
|
--tooltip-pointer: conic-gradient(from 60deg at left, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) left/50% 100% no-repeat;
|
||||||
inset-inline-start: -1rem;
|
inset-inline-start: -1rem;
|
||||||
-webkit-border-start: 1rem solid transparent;
|
-webkit-border-start: 1rem solid transparent;
|
||||||
border-inline-start: 1rem solid transparent;
|
border-inline-start: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=bottom],
|
tooltip:is([tip-position=bottom],
|
||||||
|
[tip-position=block-end]), tool-tip:is([tip-position=bottom],
|
||||||
[tip-position=block-end]) {
|
[tip-position=block-end]) {
|
||||||
inset-inline-start: 50%;
|
inset-inline-start: 50%;
|
||||||
inset-block-start: calc(100% + 0.75rem + 1rem);
|
inset-block-start: calc(100% + 0.75rem + 1rem);
|
||||||
--tooltip-x: calc(50% * -1);
|
--tooltip-x: calc(50% * -1);
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=bottom],
|
tooltip:is([tip-position=bottom],
|
||||||
|
[tip-position=block-end])::after, tool-tip:is([tip-position=bottom],
|
||||||
[tip-position=block-end])::after {
|
[tip-position=block-end])::after {
|
||||||
--tooltip-pointer: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) top/100% 50% no-repeat;
|
--tooltip-pointer: conic-gradient(from 150deg at top, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) top/100% 50% no-repeat;
|
||||||
inset-block-start: -1rem;
|
inset-block-start: -1rem;
|
||||||
-webkit-border-before: 1rem solid transparent;
|
-webkit-border-before: 1rem solid transparent;
|
||||||
border-block-start: 1rem solid transparent;
|
border-block-start: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=left],
|
tooltip:is([tip-position=left],
|
||||||
|
[tip-position=inline-start]), tool-tip:is([tip-position=left],
|
||||||
[tip-position=inline-start]) {
|
[tip-position=inline-start]) {
|
||||||
inset-inline-end: calc(100% + 1.5rem + 1rem);
|
inset-inline-end: calc(100% + 1.5rem + 1rem);
|
||||||
inset-block-end: 50%;
|
inset-block-end: 50%;
|
||||||
--tooltip-y: 50%;
|
--tooltip-y: 50%;
|
||||||
}
|
}
|
||||||
[role=tooltip]:is([tip-position=left],
|
tooltip:is([tip-position=left],
|
||||||
|
[tip-position=inline-start])::after, tool-tip:is([tip-position=left],
|
||||||
[tip-position=inline-start])::after {
|
[tip-position=inline-start])::after {
|
||||||
--tooltip-pointer: conic-gradient(from -120deg at right, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) right/50% 100% no-repeat;
|
--tooltip-pointer: conic-gradient(from -120deg at right, rgba(0, 0, 0, 0), #000 1deg 60deg, rgba(0, 0, 0, 0) 61deg) right/50% 100% no-repeat;
|
||||||
inset-inline-end: -1rem;
|
inset-inline-end: -1rem;
|
||||||
@@ -120,21 +134,21 @@
|
|||||||
border-inline-end: 1rem solid transparent;
|
border-inline-end: 1rem solid transparent;
|
||||||
}
|
}
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
[role=tooltip] {
|
tooltip, tool-tip {
|
||||||
background: #1f2127;
|
background: #1f2127;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
-webkit-filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
-webkit-filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
||||||
filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
filter: drop-shadow(0 3px 3px hsla(0, 0%, 0%, 0.5)) drop-shadow(0 12px 12px hsla(0, 0%, 0%, 0.5));
|
||||||
}
|
}
|
||||||
[role=tooltip]::after {
|
tooltip::after, tool-tip::after {
|
||||||
background: #1f2127;
|
background: #1f2127;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:has(> [role=tooltip]) {
|
:has(> tooltip), :has(> tool-tip) {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]):is(:hover, :focus-visible, :active) > [role=tooltip] {
|
:has(> tooltip):is(:hover, :focus-visible, :active) > tool-tip, :has(> tooltip):is(:hover, :focus-visible, :active) > tooltip, :has(> tool-tip):is(:hover, :focus-visible, :active) > tool-tip, :has(> tool-tip):is(:hover, :focus-visible, :active) > tooltip {
|
||||||
display: block;
|
display: block;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
-webkit-transition-delay: 300ms;
|
-webkit-transition-delay: 300ms;
|
||||||
@@ -142,16 +156,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
:has(> [role=tooltip]:is([tip-position=top], [tip-position=block-start], :not([tip-position]))):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=top], [tip-position=block-start], :not([tip-position]))):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=top], [tip-position=block-start], :not([tip-position]))):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: 3px;
|
--tooltip-y: 3px;
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]:is([tip-position=right], [tip-position=inline-end])):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=right], [tip-position=inline-end])):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=right], [tip-position=inline-end])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * -3px * -1);
|
--tooltip-x: calc(-1 * -3px * -1);
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]:is([tip-position=bottom], [tip-position=block-end])):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=bottom], [tip-position=block-end])):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=bottom], [tip-position=block-end])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-y: -3px;
|
--tooltip-y: -3px;
|
||||||
}
|
}
|
||||||
:has(> [role=tooltip]:is([tip-position=left], [tip-position=inline-start])):not(:hover):not(:active) [role=tooltip] {
|
:has(> tool-tip:is([tip-position=left], [tip-position=inline-start])):not(:hover):not(:active) tool-tip,
|
||||||
|
:has(> tooltip:is([tip-position=left], [tip-position=inline-start])):not(:hover):not(:active) tooltip {
|
||||||
--tooltip-x: calc(-1 * 3px * -1);
|
--tooltip-x: calc(-1 * 3px * -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user