Published
Edited
Dec 6, 2019
1 fork
Importers
22 stars
Insert cell
Insert cell
Insert cell
Insert cell
collapsedCSS('Your Label here')`
blockquote {
border-left: 1px solid currentColor;
margin-left: 0;
padding-left: 0.5em;
}
`
Insert cell
Insert cell
collapsedCSS`
blockquote {
border-left: 1px solid currentColor;
margin-left: 0;
padding-left: 0.5em;
}
`
Insert cell
Insert cell
viewof style = css`
blockquote {
border-left: 1px solid currentColor;
margin-left: 0;
padding-left: 0.5em;
}
`
Insert cell
style
Insert cell
Insert cell
viewof style2 = css({ transform: css => css.replace(/:scope/g, '.foo') })`
:scope h3 {
font-size: 1.5em;
}
`
Insert cell
style2.textContent
Insert cell
viewof style3 = collapsedCSS({
transform: css => css.replace(/:scope/g, '.bar')
})`
:scope h3 {
font-size: 1.5em;
}
`
Insert cell
style3.textContent
Insert cell
Insert cell
css = tagWithOptions(({ transform }) => (...args) => {
const source = interpolate(...args);
const style = html`<style>`;
style.textContent = transform ? transform(source) : source;
const el = md`
~~~css
${source}
~~~
${style}
`;
el.value = style.cloneNode(true);
return el;
})
Insert cell
collapsedCSS = tagWithOptions(opts => (...args) => {
if (typeof opts === 'string') {
opts = { title: opts };
}
const content = css(opts)(...args);
const el = html`
<details>
<summary style="cursor: pointer; user-select: none">${opts.title ||
'CSS'}</summary>
${content}
</details>
`;
el.value = content.value;
return el;
})
Insert cell
tagWithOptions = impl => (...args) => {
if (!Array.isArray(args[0])) {
return impl(args[0]);
}
return impl({})(...args);
}
Insert cell
interpolate = (strings, ...interpolations) => {
let s = '';
for (let i = 0; i < strings.length; i++) {
s += strings[i];
if (i < interpolations.length && interpolations[i]) {
s += String(interpolations[i]);
}
}
return dedent(s);
}
Insert cell
Insert cell
dedent = (await import('https://unpkg.com/dentist@1.0.3/src/index.js')).dedent
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more