This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the initial state | |
const query = window.matchMedia('(prefers-color-scheme: dark)'); | |
function toggleDarkMode(toggle = query.matches) { | |
// Open the menu | |
document.querySelector('#USER_DROPDOWN_ID[aria-expanded="false"]')?.click(); | |
// Get the wrapper item | |
const wrapper = Array.from(document.querySelectorAll('button')).find(({ innerText }) => innerText.toLowerCase() === 'dark mode'); | |
const checkbox = wrapper?.querySelector(`[aria-checked="${!toggle}"]`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "https://cdn.potts.es/fonts/fakt-pro.css"; | |
@import "https://cdn.potts.es/fonts/basier-circle-mono.css"; | |
html { | |
font-size: 100%; | |
} | |
/* Basic reset */ | |
h1, | |
h2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-embed="cart"> | |
<script type="text/props"> | |
{ | |
"storeId": 13, | |
"colors": { | |
"buttons": { | |
"background": "#f9b642", | |
"text": "#ffffff" | |
}, | |
"checkout": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rounding methods for .closest() | |
const closestRounding = { | |
none: 0, | |
ceil: 1, | |
floor: 2, | |
}; | |
export { closestRounding }; | |
/** | |
* Get the closest value in an array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================================== | |
// Simple color manipulation library | |
// ========================================================================== | |
const clamp = (input = 0, min = 0, max = 255) => { | |
return Math.min(Math.max(input, min), max); | |
}; | |
const regex = new RegExp(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/, 'i'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="fr"> | |
<head> | |
<title>Isto é um teste</title> | |
</head> | |
<body> | |
<p>Aqui está um texto em francês</p> | |
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | |
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> | |
<path d="M12,0C5.383,0,0,5.383,0,12s5.383,12,12,12s12-5.383,12-12S18.617,0,12,0z M12,2c5.176,0,9.446,3.954,9.949,9h-4.567 | |
L15,15.764l-6-12L5.382,11H2.051C2.554,5.954,6.824,2,12,2z M12,22c-5.176,0-9.446-3.954-9.949-9h4.567L9,8.236l6,12L18.618,13 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================================== | |
// tab-focus.js | |
// Detect keyboard tabbing | |
// ========================================================================== | |
(function() { | |
var className = "tab-focus"; | |
// Remove class on blur | |
document.addEventListener("focusout", function(event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Async load a script with a callback | |
(function () { | |
function async(u, c, a) { | |
var d = document; | |
var t = 'script'; | |
var o = d.createElement(t); | |
var s = d.getElementsByTagName(t)[0]; | |
o.src = u; | |
if (typeof a === 'object') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================================== | |
// SVG sprite loading and caching | |
// This file should be at the top of the body to avoid a flash | |
// Usage: loadSprite('https://cdn.com/path/to/sprite.svg', 'sprite-id'); | |
// The second argument is optional but prevents loading twice | |
// ========================================================================== | |
(function() { | |
window.loadSprite = function(url, id) { | |
if (typeof url !== "string") { |
NewerOlder