add tablesort

This commit is contained in:
Inhji 2023-07-20 07:20:21 +02:00
parent bcde9f314b
commit e90327fedd
5 changed files with 59 additions and 15 deletions

View file

@ -5,6 +5,7 @@
@import "./reset.css"; @import "./reset.css";
@import "./gruvbox.css"; @import "./gruvbox.css";
@import "./lightbox.css"; @import "./lightbox.css";
@import "./tablesort.css";
@layer base { @layer base {
:root { :root {

33
assets/css/tablesort.css Normal file
View file

@ -0,0 +1,33 @@
th[role=columnheader]:not(.no-sort) {
cursor: pointer;
}
th[role=columnheader]:not(.no-sort):after {
content: '';
float: right;
margin-top: 7px;
border-width: 0 4px 4px;
border-style: solid;
border-color: rgb(var(--color-primary)) transparent;
visibility: hidden;
opacity: 0;
-ms-user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
th[aria-sort=ascending]:not(.no-sort):after {
border-bottom: none;
border-width: 4px 4px 0;
}
th[aria-sort]:not(.no-sort):after {
visibility: visible;
opacity: 0.4;
}
th[role=columnheader]:not(.no-sort):hover:after {
visibility: visible;
opacity: 1;
}

View file

@ -1,29 +1,32 @@
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons. // Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
import "phoenix_html" import 'phoenix_html'
import hljs from "highlight.js" import hljs from 'highlight.js'
import GLightbox from 'glightbox' import GLightbox from 'glightbox'
import Tablesort from 'tablesort'
document.addEventListener('DOMContentLoaded', (event) => { document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('pre code').forEach((el) => { document.querySelectorAll('.prose pre code').forEach((el) =>
hljs.highlightElement(el); hljs.highlightElement(el))
});
document.querySelectorAll('.prose table').forEach(el =>
new Tablesort(el))
}); });
document document
.querySelector("#dark-mode-toggle") .querySelector('#dark-mode-toggle')
.addEventListener("click", (e) => { .addEventListener('click', (e) => {
e.preventDefault() e.preventDefault()
const data = document.documentElement.dataset const data = document.documentElement.dataset
if (data["mode"] && data["mode"] == "dark") { if (data['mode'] && data['mode'] == 'dark') {
delete data["mode"] delete data['mode']
window.localStorage.removeItem("theme") window.localStorage.removeItem('theme')
} else { } else {
data["mode"] = "dark" data['mode'] = 'dark'
window.localStorage.setItem("theme", "dark") window.localStorage.setItem('theme', 'dark')
} }
}) })
GLightbox({ selector: ".lightbox" }) GLightbox({ selector: '.lightbox' })
window.hljs = hljs window.hljs = hljs

View file

@ -11,7 +11,8 @@
"kbar": "^0.1.0-beta.40", "kbar": "^0.1.0-beta.40",
"phoenix": "file:../deps/phoenix", "phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html", "phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view" "phoenix_live_view": "file:../deps/phoenix_live_view",
"tablesort": "^5.3.0"
}, },
"devDependencies": { "devDependencies": {
"esbuild": "^0.18.0" "esbuild": "^0.18.0"
@ -645,6 +646,11 @@
"loose-envify": "^1.1.0" "loose-envify": "^1.1.0"
} }
}, },
"node_modules/tablesort": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/tablesort/-/tablesort-5.3.0.tgz",
"integrity": "sha512-WkfcZBHsp47gVH9CBHG0ZXopriG01IA87arGrchvIe868d4RiXVvoYPS1zMq9IdW05kBs5iGsqxTABqLyWonbg=="
},
"node_modules/tiny-invariant": { "node_modules/tiny-invariant": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.1.tgz", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.1.tgz",

View file

@ -9,7 +9,8 @@
"kbar": "^0.1.0-beta.40", "kbar": "^0.1.0-beta.40",
"phoenix": "file:../deps/phoenix", "phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html", "phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view" "phoenix_live_view": "file:../deps/phoenix_live_view",
"tablesort": "^5.3.0"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^18.0", "react": "^18.0",