Skip to content

feat: themes, and assets in the deck's own block - #19

Open
victorbahl wants to merge 2 commits into
roaldnefs:mainfrom
victorbahl:feat/themes-and-assets
Open

victorbahl wants to merge 2 commits into
roaldnefs:mainfrom
victorbahl:feat/themes-and-assets

Conversation

@victorbahl

Copy link
Copy Markdown
Contributor

Hey Roald, last one of the series 🙂 Two commits again, and you can take the first without the second.

Several themes in one deck

Sometimes I have to present the same content under two brands, and keeping two files in step doesn't work:

<html lang="en" data-themes="light dark" data-theme="light">
<style data-deck="theme">…what both share…</style>
<style data-deck="theme" data-theme="dark">…what dark changes…</style>
…
<img data-theme="dark" src="logo-dark.svg" alt="Dark">
  • An element, a style block or a favicon with data-theme is only there in that theme.
  • The theme is the author's choice: a button in the edit view gives the deck the next one, as an edit you can undo, and Save writes it. There is no key for it in the show.
  • A public copy keeps only the deck's theme, so nothing of the other brand goes out with it.

Images and fonts in the file

This one goes a bit against the README, so feel free to say no. For a deck in a repo I agree: images belong beside it. But I send most of mine by email or Slack, and the files beside the HTML get lost on the way. It's called deckfile after all, so I wanted the whole deck in the file 🙂

It's opt-in: a block at the end holds them, one per line, and the slides only name them.

<img data-asset="team" alt="The team">
…
<script type="application/json" data-deck="assets">
{
"team":"data:image/jpeg;base64,…"
}
</script>
  • It works for <img data-asset="x">, var(--asset-x) in CSS and src:local("asset:x") in @font-face.
  • Saved slides, the Suggest prompt and the thumbnails never hold the data, so diffs and an agent's context stay small.
  • A public copy keeps only the assets it uses.

The README's advice on images stays the default, with a section on the block. A deck that uses neither stays as it is.

npm test: 13 node tests and 117 browser tests pass, 11 of them new.

data-themes="light dark" on <html> lists the themes in the file, and
data-theme is the deck's. An element, a style block or a favicon with
data-theme is only there in that theme. The theme button in the edit view
gives the deck the next one, as an edit to undo or remove; Save writes it,
and the thumbnails and the presenter view follow. There is no key for it
in the show. A public copy keeps only the deck's theme, and the Suggest
prompt says which one the deck is in.
… beside it

A deck can carry its images and fonts as data URIs in a
<script type="application/json" data-deck="assets"> at its end, one per
line. The slides name them: <img data-asset="x">, var(--asset-x) in CSS,
src:local("asset:x") in @font-face. The engine fills them in as the deck
opens and leaves the data out of what it writes: the saved slides, the
Suggest prompt, the thumbnails. A public copy keeps only the assets it
uses. A deck without the block works as before.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant