Media Tile

Easily display a tile or set of tiles that showcase products, templates, or other media-based content.


React Component

NOTE: While MediaTile (singular) can be used on its own, it will commonly be implemented in a set. Therefore, the MediaTiles (plural) component is used these initial examples.

Basic Tiles

Tiles can include a title, body, and caption. An optional footer can also be used to provide additional final content such as a primary action. While typically a part of this component, the media area is also optional.

media tile image placeholder

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam rhoncus aliquam odio.

Vivamus dictum rutrum dui, nec placerat ante

media tile image placeholder

Praesent in magna in diam luctus accumsan.

Suspendisse eu tellus quis arcu sagittis semper

media tile image placeholder

Nam gravida, ligula vel varius porttitor, mauris lectus pulvinar orci, sit amet luctus tortor ipsum rutrum est.

Maecenas vitae leo eu tellus efficitur viverra sit amet ut tortor vestibulum

Actions

Tiles can include the following actionable features:

  • A primary action that makes the whole tile clickable through tile_link
  • Dropdown next to the title through actions_dropdown_items
  • Additional action buttons/links in the footer

NOTE: the examples below omit media but this can safely be used as well with these actions affordances.

Plain and simple

Tiles do not have to include an actions area if they're not needed.

As tiles may often be desired as an entire clickable element, the tile_link can be provided with link configurations to enable this functionality.

Since an "options" dropdown is common, you can easily pass a list of items to this default slot. This can be used in combinaton with tile_link or independently as desired.

Custom actions

In lieu of a whole clickable tile, additional actions can be provided as links in the footer area.

Standalone/Kitchen Sink Example

Previous examples have shown tiles in sets. Below is an example of a standalone tile that makes use of the compositional sections more explicitly.

MEDIA Image of Product Abra

BODY Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam rhoncus aliquam odio.

CAPTION Vivamus dictum rutrum dui, nec placerat ante

Other Settings for Media

Media Tile uses the Panel Figure to display the desired media. You can pass the desired media markup (images, embed code, etc.) in through media or with content_for :sage_media_tile_media. You can also pass configurations such as padding, background color, and aspect ratios through the media_configs property.

Sage Component

SageMediaTile
<%
common_actions_dropdown_items = [
  {
    value: "Edit",
    attributes: { href: "#edit" }
  },
  {
    value: "Duplicate",
    attributes: { href: "#duplicate" }
  },
  {
    value: "Delete",
    attributes: { href: "#delete" }
  }
]

common_footer = sage_component(SageButton, {
  value: "More",
  icon: { name: "arrow-right", style: "right" },
  subtle: true,
  style: "primary",
})

panels = [
  {
    body: %(
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Etiam rhoncus aliquam odio.
      </p>
    ),
    caption: %(
      <p>Vivamus dictum rutrum dui, nec placerat ante</p>
    ),
    media: %(#{image_tag("card-placeholder-lg.png", alt: "media tile image placeholder")}),
    title: "Product Abra",
  },
  {
    body: %(
      <p>
        Praesent in magna in diam luctus accumsan.
      </p>
    ),
    caption: %(
      <p>Suspendisse eu tellus quis arcu sagittis semper</p>
    ),
    media: %(#{image_tag("card-placeholder-lg.png", alt: "media tile image placeholder")}),
    title: "Product Cadabra",
  },
  {
    body: %(
      <p>
        Nam gravida, ligula vel varius porttitor, mauris lectus pulvinar orci, sit amet luctus tortor ipsum rutrum est.
      </p>
    ),
    caption: %(
      <p>Maecenas vitae leo eu tellus efficitur viverra sit amet ut tortor vestibulum</p>
    ),
    media: %(#{image_tag("card-placeholder-lg.png", alt: "media tile image placeholder")}),
    title: "Product Jimminycricket",
  },
]
%>
<%= md('
NOTE: While `MediaTile` (singular) can be used on its own, it will commonly be implemented in a set.
Therefore, the `MediaTiles` (plural) component is used these initial examples.
', use_sage_type: true) %>

<h3>Basic Tiles</h3>
<%= md('
Tiles can include a title, body, and caption.
An optional footer can also be used to provide additional final content such as a primary action.
While typically a part of this component, the `media` area is also optional.
', use_sage_type: true) %>
<%= sage_component SageMediaTiles, {
  items: [
    {
      title: panels[0][:title],
      body: panels[0][:body],
      caption: panels[0][:caption],
      media: panels[0][:media],
      actions_dropdown_items: common_actions_dropdown_items,
      tile_link: { href: "#tile-link" }
    },
    {
      title: panels[1][:title],
      body: panels[1][:body],
      caption: panels[1][:caption],
      media: panels[1][:media],
      actions_dropdown_items: common_actions_dropdown_items,
      tile_link: { href: "#tile-link" }
    },
    {
      title: panels[2][:title],
      body: panels[2][:body],
      caption: panels[2][:caption],
      media: panels[2][:media],
      actions_dropdown_items: common_actions_dropdown_items,
      tile_link: { href: "#tile-link" }
    }
  ]
} %>

<h3>Actions</h3>
<%= md('Tiles can include the following actionable features:

- A primary action that makes the whole tile clickable through `tile_link`
- Dropdown next to the title through `actions_dropdown_items`
- Additional action buttons/links in the `footer`

NOTE: the examples below omit `media` but this can safely be used as well with these actions affordances.

', use_sage_type: true) %>

<%= sage_component SageMediaTiles, {
  items: [
    {
      title: "Plain and simple",
      title_tag: "h1",
      body: md("Tiles do not have to include an actions area if they're not needed."),
    },
    {
      title: "Clickable Tile",
      body: md('As tiles may often be desired as an entire clickable element, the `tile_link` can be provided with link configurations to enable this functionality.'),
      tile_link: { href: "#" },
    },
    {
      title: "Actions dropdown",
      body: md('Since an "options" dropdown is common, you can easily pass a list of items to this default slot.
      This can be used in combinaton with `tile_link` or independently as desired.'),
      actions_dropdown_items: common_actions_dropdown_items,
      tile_link: { href: "#" },
    },
    {
      title: "Custom actions",
      body: md('In lieu of a whole clickable tile, additional actions can be provided as links in the footer area.'),
      footer: common_footer,
    }
  ]
} %>

<h3>Standalone/Kitchen Sink Example</h3>
<%= md('Previous examples have shown tiles in sets. Below is an example of a standalone tile that makes use of the compositional sections more explicitly.', use_sage_type: true) %>
<%= sage_component SageMediaTile, {
  media_configs: {
    aspect_ratio: 0.89,
    padded: true,
    background_color: SageTokens::COLOR_PALETTE[:SAGE_100],
  },
  tile_link: {
    href: "#",
    "data-js-modaltoggle": "pretend-modal",
  },
  title: "TITLE Kitchen Sink Example",
  title_tag: "h2",
} do %>
  <%= content_for :sage_media_tile_media do %>
    <img src="/assets/card-placeholder-lg.png" alt="MEDIA Image of Product Abra" />
  <% end %>
  <%= content_for :sage_media_tile_actions_custom do %>
    <%= sage_component SageBadge, { value: "CUSTOM Draft", color: "draft" } %>
  <% end %>
  <%= content_for :sage_media_tile_body do %>
    <p>
      BODY Lorem ipsum dolor sit amet, consectetur adipiscing elit.
      Etiam rhoncus aliquam odio.
    </p>
  <% end %>
  <%= content_for :sage_media_tile_caption do %>
    <p>CAPTION Vivamus dictum rutrum dui, nec placerat ante</p>
  <% end %>
  <%= content_for :sage_media_tile_footer do %>
    <%= sage_component SageButton, {
      value: "FOOTER More",
      icon: { name: "arrow-right", style: "right" },
      subtle: true,
      style: "primary",
    } %>
  <% end %>
<% end %>

<h3>Other Settings for Media</h3>
<%= md("
Media Tile uses the [Panel Figure](#{pages_component_path(:panel_figure)}) to display the desired media.
You can pass the desired media markup (images, embed code, etc.) in through `media` or with `content_for :sage_media_tile_media`.
You can also pass configurations such as padding, background color, and aspect ratios through the `media_configs` property.
") %>
Property Description Type Default
MediaTile

actions_dropdown_items

Provide a list of dropdown items to be used with an actions dropdown menu in the actions slot next to the title of the tile. This dropdown will appear on the far right of any other actions provided through actions_custom property or the :sage_media_tile_actions_custom slot.

See Dropdown items schema.

nil

actions_custom

Provide any items you want to appear to the right of the title in an actions_custom slot. NOTE: It is preferrable to use the actions_dropdown_items to contain interactive features. Alternatively, compose this using a content_for :sage_media_tile_actions_custom block.

String | HTML Content

nil

body

Provide content you want to appear in the body area of the tile. Alternatively, compose this using a content_for :sage_media_tile_body block.

String | HTML Content

nil

caption

Provide any items you want to appear in smaller type below the body area of the tile. Alternatively, compose this using a content_for :sage_media_tile_caption block.

String | HTML Content

nil

footer

Provide any items you want to appear to very bottom of the tile such as an action button. Alternatively, compose this using a content_for :sage_media_tile_footer block.

String | HTML Content

nil

media

Provide the media markup to be displayed within the tile. Alternatively, compose this using a content_for :sage_media_tile_media block. Typically this is an image, but other mebed code can be provided as well. Use the media_configs property to provide additional settings.

String | HTML Content

nil

media_configs

Allows for a set of configurations for the media figure that plays a prominent role in this tiling component.

See schema for Panel Figure

nil

tile_link

Provide a primary action link configuration that makes the whole tile clickable. Similar to attributes on SageButton, this is a Hash that can contain any HTML attribute desired for this link.

Hash

nil

title

Provide the "header" content for the tile.

String

nil

title_tag

Sets which HTML heading tag to use on the title.

One of h1 through h6

h3

Sections

Element

sage_media_tile_media

Provides the HTML content for the media area at the top of the tile; same purpose as the media property.

Any; typically images or video embeds.

sage_media_tile_actions_custom

Provides the HTML content for a custom set of actions or other content that is placed to the right of the title; same purpose as the acttions_custom property.

Any; typically SageButton or SageBadge.

sage_media_tile_body

Provides HTML content for the main body copy area; same purpose as the body property.

Any; formatted as HTML.

sage_media_tile_caption

Provides HTML content for the smaller "caption" copy area below the body; same purpose as the caption property.

Any; formatted as HTML.

sage_media_tile_footer

Provides HTML content for the very bottom portion of the tile that is also aligned to the bottom consistently when tiles are stretched; same purpose as the caption property.

Any; typically SageButton or SageLink.

MediaTiles

items

required

Provide a set of items to be rendered as MediaTiles.

See schema for MediaTile above.

nil

Do
  • Keep interactive features simple.
Don't
  • Use tile_link and actions in the footer; only use one or the other.