Pieces in Phoenix: player/1 plays one in a page, through its own
LiveView (Ascii.Phoenix.PlayerLive); live_player/1 plays one
inside yours (Ascii.Phoenix.PlayerComponent), taking new options as
your assigns change, for live data. For a still, use
Ascii.Phoenix.Components.ascii/1.
<Ascii.Phoenix.player socket={@socket} id="donut" piece="donut" />
<Ascii.Phoenix.player socket={@socket} id="coast" piece="night-coast" render={:server} />
<Ascii.Phoenix.player socket={@socket} id="hello" piece="big-text" ink="#ff5f6d,#ffc371" />
<Ascii.Phoenix.player socket={@socket} id="boot" piece="boot-log" parts />
<Ascii.Phoenix.live_player id="files" piece="file-tree" options={%{walk: false, paths: @paths}} interactive notify />Only available when phoenix_live_view is a dependency.
Summary
Functions
Plays a piece inside your LiveView, taking new options each time it is
rendered with them: for live data (see Ascii.Phoenix.PlayerComponent).
Plays a piece, embedding Ascii.Phoenix.PlayerLive with live_render/3.
Functions
Plays a piece inside your LiveView, taking new options each time it is
rendered with them: for live data (see Ascii.Phoenix.PlayerComponent).
<Ascii.Phoenix.live_player id="load" piece="gauge" options={%{label: "load", value: @load}} />Attributes
id(:string) (required) - unique on the page.piece(:any) (required) - a slug, or a module implementingAscii.Piece.options(:map) - the piece's options; new ones are taken up as it plays. Defaults to%{}.fps(:integer) - frames a second; the piece's own by default. Defaults tonil.mono(:boolean) - draw a coloured piece in one ink. Defaults tofalse.ink(:any) - as forplayer/1. Defaults tonil.gradient(:atom) - as forplayer/1. Defaults tonil.parts(:any) - as forplayer/1. Defaults tonil.paper(:boolean) - dark ink on a light page. Defaults tofalse.render(:atom) - as forplayer/1. Defaults to:client. Must be one of:client, or:server.label(:string) - as forplayer/1. Defaults tonil.interactive(:boolean) - as forplayer/1. Defaults tofalse.notify(:boolean) - send your LiveView each key and click (seeAscii.Phoenix.PlayerComponent). Defaults tofalse.
Plays a piece, embedding Ascii.Phoenix.PlayerLive with live_render/3.
Attributes
socket(:any) (required) - the parent LiveView's socket (or the conn in a dead view).id(:string) (required) - a DOM id, unique on the page.piece(:any) (required) - a slug, or a module implementingAscii.Piece.options(:map) - the piece's options. Defaults to%{}.fps(:integer) - frames a second; the piece's own by default. Defaults tonil.mono(:boolean) - draw a coloured piece in one ink. Defaults tofalse.ink(:any) - the colour of a piece in one ink:"#rrggbb", or a list (or comma-separated) for a gradient; seeAscii.Ink. Defaults tonil.gradient(:atom) - which way several inks run;:horizontalby default. Defaults tonil. Must be one ofnil,:horizontal,:vertical, or:diagonal.parts(:any) - colours for the piece's parts: a map of part names to colours, ortruefor the ones it suggests; seeAscii.Parts. Defaults tonil.paper(:boolean) - dark ink on a light page. Defaults tofalse.render(:atom) -:clientdraws in the browser with the hook (loops sent once, then only changes);:serverpatches HTML from the server, with no hook. Defaults to:client. Must be one of:client, or:server.label(:string) - what the picture shows, for screen readers; by default the piece tells it from its options (Ascii.describe/1). Defaults tonil.interactive(:boolean) - keys and clicks go to the piece (Ascii.handle_event/2): its element takes focus, and arrows, space, enter and typing reach it (clicks need the hook). Defaults tofalse.notify(:boolean) - send the LiveView that embeds the player{:ascii, id, info}for each key and click (seeAscii.Phoenix.PlayerComponent). Defaults tofalse.