Skip to content

Instantly share code, notes, and snippets.

View wuhhh's full-sized avatar

Huw Roberts wuhhh

View GitHub Profile
@wuhhh
wuhhh / rose_pine.json
Last active October 12, 2025 22:06
Rose Pine theme for Musikcube
{
"name": "rose_pine",
"schemaVersion": 1,
"colors": {
"background": { "hex": "#232137", "palette": 234 },
"foreground": { "hex": "#908caa", "palette": 254 },
"focused_border": { "hex": "#eb6f92", "palette": 160 },
"text_focused": { "hex": "#ebbcba", "palette": 160 },
"text_active": { "hex": "#f6c177", "palette": 64 },
"text_disabled": { "hex": "#908caa", "palette": 245 },
@wuhhh
wuhhh / poimandres.json
Created March 4, 2025 12:57
Musikcube Poimandres Theme ✨
{
"name": "poimandres",
"schemaVersion": 1,
"colors": {
"background": {
"hex": "#1b1e28",
"palette": 235
},
"foreground": {
"hex": "#7f8bbc",
@wuhhh
wuhhh / trap-focus.js
Last active March 9, 2024 21:52
Trap focus example (Svelte)
export function trapFocus(node) {
const previous = document.activeElement;
function focusable() {
return Array.from(node.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'));
}
function handleKeydown(event) {
if (event.key !== 'Tab') return;
const createStoreImpl = (createState) => {
let state;
const listeners = /* @__PURE__ */ new Set();
const setState = (partial, replace) => {
const nextState = typeof partial === "function" ? partial(state) : partial;
if (!Object.is(nextState, state)) {
const previousState = state;
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
listeners.forEach((listener) => listener(state, previousState));
@wuhhh
wuhhh / limit-orbit-pan.jsx
Created June 12, 2023 20:19
Limit OrbitControls pan
/**
* Limit OrbitControls pan
*/
const controls = useRef();
const minPan = new THREE.Vector3(-2, 1, 0);
const maxPan = new THREE.Vector3(2, -1, 0);
useEffect(() => {
const _v = new THREE.Vector3();
float map(float value, float low1, float high1, float low2, float high2) {
return low2 + (value - low1) * (high2 - low2) / (high1 - low1);
}
// Hex to RGB
// e.g. vec3 rgbBlue = hexToRGB(0xD0F5F7);
vec3 hexToRGB(int h) {
float rValue = float(h / 256 / 256);
float gValue = float(h / 256 - int(rValue * 256.0));
float bValue = float(h - int(rValue * 256.0 * 256.0) - int(gValue * 256.0));
return vec3(rValue / 255.0, gValue / 255.0, bValue / 255.0);
}
@wuhhh
wuhhh / vue-parallax-plugins.js
Last active January 15, 2020 13:43
A simple parallax plugin for Vue. Add the v-parallax directive to elements you want to... parallaxify. Directive argument should be an object with single argument, 'target'. Target specifies the final offset amount (in px) for the element
/**
* A simple parallax plugin for Vue
* Add the v-parallax directive to elements you want to... parallaxify.
* Directive argument should be an object with single argument, 'target'
* Target specifies the final offset amount (in px) for the element
*
* For example:
*
* <my-element v-parallax="{ target: -500 }">
*/
@wuhhh
wuhhh / outerHeight.js
Created August 21, 2019 08:10
Get element outer height
/**
* Returns the element height including margins
* @param element - element
* @returns {number}
*/
function outerHeight(element) {
const height = element.offsetHeight,
style = window.getComputedStyle(element)
return ['top', 'bottom']
/**
* From: https://stackoverflow.com/a/23529943
*
* Add or update a query string parameter. If no URI is given, we use the current
* window.location.href value for the URI.
*
* Based on the DOM URL parser described here:
* http://james.padolsey.com/javascript/parsing-urls-with-the-dom/
*
* @param (string) uri Optional: The URI to add or update a parameter in