Skip to content

Commit

Permalink
Seems fine, except static HTML tree list...
Browse files Browse the repository at this point in the history
  • Loading branch information
VashJuan committed Sep 26, 2024
1 parent 61cfdc9 commit b764cd5
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 30 deletions.
92 changes: 81 additions & 11 deletions themes/eoconline/layouts/OrgChart/org-tree.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,89 @@
/* https://codepen.io/bisserof/pen/nrMveb
*/

body {
margin: 30px;
font-family: sans-serif;
}

#fontSizeWrapper {
font-size: 16px;
#TreeOptions {
margin: 15px 0;
padding: 15px;
background-color: #eee;
border-radius: 0.3em;
}

#TreeOptions div {
font-size: large;
font-weight: bold;
}

#TreeOptions input {
margin: 5px;
background-color: rgb(168, 168, 168);
border: 1px solid transparent;
border-radius: 0.5rem;
box-sizing: border-box;
color: #ffffff;
cursor: pointer;
flex: 0 0 auto;
font-weight: 600;
line-height: 1.3rem;
padding: 0.25rem 1.2rem;
text-align: center;
text-decoration: none #6b7280 solid;
text-decoration-thickness: auto;

transition-property: background-color, border-color, color, fill, stroke;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
width: auto;
/*
transition-duration: 2.5s;
box-shadow:
rgba(44, 187, 99, 0.2) 0 -25px 18px -14px inset,
rgba(44, 187, 99, 0.15) 0 1px 2px,
rgba(44, 187, 99, 0.15) 0 2px 4px,
rgba(44, 187, 99, 0.15) 0 4px 8px,
rgba(44, 187, 99, 0.15) 0 8px 16px,
rgba(44, 187, 99, 0.15) 0 16px 32px;
*/
display: inline-block;
transition: all 500ms;
}

#TreeOptions input:hover {
box-shadow:
rgba(69, 103, 187, 0.35) 0 -25px 18px -14px inset,
rgba(69, 103, 187, 0.35) 0 1px 2px,
rgba(69, 103, 187, 0.35) 0 2px 4px,
rgba(69, 103, 187, 0.35) 0 4px 8px,
rgba(69, 103, 187, 0.35) 0 8px 16px,
rgba(69, 103, 187, 0.35) 0 16px 32px;
transform: scale(1.05) rotate(-1deg);
background-color: #374151;
}

#TreeOptions input:focus {
box-shadow: none;
outline: 2px solid transparent;
outline-offset: 2px;
}

#fontSizeLabel {
font-size: medium;
margin-top: 3px;
}

#fontSize {
width: 100px;
font-size: 1em;
width: 150px;
margin-left: 10px;
}

#fontSizeValue {
width: 2em;
display: inline-block;
background-color: rgb(255, 255, 255);
padding: 2px;
}

/* ————————————————————–
Expand All @@ -25,10 +96,9 @@ ul {
}

.tree {
margin: 1em;
list-style-type: none;
padding: 0;
margin: 0;
padding: 20px;
border: 1px solid #a6a6a6;
border-radius: 0.3em;
}

.tree input {
Expand Down
27 changes: 22 additions & 5 deletions themes/eoconline/layouts/OrgChart/org-tree.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- https://codepen.io/bisserof/pen/nrMveb -->
<!-- originally based on https://codepen.io/bisserof/pen/nrMveb -->

<!doctype html>
<html lang="en">
Expand All @@ -14,13 +14,30 @@
<script defer src="./org-tree.js"></script>
</head>
<body>
<div id="fontSizeWrapper">
<label for="fontSize">Font size</label>
<input type="range" value="1" id="fontSize" step="0.5" min="0.5" max="5" />
<div id="TreeOptions">
<div>Tree Options:<br /></div>
<input type="button" value="Collapse Entire Tree" onclick="" />
<input type="button" value="Expand Entire Tree" onclick="" />

<div>
<label title="Font size in em's" id="fontSizeLabel">
Font size: <span id="fontSizeValue">1</span>
<input type="range" value="2.5" id="fontSize" step="0.5" min="0.5" max="5" list="steplist" oninput="document.querySelector('#fontSizeValue').textContent = this.value" />
<datalist id="steplist">
<option>0.5</option>
<option>1.0</option>
<option>2.0</option>
<option>3.0</option>
<option>4.0</option>
<option>5</option>
</datalist>
</label>
</div>
</div>

<ul class="tree">
<li>
<input type="checkbox" checked="checked" id="c1" />
<input type="checkbox" id="c1" />
<label class="tree_label" for="c1">Level 0</label>
<ul>
<li>
Expand Down
29 changes: 15 additions & 14 deletions themes/eoconline/layouts/OrgChart/org-tree.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
let fontSize = document.body.style.fontSize;
let fontSize = document.querySelector(".tree").style.fontSize;
setFontSize(fontSize);

function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}

function setFontSize(el) {
fontSize = el.value;
if (!isNumber(fontSize) || fontSize < 0.5) {
fontSize = 1;
}
document.body.style.fontSize = fontSize + 'em';
}

document.querySelector("#fontSize").addEventListener("change", (e) => { setFontSize(e.target); });
document.querySelector("#fontSize").addEventListener("input", (e) => { setFontSize(e.target); });

document.querySelector("#fontSize").addEventListener('keyup', (event) => {
if (event.key === 'Escape') {
Expand All @@ -24,3 +13,15 @@ document.querySelector("#fontSize").addEventListener('keyup', (event) => {
}
}
});

function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}

function setFontSize(el) {
fontSize = el.value;
if (!isNumber(fontSize) || fontSize < 0.5) {
fontSize = 1;
}
document.querySelector(".tree").style.fontSize = fontSize + 'em';
}

0 comments on commit b764cd5

Please sign in to comment.