WraithWeb. Theme behaviour
(Wraith v0.1.0)
View Source
What a theme is: a layout (the HEEx templates and the structural CSS for a kind of site — editorial, list, grid, magazine, minimal, journal) plus tokens (fonts, palette, radius, measure) inlined as CSS variables, plus a Google Fonts URL. Eighteen themes ship from six layouts, so the type and colour change completely while a layout's templates are written once.
defmodule WraithWeb.Themes.Broadsheet do
use WraithWeb.Theme,
name: "broadsheet",
label: "Broadsheet",
description: "Black on white, newspaper serif, a big first story.",
layout: WraithWeb.Themes.Layouts.Editorial,
fonts: "https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;700&family=Source+Serif+4&display=swap",
tokens: %{"--heading" => "'Playfair Display', serif", "--body" => "'Source Serif 4', serif", "--paper" => "#fff", …}
endA layout module (WraithWeb.Theme.Layout) embeds templates/{layout,index, post,listing}.html.heex and gets tag, author, search from its
listing, and subscribe/member from WraithWeb.Themes.Shared.
Tokens every layout reads (priv/static/themes/base.css sets fallbacks):
--heading, --body, --mono, --paper, --paper-2, --rule, --ink,
--ink-2, --ink-3, --accent, --radius, --measure, --scheme
(light | dark).
Summary
Types
Callbacks
@callback author(map()) :: Phoenix.LiveView.Rendered.t()
@callback index(map()) :: Phoenix.LiveView.Rendered.t()
@callback info() :: info()
@callback layout(map()) :: Phoenix.LiveView.Rendered.t()
@callback member(map()) :: Phoenix.LiveView.Rendered.t()
@callback post(map()) :: Phoenix.LiveView.Rendered.t()
@callback search(map()) :: Phoenix.LiveView.Rendered.t()
@callback subscribe(map()) :: Phoenix.LiveView.Rendered.t()
@callback tag(map()) :: Phoenix.LiveView.Rendered.t()