Installation
Four steps for a Phoenix app: the dependency, the stylesheet, the optional trigger script, and one line where you render.
-
Add the dependency
In the umbrella, add it to the app that renders the pictures.
apps/uiis the natural home, because every brand already depends on it.defp deps do [ {:eh_visuals, git: "git@github.com:EmpoweredHouse/empowered-visual-library.git", tag: "v0.1.0"} ] endThen run
mix deps.get. Mix compiles a dependency in the:prodenvironment, so you get the compositions without the docs site. -
Import the stylesheet
Import the index from the brand's
app.css, next to the chrome and the fonts. It pulls in the base layer and every composition.@import "tailwindcss"; @import "../../../ui/assets/css/chrome.css"; @import "../../../ui/assets/css/fonts.css"; /* EmpoweredHouse Visuals, fetched by mix into the umbrella's deps/. */ @import "../../../../deps/eh_visuals/assets/css/eh-visuals.css";To ship less CSS, import the base layer and only what a page uses:
@import "../../../../deps/eh_visuals/assets/css/base.css"; @import "../../../../deps/eh_visuals/assets/css/hero/platform-stack.css"; @import "../../../../deps/eh_visuals/assets/css/process/flow.css";Vite has to be allowed to read outside the app. Add
deps/eh_visuals/assetstoserver.fs.allowinvite.config.ts, the same way../../ui/assetsis listed today. -
Import the trigger script, if you want scroll triggers
Without the script every animated composition plays on page load. With it,
trigger="in-view"waits until the picture is on screen. It is plain DOM code and about 1 KB.import "../../../../deps/eh_visuals/assets/js/eh-visuals.js"; -
Render a composition
use EHVisualsimports every composition into the module. Each one is a function named{category}_{file}.defmodule EmpoweredLandingWeb.HomeSections do use Phoenix.Component use EHVisuals def platform(assigns) do ~H""" <div class="h-120 rounded-xl border border-border"> <.hero_platform_stack animated /> </div> """ end endTo import one composition, import its module:
import EHVisuals.Charts.Sparkline.
Tokens and fonts
A composition reads the token names of the landing stylesheet: --canvas, --surface-1, --border-soft, --text-primary, --lime, --coral, --sans,
--mono
and --ease. On a page that defines none of them it falls back to the brand
values, so it looks the same in a blog embed or a deck as on the site.
Prefer to own the code?
Skip the dependency and copy the source. Every preview page shows the two files of its composition with a copy button. You also need the shared layer once:
lib/eh_visuals/composition.exandlib/eh_visuals/frame.exassets/css/base.cssassets/js/eh-visuals.js, only for scroll triggers
Rename the EHVisuals
module prefix to your app's and the files are yours. The mark is the one exception: inside
the umbrella, keep rendering it through UI.CoreComponents.mark/1, which is its
single definition.
Work on the library
mix deps.get
mix test # every composition, every variation
mix eh_visuals.build # docs site into _site/, CSS index, skill catalog
mix eh_visuals.serve # the same, served at http://localhost:4400 and opened