Dishes

A menu or a price list: items by section with description and price, badges such as new, diet marks with a legend and a link to order or book.

When to use it

Menus and price lists: items in sections with a description, a price, badges such as new, diet marks with their legend, and a link to order or book. It can read a collection, so the menu lives in one Sheet or file.

When not to

Products sold online (use products) and timetables (use schedule).

Accessibility

Sections are headings and items a list; prices are text, and diet marks are explained by the legend, not only by an icon or a colour.

See it live

The component library shows this component in the default theme, in every variant: open it in the component library

The dishes example as the component library shows it in the default theme

Where it is used

The starter sites that use it, each at a page that shows it:

Fields

What the component’s dialog asks for. In a Doc, keyed rows start with the key; rows in order follow the order below. Each row is one item, its cells in the order of the fields.

Field

Key

Kind

Required

Section

section

Plain text, one line

No

Name

name

Plain text, one line

Yes

Text

text

Plain text, one line

No

Price

price

Plain text, one line

No

Tags

tags

Plain text, one line

No

Link

link

A link: its text and address

No

Collection (a Sheet or JSON file in the data folder)

source

A value from a short list, or a setting

No

Keep only the items whose field or column has a value, as category = Mains or start >= today

filter

A value from a short list, or a setting

No

Variants

A variant changes how the component looks. Write it in parentheses after the name in the table’s first cell, several separated by commas.

Variant

Write in the first cell

Section links at the top

dishes (index)

From a collection

Instead of writing its items one by one, the block can show the items of a collection: a Sheet tab or a JSON file in the content/data folder. Add these rows to the table, a name in the first cell and its value in the second:

  • source: the name of the collection, such as menu (required)
  • sort: the column to order the items by; a minus before it, such as -date, orders them backwards
  • limit: the most items to show
  • filter: keep only the items whose column has a value, such as category = Mains

The first row of the collection names its columns. A name that matches no collection raises the warning unknown_data_source.

Warnings it can raise

The editor and the build say these when a block of this component needs a fix. All warnings are listed in the warnings reference.

Code

What it says

unknown_data_source

No collection named "{source}" in the data folder.

In Google Docs

A component is a table. Its first cell names it; the rows below hold its fields. This is the example table: The first row of the table here only names the columns; the Doc table is the rows below it.

Section

Name

Text

Price

Tags

dishes

To share

Hummus and flatbread

Chickpeas, tahini, lemon and warm bread.

7.50

vegan

To share

Crispy potatoes

With a smoked paprika mayonnaise.

5.90

new, vegetarian

Bowls

Market bowl

Grains, roasted vegetables and a soft egg.

12.50

popular, gluten-free

In a page file

In a site kept as a folder or in Git, the same component is a block of the page’s JSON file:

JSON
{
  "name": "dishes",
  "variants": [
    "index"
  ],
  "rows": [
    [
      "To share",
      "Hummus and flatbread",
      "Chickpeas, tahini, lemon and warm bread.",
      "7.50",
      "vegan"
    ],
    [
      "To share",
      "Crispy potatoes",
      "With a smoked paprika mayonnaise.",
      "5.90",
      "new, vegetarian"
    ],
    [
      "Bowls",
      "Market bowl",
      "Grains, roasted vegetables and a soft egg.",
      "12.50",
      "popular, gluten-free"
    ]
  ]
}

Markup and classes

What the component writes takes these classes, for a theme’s CSS: the component’s own name, name__part for its parts and name--variant for each variant (the variant’s plain name is there too).

Class

What it marks

dishes

The component

dishes__badge

A part of it

dishes__book

A part of it

dishes__description

A part of it

dishes__heading

A part of it

dishes__index

A part of it

dishes__item

A part of it

dishes__legend

A part of it

dishes__line

A part of it

dishes__list

A part of it

dishes__mark

A part of it

dishes__name

A part of it

dishes__note

A part of it

dishes__price

A part of it

dishes__section

A part of it

dishes__title

A part of it

dishes--index

A variant

The HTML the example above writes, as the component library builds it in the default theme:

html
<div class="dishes">
  <section class="dishes__section" id="to-share">
    <h3 class="dishes__heading">To share</h3>
    <ul class="dishes__list">
      <li class="dishes__item">
        <p class="dishes__line"><span class="dishes__title"><span class="dishes__name">Hummus and flatbread</span><abbr class="dishes__mark dishes__mark--vegan" title="Vegan">VG</abbr></span><span class="dishes__price">7.50</span></p>
        <p class="dishes__description">Chickpeas, tahini, lemon and warm bread.</p>
      </li>
      <li class="dishes__item">
        <p class="dishes__line"><span class="dishes__title"><span class="dishes__name">Crispy potatoes</span><abbr class="dishes__mark dishes__mark--vegetarian" title="Vegetarian">V</abbr><span class="dishes__badge dishes__badge--new">New</span></span><span class="dishes__price">5.90</span></p>
        <p class="dishes__description">With a smoked paprika mayonnaise.</p>
      </li>
    </ul>
  </section>
  <section class="dishes__section" id="bowls">
    <h3 class="dishes__heading">Bowls</h3>
    <ul class="dishes__list">
      <li class="dishes__item">
        <p class="dishes__line"><span class="dishes__title"><span class="dishes__name">Market bowl</span><abbr class="dishes__mark dishes__mark--gluten-free" title="Gluten free">GF</abbr><span class="dishes__badge dishes__badge--popular">Most ordered</span></span><span class="dishes__price">12.50</span></p>
        <p class="dishes__description">Grains, roasted vegetables and a soft egg.</p>
      </li>
    </ul>
  </section>
  <ul class="dishes__legend" aria-label="Diet marks"><li><abbr class="dishes__mark dishes__mark--vegan" title="Vegan">VG</abbr> Vegan</li><li><abbr class="dishes__mark dishes__mark--vegetarian" title="Vegetarian">V</abbr> Vegetarian</li><li><abbr class="dishes__mark dishes__mark--gluten-free" title="Gluten free">GF</abbr> Gluten free</li></ul>
</div>

Visitor texts

Texts it shows visitors, in the page’s language. Every one is in the visitor texts reference.

Key

Text

site.dishes.index

Sections of the menu

site.dishes.legend

Diet marks

site.dishes.tag.new

New

site.dishes.tag.popular

Most ordered

site.dishes.tag.vegan

Vegan

site.dishes.tag.vegetarian

Vegetarian

site.dishes.tag.gluten-free

Gluten free

site.dishes.tag.spicy

Spicy

site.dishes.mark.vegan

VG

site.dishes.mark.vegetarian

V

site.dishes.mark.gluten-free

GF

site.dishes.mark.spicy

S

site.dishes.book

Book

Extending it

Its files in SeedPage. A theme or a site changes the markup by giving a file of the same name (the Liquid part), and a new component can extend this one.

  • src/components/dishes.js
  • src/components/dishes/dishes.liquid