Skip to content

Instantly share code, notes, and snippets.

View alanbsmith's full-sized avatar
👋

Alan B Smith alanbsmith

👋
View GitHub Profile
@alanbsmith
alanbsmith / style-prop-comparison.md
Created April 19, 2021 02:09
Style Prop type comparison

Style Prop Comparison

Example 1

// These types are brief and correct, but lose autocomplete support because of the string union :/ 
export type ColorProps = {
  /** sets background color with design system or generic value */
  bgColor?: DesignSystemColor | string;
 /** sets color with design system or generic value */
@alanbsmith
alanbsmith / coffee-flavor-profiles.json
Created April 2, 2021 21:08
some sample coffee flavor profiles
[
"almond",
"caramel",
"blackberry",
"brown sugar",
"candied orange",
"chocolate",
"clean",
"cocoa",
"dried cherry",
@alanbsmith
alanbsmith / coffee-origins.json
Created April 2, 2021 21:04
sample data for coffee regions
[
{
"country": "Burundi",
"region": "Africa",
"subRegions": ["Buyenzi", "Bweru"]
},
{
"country": "Ethiopia",
"region": "",
"subRegions": ["Harrar", "Jimma", "Limu", "Sidamo", "Yirgacheffe"]
[
{
"firstName": "Alan",
"lastName": "Smith"
}
]
@alanbsmith
alanbsmith / canvas-kit-v5-workshop-session-1.md
Last active March 17, 2021 15:42
Canvas Kit V5 Workshop Session 1
@alanbsmith
alanbsmith / learn-with-canvas-block-1.md
Last active February 17, 2021 17:00
Learn HTML & CSS with Canvas | Block 1
@alanbsmith
alanbsmith / Design Systems Resources.md
Last active October 13, 2022 19:11
Design Systems Resources | A Primer

Design Systems Resources | A Primer

Design Systems

  • [Design Systems][1] by Alla Kholmatova - the canonical design systems book, in my opinion
  • [Expressive Design Systems][2] by Yesenia Perez-Cruz - a great follow-up to Kholmatova's book
  • [Atomic Design][3] by Brad Frost - written before we were using the term 'design system' for web interfaces, but many popular ideas extend from these ideas

Systems Thinking

@alanbsmith
alanbsmith / sign.js
Last active August 5, 2021 09:17
A JS function for adding a signature to an HTML canvas element
function sign(name, fontSize = 96) {
// assumes the id of the canvas element is 'canvas'
const canvas = document.getElementById('canvas')
const ctx = canvas.getContext('2d');
ctx.font = `italic ${fontSize}px Snell Roundhand`;
const signatureWidth = ctx.measureText(name).width;
const x = canvas.width/2 - signatureWidth/2;
const y = canvas.height/2 + fontSize/2;
ctx.fillStyle = ctx.strokeStyle;
ctx.fillText(name, x, y);
@alanbsmith
alanbsmith / CollapsibleSideNav.jsx
Created September 4, 2020 20:27
image08 for component hierarchy post
import { collapseOnEsc } from '../utils/hooks';
import { useSideNav } from './hooks';
const CollapsibleSideNav = () => {
const { isNavOpen, toggleNav, a11yTargetProps, a11yHeadingProps} = useSideNav();
// collapse the nav when the ESC key is pressed
collapseOnEsc();
return (
<SidenavContainer variant={isNavOpen ? 'expanded' : 'collapsed'}>