Skip to content

Instantly share code, notes, and snippets.

@atomiks
atomiks / LazyTippy.jsx
Last active February 9, 2023 02:10
Lazy Tippy
// Will only render the `content` or `render` elements if the tippy is mounted to the DOM.
// Replace <Tippy /> with <LazyTippy /> component and it should work the same.
const LazyTippy = forwardRef((props, ref) => {
const [mounted, setMounted] = useState(false);
const lazyPlugin = {
fn: () => ({
onMount: () => setMounted(true),
onHidden: () => setMounted(false),
@atomiks
atomiks / HyperappTippy.jsx
Last active July 6, 2018 08:44
Hyperapp Component for Tippy.js
import { h, app } from "hyperapp"
import tippy from "tippy.js"
export default (realProps, [reference]) => {
const props = { ...realProps }
if (props.html.constructor === Object && !props.target) {
const container = document.createElement('div')
app({}, {}, props.html, container)
props.html = container
@atomiks
atomiks / fix-blinkmacsystemfont-kerning.js
Last active May 18, 2020 14:54
Fixes BlinkMacSystemFont / -apple-system (San Francisco) letter tracking/kerning on macOS for affected browsers
/*
* A small utility to fix the letter kerning on macOS Chrome and Firefox when using the system font
* (San Francisco). It is now fixed in the text rendering engine in FF 58 and Chrome 64.
* UPDATE: It appears the applied fix doesn't work when the font is in italics. New fix has been added.
* Must be applied to all browsers for now.
*/
;(() => {
const ua = navigator.userAgent
// macOS 10.11 (El Capitan) came with San Francisco. Previous versions used Helvetica