Update patterns and core JS

This commit is contained in:
2024-07-12 22:19:12 -04:00
parent 4a18341cf5
commit dcbc471c4d
10 changed files with 3565 additions and 184 deletions

BIN
src/pg/.DS_Store vendored

Binary file not shown.

View File

@@ -75,30 +75,6 @@ const css = (el, attr) => {
el.setAttribute("style",st.trim());
}
const setupStickies = () => {
let stickies = document.querySelectorAll("sticky-note");
stickies.forEach((s) => {
if (s.style.position !== "absolute") {
let wrapper = document.createElement("sticky-note-wrapper");
s.parentNode.insertBefore(wrapper, s);
wrapper.appendChild(s);
s.setAttribute("content", s.innerHTML.replace(/"/g, "\""));
s.innerHTML = `<div><svg width='0' height='0'><defs><clipPath id='stickyClip' clipPathUnits='objectBoundingBox'><path d='M 0 0 Q 0 0.69, 0.03 0.96 0.03 0.96, 1 0.96 Q 0.96 0.69, 0.96 0 0.96 0, 0 0' stroke-linejoin='round' stroke-linecap='square' /></clipPath></defs></svg></div><div><div>${s.innerHTML}</div></div>`;
}
calculateStickyPosition(s);
drag(s);
s.ondblclick = (e) => {
if (e.ctrlKey) {
calculateStickyPosition(s);
} else {
// add one click select
}
}
})
}
const calculateStickyPosition = (s) => {
let float = s.getAttribute("float");
@@ -119,18 +95,35 @@ const calculateStickyPosition = (s) => {
}
}
export function init(callback){
export function init(p = document){
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
setupStickies();
let stickies = document.querySelectorAll("sticky-note");
stickies.forEach((s) => {
p.querySelectorAll("sticky-note").forEach((s) => {
if (s.querySelectorAll("svg").length == 0) {
let wrapper = document.createElement("sticky-note-wrapper");
s.parentNode.insertBefore(wrapper, s);
wrapper.appendChild(s);
s.setAttribute("content", s.innerHTML.replace(/"/g, "\""));
s.innerHTML = `<div><svg width='0' height='0'><defs><clipPath id='stickyClip' clipPathUnits='objectBoundingBox'><path d='M 0 0 Q 0 0.69, 0.03 0.96 0.03 0.96, 1 0.96 Q 0.96 0.69, 0.96 0 0.96 0, 0 0' stroke-linejoin='round' stroke-linecap='square' /></clipPath></defs></svg></div><div><div>${s.innerHTML}</div></div>`;
}
calculateStickyPosition(s);
drag(s);
s.ondblclick = (e) => {
if (e.ctrlKey) {
calculateStickyPosition(s);
} else {
// add one click select
}
}
})
window.onresize = () => {
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
let stickies = document.querySelectorAll("sticky-note");
let stickies = p.querySelectorAll("sticky-note");
stickies.forEach((s) => {
calculateStickyPosition(s);
});

View File

@@ -1,14 +1,11 @@
//- DS2 core (c) 2024 Alexander McIlwraith
//- Licensed under CC BY-SA 4.0
/* DS2 core (c) 2024 Alexander McIlwraith
import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js";
tabs.init();
*/
//- import * as tabs from "../pg/patterns/layouts/tabs/_tabs-core.js";
//- tabs.init();
export function init(p = document) {
p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
export function init() {
const tabGroups = document.querySelectorAll(".tab-group, tabset");
tabGroups.forEach(tabGroup => {
if (tabGroup.querySelector("[role=tablist]") === null) {
const tabgroup = tabGroup.getAttribute("id");
let tablist = "";