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
import { observable, computed, runInAction } from 'mobx' | |
import uid from './uid' | |
type UndoFn = () => void | |
type Command = () => UndoFn | Promise<UndoFn> | |
interface UndoContext { | |
id: string | |
label: string | |
command: Command |
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
type UndoFn = () => void | |
type Command = () => UndoFn | Promise<UndoFn> | |
interface UndoContext { | |
command: Command | |
revert: UndoFn | Promise<UndoFn> | |
} | |
export class UndoManager { | |
undoStack: UndoContext[] = [] |
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
import _ from 'lodash' | |
class TagSet { | |
constructor({ name, slug, sortBy = 'title' }) { | |
/** @type {string} */ | |
this.name = name | |
/** @type {string} */ | |
this.slug = slug | |
/** @type {string} */ | |
this.sortBy = sortBy |
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
import { renderMarkdown, useCollection, useFiles, usePage, useSite, xml } from "../packages/tilt/index.js"; | |
export default function Feed(props, children) { | |
const site = useSite() | |
const posts = useCollection('posts') | |
const buildDate = (new Date()).toUTCString() | |
return xml`<?xml version="1.0" encoding="UTF-8"?> | |
<rss | |
xmlns:dc="http://purl.org/dc/elements/1.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
let _stack = [{}] | |
export function getContext(key) { | |
return _stack[0][key] | |
} | |
export function setContext(key, value) { | |
_stack[0][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
export function selectImage(accepts: string = "image/*"): Promise<File | null> { | |
return new Promise((resolve, reject) => { | |
const input = createFileInput(accepts) | |
let focusCount = 0 | |
let fileWasSelected = false | |
input.onchange = (e: any) => { | |
fileWasSelected = true | |
const file = e.target.files[0] |
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
const _tokenCache = new WeakMap<CockpitAPI, string>() | |
export class CockpitAPI { | |
constructor(public readonly baseUrl: string, token: string) { | |
_tokenCache.set(this, token) | |
} | |
setToken(token: string) { |
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
import * as React from 'react' | |
import { stream, scan } from 'flyd' | |
import merge from 'mergerino' | |
interface StreamedStateConfigObject<T, A> { | |
state: T, actions: (updater: (value: Partial<T>) => void) => A | |
} | |
type StreamedStateConfigBuilder<T, A> = () => StreamedStateConfigObject<T, A> |
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
<script role="view"> | |
import { store, view } from 'react-easy-state' | |
const counter = store({ | |
value: 0, | |
increment() { counter.value += 1 }, | |
decrement() { counter.value -= 1 } | |
}) | |
export default view(() => ( |
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
* { | |
scroll-behavior: smooth; | |
box-sizing: border-box; | |
} | |
.modal-card { | |
box-shadow: 0px 6px 8px rgba(0,0,0,.5); | |
border-radius: 6px; | |
} |