Skip to content

Instantly share code, notes, and snippets.

View sarahbethfederman's full-sized avatar

Sarah Federman sarahbethfederman

View GitHub Profile
@smhigley
smhigley / aria-maxlength.md
Created March 28, 2024 04:35
Discussion topics for aria-maxlength

aria-maxlength discussion

This is a short overview of the background and decisions that need to be made to map the maxlength HTML attribute and create an aria-maxlength ARIA attribute.

Background

Although the HTML maxlength prop can be used to limit characters in native inputs, it has no accessibility mappings and is not communicated to screen reader users (either up front or when the character limit is reached).

This becomes a pain point when authoring text inputs that have character limits in several ways:

  • It necessitates a custom live region announcement when the character limit is approaching and exceeded, despite there often being no visual text equivalent.
@msewell
msewell / AXNameFromColor.swift
Last active October 17, 2024 12:15
AXNameFromColor: String representation of a CGColor
import Accessibility
import UIKit
extension CGColor {
var rgba: String { String(format: "R: %1.3f, G: %2.3f, B: %3.3f, A: %4.3f", components![0], components![1], components![2], components![3]) }
}
let hues: ClosedRange<Int> = (0...359)
hues // with constant saturation, brightness, and alpha
@resource11
resource11 / autolink-headers-in-gatsby-mdx-files
Last active January 26, 2020 00:37
gatsby-config.js settings to generate autolinked headers in MDX files
import React from 'react';
import { BLOCKS } from '@contentful/rich-text-types';
import { documentToHtmlString } from './lib';
import BlogPostBlockquoteEmoji, {
contentfulId as BLOCKQUOTE_EMOJI,
} from '../BlogPostBlockquoteEmoji';
import BlogPostCaption, { contentfulId as CAPTION } from '../BlogPostCaption';
import BlogPostColumns, { contentfulId as COLUMNS } from '../BlogPostColumns';
import BlogPostImage from '../BlogPostImage';
@fstorr
fstorr / how-to-get-speech-output-as-text-from-screen-readers.md
Last active April 10, 2025 05:08
How to get speech output as text from screen readers

How to get speech output as text from screen readers

Sometimes you need text, rather than voice, output from screen readers. Why? It's really useful for bug reports ("this disclosure icon is announced as 'black dash triangle dash filled dash x2 underscore final dot png' and needs alt text"). Luckily, getting this text is easy to do.

VoiceOver on MacOS

In VoiceOver you press Option + Control + Shift + C to have the last item that was announced copied to the clipboard. Bonus feature: pressing Option + Control + Shift + Z to save the last phrase to the desktop as an audio file.

VoiceOver on iOS

A three-finger quadruple tap copies the last announcement to the clipboard.

Introduction

Many people are confused by the {{mut}} helper because it seems very magical. This gist aims to help you construct a mental model for understanding what is going on when you use it.

History

Prior to the introduction of {{mut}}, form elements were two-way bound by default. That is, given this component:

import Ember from 'ember';
export default Ember.Component.extend({
@odewahn
odewahn / error-handling-with-fetch.md
Last active June 9, 2024 14:27
Processing errors with Fetch API

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

fetch("/api/foo")
  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
 })
@ivanoats
ivanoats / fetch-from-contentful.js
Created June 17, 2016 18:45
fetch-from-contentful.js
#!/usr/bin/env babel-node
require('dotenv').config()
import contentful from 'contentful'
import fs from 'fs-extra-promise'
// Contentful Config
const apiToken = process.env.CONTENTFUL_DELIVERY_API_TOKEN
const spaceId = process.env.CONTENTFUL_SPACE_ID
const client = contentful.createClient({ accessToken: apiToken, space: spaceId })