- Use font sizes between 15-25px for body text
- Use bigger font sizes for headlines. Decrease font-weight as font-size increases.
- Use 120-150% of font-size for line-height
- Allow 45-90 characters per line. Increase font-size and/or whitespace or use a multi-column to help with this
- Use sans-serif fonts for UI elements and most other things. Use serif fonts for content and long text sections
- Do not put text on images you do not control
- Text shadows can improve legibility
- 4:5:1 contrast ratio for text below 24px and 3:1 for text above 24px
- Do not mix text effects which add emphasis. For example, do not underline and italicise text which is also bold
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.onsubmit = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Object.prototype, "onsubmit", { | |
get() { | |
return (e) => { | |
e.preventDefault(); | |
console.log('I am on the setter'); | |
} | |
}, | |
set(val) { | |
console.log(val); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.render(document.getElementById('app'), | |
m('form', { | |
onsubmit: (e) => { | |
e.preventDefault(); | |
console.log('I am on the form element') | |
} | |
}, [ | |
m('button', { type: 'submit'}, 'Submit') | |
]) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.render(document.getElementById('app'), | |
m('form', { | |
onreset: (e) => { | |
console.log('resetting form...') | |
}, | |
onsubmit: (e) => { | |
e.preventDefault(); | |
console.log('submitting form...') | |
}, | |
}, [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateEvent(vnode, key, value) { | |
if (vnode.events != null) { | |
if (vnode.events[key] === value) return | |
if (value != null && (typeof value === "function" || typeof value === "object")) { | |
if (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false) | |
vnode.events[key] = value | |
} | |
// ... | |
} | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
attrs: { | |
onreset: onreset(e) { /* ... */ }, | |
onsubmit: onsubmit(e) { /* ... */ }, | |
} | |
children: [{…}, {…}] | |
dom: form | |
domSize: undefined | |
events: EventDict { | |
onreset: onreset(e) { /* ... */ }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here's an explanation of how this works: | |
// 1. The event names are always (by design) prefixed by `on`. | |
// 2. The EventListener interface accepts either a function or an object | |
// with a `handleEvent` method. | |
// 3. The object does not inherit from `Object.prototype`, to avoid | |
// any potential interference with that (e.g. setters). | |
// 4. The event name is remapped to the handler before calling it. | |
// 5. In function-based event handlers, `ev.target === this`. We replicate | |
// that below. | |
// 6. In function-based event handlers, `return false` prevents the default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateEvent(vnode, key, value) { | |
if (vnode.events != null) { | |
if (vnode.events[key] === value) return | |
if (value != null && (typeof value === "function" || typeof value === "object")) { | |
if (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false) | |
vnode.events[key] = value | |
} else { | |
if (vnode.events[key] != null) vnode.dom.removeEventListener(key.slice(2), vnode.events, false) | |
vnode.events[key] = undefined | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
actualDuration: 4.100000005564652 | |
actualStartTime: 95595.49999999581 | |
alternate: null | |
child: null | |
childExpirationTime: 0 | |
effectTag: 0 | |
elementType: "h1" | |
expirationTime: 0 | |
firstContextDependency: null |
NewerOlder