Skip to content

Commit

Permalink
Adding latest updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tnylea committed Jun 6, 2024
1 parent 1f7b4e3 commit bbff863
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 167 deletions.
115 changes: 87 additions & 28 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,51 +35,110 @@ h2 a, h3 a, h4 a {
color: #b4fd4f !important;
}

@property --border-angle {
inherits: false;
initial-value: 0deg;
syntax: '<angle>';
}

@keyframes border-rotate {
to {
--border-angle: 360deg;
}
}

@keyframes fade-in {
from { opacity: 0; }
.animate-border {
animation: border-rotate 3s linear infinite;
}

@keyframes fade-out {
to { opacity: 0; }
.font-rota{
font-family: rota;
}

@keyframes slide-from-right {
from {
transform: translateY(15px);
opacity:0;
}
.hljs {
color: #f8e164;
}

@media(min-width: 768px) {
.features-tailwind.hljs{
overflow:hidden;
padding-top: 15px !important;
padding-left: 20px !important;
padding-right: 190px !important;
padding-bottom: 150px !important;
background-size:top right;
/* background-image:url('/assets/images/page.svg'); */
}
}

.features-tailwind.hljs{
overflow:hidden;
padding: 15px;
}

@media(min-width: 768px) {
.features-layouts.hljs{
padding-top: 30px !important;
padding-left: 45px !important;
padding-bottom: 30px !important;
}
}

@keyframes slide-to-left {
to { transform: translateY(-0px);
filter: blur(0px);
opaity:1; }
.features-layouts.hljs{
padding: 15px;
}

/* define animations for the old and new content */
::view-transition-old(slide-it) {
animation: 300ms cubic-bezier(0.4, 0, 1, 1) both fade-out,
400ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left;
.hljs-addition,
.hljs-code,
.hljs-string,
.hljs-title.class_.inherited__ {
color: #f8e164 !important;
}
::view-transition-new(slide-it) {
animation: 300ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,
400ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right;


.prose h1, .prose h2, .prose h3, .prose h4{
font-family: 'Rota';
}

/* tie the view transition to a given CSS class */
/* #site-content {
view-transition-name: slide-it;
} */
.prose-sm pre code{
font-size:14px;
}

#docs-content {
view-transition-name: slide-it;
.docs .prose pre {
padding:0px;
border: 1px solid rgba(255, 255, 255, 0.08);
background:rgba(255, 255, 255, 0.06);
border-radius:10px;
white-space: break-spaces;
display:grid;
}

#hero-bg{
view-transition-name: none;


.docs .prose pre code {
padding:18px;
white-space:pre;
}

@media (min-width: 640px) {
.docs .prose pre code {
padding:26px;
}
}

.prose p{
color:rgba(255, 255, 255, 0.8);
}


.prose h2{
font-size:25px;
font-weight:800;
}
[data-loading] {
display: none;
}

.language-makefile .hljs-comment{
color: #87e778;
}
21 changes: 21 additions & 0 deletions assets/js/alpine-morph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// https://htmx.org/extensions/alpine-morph/

import * as htmx from "htmx.org";
window.htmx = htmx;

htmx.defineExtension('alpine-morph', {
isInlineSwap: function (swapStyle) {
return swapStyle === 'morph';
},
handleSwap: function (swapStyle, target, fragment) {
if (swapStyle === 'morph') {
if (fragment.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
Alpine.morph(target, fragment.firstElementChild);
return [target];
} else {
Alpine.morph(target, fragment.outerHTML);
return [target];
}
}
}
});
188 changes: 188 additions & 0 deletions assets/js/htmx-loading-states.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
// https://htmx.org/extensions/loading-states/

import * as htmx from "htmx.org";
window.htmx = htmx;

;(function () {
let loadingStatesUndoQueue = []

function loadingStateContainer(target) {
return htmx.closest(target, '[data-loading-states]') || document.body
}

function mayProcessUndoCallback(target, callback) {
if (document.body.contains(target)) {
callback()
}
}

function mayProcessLoadingStateByPath(elt, requestPath) {
const pathElt = htmx.closest(elt, '[data-loading-path]')
if (!pathElt) {
return true
}

return pathElt.getAttribute('data-loading-path') === requestPath
}

function queueLoadingState(sourceElt, targetElt, doCallback, undoCallback) {
const delayElt = htmx.closest(sourceElt, '[data-loading-delay]')
if (delayElt) {
const delayInMilliseconds =
delayElt.getAttribute('data-loading-delay') || 200
const timeout = setTimeout(function () {
doCallback()

loadingStatesUndoQueue.push(function () {
mayProcessUndoCallback(targetElt, undoCallback)
})
}, delayInMilliseconds)

loadingStatesUndoQueue.push(function () {
mayProcessUndoCallback(targetElt, function () { clearTimeout(timeout) })
})
} else {
doCallback()
loadingStatesUndoQueue.push(function () {
mayProcessUndoCallback(targetElt, undoCallback)
})
}
}

function getLoadingStateElts(loadingScope, type, path) {
return Array.from(htmx.findAll(loadingScope, "[" + type + "]")).filter(
function (elt) { return mayProcessLoadingStateByPath(elt, path) }
)
}

function getLoadingTarget(elt) {
if (elt.getAttribute('data-loading-target')) {
return Array.from(
htmx.findAll(elt.getAttribute('data-loading-target'))
)
}
return [elt]
}

htmx.defineExtension('loading-states', {
onEvent: function (name, evt) {
if (name === 'htmx:beforeRequest') {
const container = loadingStateContainer(evt.target)

const loadingStateTypes = [
'data-loading',
'data-loading-class',
'data-loading-class-remove',
'data-loading-disable',
'data-loading-aria-busy',
]

let loadingStateEltsByType = {}

loadingStateTypes.forEach(function (type) {
loadingStateEltsByType[type] = getLoadingStateElts(
container,
type,
evt.detail.pathInfo.requestPath
)
})

loadingStateEltsByType['data-loading'].forEach(function (sourceElt) {
getLoadingTarget(sourceElt).forEach(function (targetElt) {
queueLoadingState(
sourceElt,
targetElt,
function () {
targetElt.style.display =
sourceElt.getAttribute('data-loading') ||
'inline-block' },
function () { targetElt.style.display = 'none' }
)
})
})

loadingStateEltsByType['data-loading-class'].forEach(
function (sourceElt) {
const classNames = sourceElt
.getAttribute('data-loading-class')
.split(' ')

getLoadingTarget(sourceElt).forEach(function (targetElt) {
queueLoadingState(
sourceElt,
targetElt,
function () {
classNames.forEach(function (className) {
targetElt.classList.add(className)
})
},
function() {
classNames.forEach(function (className) {
targetElt.classList.remove(className)
})
}
)
})
}
)

loadingStateEltsByType['data-loading-class-remove'].forEach(
function (sourceElt) {
const classNames = sourceElt
.getAttribute('data-loading-class-remove')
.split(' ')

getLoadingTarget(sourceElt).forEach(function (targetElt) {
queueLoadingState(
sourceElt,
targetElt,
function () {
classNames.forEach(function (className) {
targetElt.classList.remove(className)
})
},
function() {
classNames.forEach(function (className) {
targetElt.classList.add(className)
})
}
)
})
}
)

loadingStateEltsByType['data-loading-disable'].forEach(
function (sourceElt) {
getLoadingTarget(sourceElt).forEach(function (targetElt) {
queueLoadingState(
sourceElt,
targetElt,
function() { targetElt.disabled = true },
function() { targetElt.disabled = false }
)
})
}
)

loadingStateEltsByType['data-loading-aria-busy'].forEach(
function (sourceElt) {
getLoadingTarget(sourceElt).forEach(function (targetElt) {
queueLoadingState(
sourceElt,
targetElt,
function () { targetElt.setAttribute("aria-busy", "true") },
function () { targetElt.removeAttribute("aria-busy") }
)
})
}
)
}

if (name === 'htmx:beforeOnLoad') {
while (loadingStatesUndoQueue.length > 0) {
loadingStatesUndoQueue.shift()()
}
}
},
})
})()
Loading

0 comments on commit bbff863

Please sign in to comment.