When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:
main {
max-width: 38rem;
padding: 2rem;
margin: auto;
}| /* | |
| Copy this into the console of any web page that is interactive and doesn't | |
| do hard reloads. You will hear your DOM changes as different pitches of | |
| audio. | |
| I have found this interesting for debugging, but also fun to hear web pages | |
| render like UIs do in movies. | |
| */ | |
| const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
| /* Highliting accessibility errors in HTML */ | |
| /* highlight HTML element with invalid value for lang attribute */ | |
| html:not([lang]), | |
| html[lang=""] { | |
| border: 2px dotted red !important; | |
| } | |
| /* highlight images missing alt text */ | |
| img:not([alt]) { |
| Seven different types of CSS attribute selectors | |
| // This attribute exists on the element | |
| [value] | |
| // This attribute has a specific value of cool | |
| [value='cool'] | |
| // This attribute value contains the word cool somewhere in it | |
| [value*='cool'] |
| import React, { useContext } from 'react' | |
| import { UserContext, UserContextProvider } from './UserContext' | |
| export default (props) => { | |
| const [user, setUser] = useContext(UserContext) | |
| return ( | |
| <UserContextProvider user={null}> | |
| <div>User name: {user && user.name}</div> | |
| </UserContextProvider> |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <opml version="1.0"> | |
| <head> | |
| <title>RSS subscriptions for mundizzle@gmail.com</title> | |
| <dateCreated>Sun, 09 Jun 2019 11:05:23 -0500</dateCreated> | |
| <ownerEmail>mundizzle@gmail.com</ownerEmail> | |
| </head> | |
| <body> | |
| <outline text="A List Apart: The Full Feed" title="A List Apart: The Full Feed" type="rss" xmlUrl="http://feeds.feedburner.com/alistapart/main" htmlUrl=" https://alistapart.com "/> | |
| <outline text="Cognition by Happy Cog" title="Cognition by Happy Cog" type="rss" xmlUrl="http://feeds.feedburner.com/cognitionfeed" htmlUrl="http://cognition.happycog.com/feed"/> |
| # Quickly fix one file | |
| npx prettier --write your-file.html | |
| # Quickly fix all files of one type | |
| npx prettier --write src/**/*.{js,jsx} |
| /** | |
| * Pass in an element and its CSS Custom Property that you want the value of. | |
| * Optionally, you can determine what datatype you get back. | |
| * | |
| * @param {String} propKey | |
| * @param {HTMLELement} element=document.documentElement | |
| * @param {String} castAs='string' | |
| * @returns {*} | |
| */ | |
| const getCSSCustomProp = (propKey, element = document.documentElement, castAs = 'string') => { |
| function decorate(tag, template) { | |
| customElements.define(tag, class extends HTMLElement { | |
| constructor() { | |
| super(); | |
| this.attachShadow({ mode: 'open' }); | |
| } | |
| connectedCallback() { | |
| let root = this.shadowRoot; | |
| if(!root.firstChild) { |