View Source Phx.Live.Favicon (Phoenix Live Favicon v0.2.0)

Provides commands for manipulating the Favicon of Phoenix Live View applications while minimizing data over the wire.

The available command actions support a variety of utility operations useful for Favicon manipulation. Such as setting or removing tag attributes and adding or removing CSS classes for vector (SVG) favicons.

The elements selected for manipulation are found by Javascript client code document.querySelectorAll("link[rel*=icon]").

Link to this section Summary

Functions

Add a class_name to the list of classes on all favicon link elements

Remove an attribute from all favicon link elements

Remove a class_name from the list of classes on all favicon link elements

Reset all favicon link elements to their initial values

Reset an attribute to it's initial value on all favicon link elements

Restore snapshot with name

Restore an attribute from snapshot with named name

Set a new value to the attribute on all favicon link elements

Set the class on all favicon link elements

Set the value of a {placeholder} on all favicon link elements

Make a snapshot with name name of all favicon link element attribute values

Create a snapshot named name of an attribute from all favicon link element

Toggle class_name on all favicon link elements

Link to this section Types

Link to this section Functions

Link to this function

add_class(socket, class_name)

View Source

Add a class_name to the list of classes on all favicon link elements

Link to this function

remove_attr(socket, attr)

View Source

Remove an attribute from all favicon link elements

Link to this function

remove_class(socket, class_name)

View Source

Remove a class_name from the list of classes on all favicon link elements

@spec reset(Phoenix.LiveView.Socket.t()) :: map()

Reset all favicon link elements to their initial values

Link to this function

reset_attr(socket, attr)

View Source

Reset an attribute to it's initial value on all favicon link elements

@spec restore(Phoenix.LiveView.Socket.t(), name()) :: map()

Restore snapshot with name

Link to this function

restore_attr(socket, name, attr)

View Source
@spec restore_attr(Phoenix.LiveView.Socket.t(), name(), attr()) :: map()

Restore an attribute from snapshot with named name

Link to this function

set_attr(socket, attr, value)

View Source

Set a new value to the attribute on all favicon link elements

Link to this function

set_class(socket, class)

View Source

Set the class on all favicon link elements

Link to this function

set_dynamic(socket, placeholder, value)

View Source

Set the value of a {placeholder} on all favicon link elements

dynamic-attributes-placeholders

Dynamic attributes / placeholders

To use a dynamic value for an attribute, the element must have an additional data-dynamic-[attribute] attribute with a value containing a named placeholder. For example: {sub} in attribute href.

Example

  <!-- data-dynamic-href is set -->
  <!-- {sub} is used in it's value -->
<link rel='icon' href="default_fav.png" data-dynamic-href="favs/{sub}/fav-16x16.png">

When an event is pushed with set_dynamic("sub", "new_message") the result will be:

<link rel='icon' href="favs/new_message/fav-16x16.png">
@spec snap(Phoenix.LiveView.Socket.t(), name()) :: map()

Make a snapshot with name name of all favicon link element attribute values

Link to this function

snap_attr(socket, name, attr)

View Source
@spec snap_attr(Phoenix.LiveView.Socket.t(), name(), attr()) :: map()

Create a snapshot named name of an attribute from all favicon link element

Link to this function

toggle_class(socket, class_name)

View Source

Toggle class_name on all favicon link elements