Lookbook v1.0.8

Preview

Represents an annotated ViewComponent preview class.

Attributes

.id

Unique ID for the preview

Type: String
.label

Label for the preview, used in navigation

Type: String
.full_path

Full filesystem path to the preview class file

Type: Pathname
.url_path

URL of the preview in Lookbook

Type: Pathname
.examples

Array of all the preview examples defined in the preview class

Type: Array
.components

Array of all the components used in the preview - usually just one!

Type: Array
.component

The first (and normally only) component used in the preview

Type: Component
.type

The entity type. Returns :preview

Type: Symbol

Methods

.tags

Returns an array of tag objects representing all tags that have been applied of the specified type.

If no tag type is provided then all tags are returned.

preview.tags(<tag_type?>)
<tag_type?>

Optional tag type to filter by - e.g. :todo

Type: Symbol
<ul id="todo-list">
  <% preview.tags(:todo).each do |todo| %>
    <li><%= todo.task %></li>
  <% end %>
</ul>

.tag

Returns the first Tag of type <tag_type> that has been applied.

preview.tag(<tag_type?>)
<tag_type?>

Optional tag type to filter by - e.g. :status

Type: Symbol
<p>Preview status: "<%= preview.tag(:status).label %>"</p>