Skip to content

Instantly share code, notes, and snippets.

View bramus's full-sized avatar

Bramus bramus

View GitHub Profile
@bramus
bramus / windows-viewports.md
Last active October 17, 2022 03:46
Interop 2022 Viewport Investigation: Behavior on a Windows Touch Screen Device

Windows On-Screen Keyboard vs. Viewports

Setup / General

  • Device: Dell XPS 13 9380 with Windows 10 Enterprise (19044.1949)
  • I had to enable a few things before I could trigger the OSK / show the button in the task bar
    • Don't recall which ones though :-/
  • Windows has various concepts for the OSK. If you hit CTRL+WIN+O for example a totally different OSK - one that floats and cannot be docked - pops up

The Good

@bramus
bramus / generate.js
Created April 22, 2022 23:14
Generate CSS @scroll-timeline definitions
// Code that generates the CSS Scroll-Timelines for https://codepen.io/bramus/pen/xxRZZdK
const generateCSS = () => {
let css = '';
document.querySelectorAll('li').forEach((li, i) => {
const id = li.getAttribute('id');
css = `
${css}
@scroll-timeline scroll-in-cards-${id} {
@bramus
bramus / astro-env-vars.md
Created October 17, 2021 09:13
Astro Env Vars
  • Install @snowpack/plugin-dotenv

    npm i --save @snowpack/plugin-dotenv
    
  • Configure Astro via astro.config.mjs to use @snowpack/plugin-dotenv

plugins: [

@bramus
bramus / script.js
Last active February 27, 2024 22:38
Text-to-Speech with the Web Speech API
// 🗣 Text-to-Speech with the Web Speech API's SpeechSynthesis
// @link https://gist.github.com/bramus/e27fcb783f469b6585007a7453e1bb5a
// @ref https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis
((text) => {
// Create an Utterance (= speech request)
const utter = new SpeechSynthesisUtterance(text);
// Set the voice
utter.voice = window.speechSynthesis.getVoices()[0];
@bramus
bramus / generate.js
Created September 3, 2021 08:36
Generate CSS ScrollTimelines
// This little piece of JS was used to generate the scroll-timelines
// used in the demo at https://codepen.io/bramus/pen/wveWXdw
const generateCSS = () => {
let css = '';
document.querySelectorAll('.slide').forEach((li, i) => {
const id = li.getAttribute('id');
const parentId = li.parentElement.getAttribute('id');
css = `
@bramus
bramus / DOMBuilder.coffee
Created August 16, 2021 10:11
DOMBuilder
class DOMBuilder
@build: (tag) ->
# create element
el = document.createElement(tag)
# set options
for attribute, value of arguments[1]
switch (true)
@bramus
bramus / generate.js
Created May 20, 2021 21:08
Generate CSS ScrollTimelines
// This little piece of JS was used to generate the scroll-timelines
// used in the demo at https://codepen.io/bramus/pen/LYbBoRj
const generateCSS = () => {
const css = [];
document.querySelectorAll('section[id]').forEach((section, i) => {
const id = section.getAttribute('id');
css.push(`
@scroll-timeline section-${id}-enter {
const changeValueInObject = (object, key, value) => {
if (key.indexOf('.') !== -1) {
const keyParts = key.split('.');
const firstPartOfKey = keyParts.shift();
return {
...object,
[firstPartOfKey]: {
...(object[firstPartOfKey] ?? {}),
...changeValueInObject((object[firstPartOfKey] ?? {}), keyParts.join('.'), value),
},
@bramus
bramus / feedback.md
Created March 13, 2019 22:02
RE: Designing An Aspect Ratio Unit For CSS

The addition of an aspect-ratio property would indeed solve this specific issue. Glad to see it's being discussed (once wrote an extensive post on this myself).

Thinking further on this, this solution is somewhat limited: it only solves the aspect ratio problem.

A more broader solution could be the introduction of a val() function. It would work like the var() function – which reads the value of a custom property – but then for reading values from other properties. The function would yield the computed value of the given property. Combine it with calc() and you're good to go.

In code, it would result in something like this:

.box {