Content components
Components of the Content group of frame_demo_umami. They are Twig and CSS; Questions and answers adds a small plain script. Most of their content is a list prop: in the editor a list is a table of values that are added, dragged into order and removed (Lists and groups).
Questions and answers
components/faq. An FAQ: questions that open to their answers.
| Prop | |
|---|---|
heading, intro | above the questions |
items | the list: question (text) and answer (rich text of a text format) |
look | Lines between, Box around each, Cards with a shadow |
searchable | a search field that shows only the questions with the words typed |
toggle_all | an Open all / Close all button |
single | one open at a time |
open_first | the first one starts open |
schema | adds the questions as schema.org FAQPage data (JSON-LD) for search engines |
Each question is a native <details> element, so it opens with the keyboard and without JavaScript. One open at a time is the name attribute of <details>, also without JavaScript. faq.js shows the search and the button only once it runs; the search ignores case and accents, says how many questions it found to screen readers, and shows a message when none has the words.
Uses a list of objects, rich text in a list (filtered by its text format, like a rich text prop), x-builder-summary to name the rows of the list by their question, structured data from Twig.
Limitations. With For search engines, use one FAQ per page: search engines expect one FAQPage. In the editor all questions are open (Frame opens every <details> so that its content can be edited).
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
name: 'Questions and answers'
status: experimental
description: 'An FAQ: questions that open to their answers, with a search over them, "Open all", and the structured data search engines read (schema.org FAQPage).'
group: Content
help: |
Each line of Questions is a question with its answer. The answer is formatted text: lists, links and bold work.
Search shows only the questions that have the words typed. With "For search engines" the page also has the questions as schema.org FAQPage data; use it on one FAQ per page.
props:
type: object
properties:
heading:
type: string
title: Heading
examples: ['Questions and answers']
intro:
type: string
title: Introduction
x-builder-widget: textarea
examples: ['Everything about the classes. Something missing? Write to us.']
items:
type: array
title: Questions
x-builder-summary: question
minItems: 1
items:
type: object
properties:
question:
type: string
title: Question
examples: ['A question']
answer:
type: string
title: Answer
contentMediaType: text/html
x-formatting-context: block
examples: ['The answer.']
required: [question, answer]
examples:
- - { question: 'Do I need any experience?', answer: 'No. Every class starts from the basics, and the chef cooks with you.' }
- { question: 'What should I bring?', answer: 'Nothing but an appetite. Aprons, knives and ingredients are ready for you.' }
- { question: 'Can I cancel?', answer: 'Yes, up to 48 hours before the class, for a full refund.' }
- { question: 'Are there vegetarian classes?', answer: 'Every class has a vegetarian version. Tell us when you book.' }
look:
type: string
title: Look
enum: [lines, boxed, cards]
meta:enum: { lines: 'Lines between', boxed: 'Box around each', cards: 'Cards with a shadow' }
examples: [boxed]
searchable:
type: boolean
title: Search
description: 'A field over the questions that shows only those with the words typed.'
examples: [true]
toggle_all:
type: boolean
title: '"Open all" button'
examples: [true]
single:
type: boolean
title: 'One open at a time'
description: 'Opening a question closes the one that was open.'
examples: [false]
open_first:
type: boolean
title: 'First one open'
examples: [true]
schema:
type: boolean
title: 'For search engines'
description: 'Adds the questions as schema.org FAQPage data to the page.'
examples: [false]
required: [items]
thirdPartySettings:
frame_editor:
icon: accordion
example: { type: 'frame_demo_umami:faq', props: { heading: 'Before you book', look: boxed, searchable: true, toggle_all: true, open_first: true, schema: true, items: [ { question: 'Do I need any experience?', answer: 'No. Every class starts from the basics.' }, { question: 'Can I cancel?', answer: 'Yes, up to 48 hours before the class.' } ] } }
libraryOverrides:
dependencies:
- core/drupal
- core/drupal.debounce
- core/once{#
/**
* @file
* Questions and answers: native details elements; faq.js adds the search and "Open all".
*/
#}
{% set group = 'faq-' ~ random() %}
<section {{ attributes.addClass('faq', 'faq--' ~ look|default('boxed')).setAttribute('data-faq', '') }}>
{% if heading or intro %}
<header class="faq__header">
{% if heading %}<h2 class="faq__heading">{{ heading }}</h2>{% endif %}
{% if intro %}<p class="faq__intro">{{ intro }}</p>{% endif %}
</header>
{% endif %}
{% if searchable is not same as(false) or toggle_all is not same as(false) %}
{# Shown by faq.js: without JavaScript they would do nothing. #}
<div class="faq__tools" hidden>
{% if searchable is not same as(false) %}
<label class="faq__search">
<span class="visually-hidden">{{ 'Search the questions'|t }}</span>
<i class="bi bi-search" aria-hidden="true"></i>
<input type="search" name="faq-search" placeholder="{{ 'Search the questions'|t }}" autocomplete="off" data-faq-search>
</label>
{% endif %}
{% if toggle_all is not same as(false) %}
<button type="button" class="faq__toggle" data-faq-toggle aria-pressed="false">{{ 'Open all'|t }}</button>
{% endif %}
</div>
<p class="faq__status visually-hidden" aria-live="polite" data-faq-status></p>
{% endif %}
<div class="faq__items">
{% for item in items %}
<details class="faq__item"{% if single %} name="{{ group }}"{% endif %}{% if loop.first and open_first is not same as(false) %} open{% endif %}>
<summary class="faq__question">{{ item.question }}</summary>
<div class="faq__answer">{{ item.answer }}</div>
</details>
{% endfor %}
</div>
<p class="faq__empty" hidden data-faq-empty>{{ 'No question has these words.'|t }}</p>
{% if schema %}
{% set entities = [] %}
{% for item in items %}
{% set entities = entities|merge([{ '@type': 'Question', 'name': item.question, 'acceptedAnswer': { '@type': 'Answer', 'text': item.answer|render|striptags|trim } }]) %}
{% endfor %}
<script type="application/ld+json">{{ { '@context': 'https://schema.org', '@type': 'FAQPage', 'mainEntity': entities }|json_encode(constant('JSON_UNESCAPED_UNICODE') b-or constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }}</script>
{% endif %}
</section>/**
* @file
* Questions and answers: search over the questions and the "Open all" button.
*/
((Drupal, once) => {
const words = (text) => text.toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g, '').split(/\s+/).filter(Boolean);
function init(root) {
const items = [...root.querySelectorAll('.faq__item')];
const tools = root.querySelector('.faq__tools');
const search = root.querySelector('[data-faq-search]');
const toggle = root.querySelector('[data-faq-toggle]');
const status = root.querySelector('[data-faq-status]');
const empty = root.querySelector('[data-faq-empty]');
if (tools) tools.hidden = false;
const visible = () => items.filter((item) => !item.hidden);
const syncToggle = () => {
if (!toggle) return;
const all = visible().length > 0 && visible().every((item) => item.open);
toggle.textContent = all ? Drupal.t('Close all') : Drupal.t('Open all');
toggle.setAttribute('aria-pressed', String(all));
};
if (search) {
const texts = items.map((item) => words(item.textContent).join(' '));
const filter = Drupal.debounce(() => {
const wanted = words(search.value);
items.forEach((item, index) => {
item.hidden = wanted.length > 0 && !wanted.every((word) => texts[index].includes(word));
});
const count = visible().length;
empty.hidden = count > 0;
status.textContent = wanted.length
? Drupal.formatPlural(count, '1 question found', '@count questions found')
: '';
syncToggle();
}, 150);
search.addEventListener('input', filter);
}
if (toggle) {
toggle.addEventListener('click', () => {
const open = toggle.getAttribute('aria-pressed') !== 'true';
// Questions that close one another ("One open at a time") cannot all be open.
visible().forEach((item) => { item.removeAttribute('name'); item.open = open; });
syncToggle();
});
items.forEach((item) => item.addEventListener('toggle', syncToggle));
syncToggle();
}
}
Drupal.behaviors.frameDemoFaq = {
attach(context) {
once('frame-demo-faq', '[data-faq]', context).forEach(init);
},
};
})(Drupal, once);Timeline
components/timeline. Moments in order along a line: a history, the steps of a process, a programme.
| Prop | |
|---|---|
heading | above the line |
items | the list: date ("1998", "Step 1"), title, text, icon, highlight |
layout | Alternating sides from tablet width on, or At the start |
markers | Dots, Icons or Numbers on the line |
reveal | each moment fades in as it scrolls into view |
An ordered list (<ol>). The fading in is a CSS scroll-driven animation (animation-timeline: view()): it needs no script, is skipped by browsers that do not have it and for visitors who prefer less motion, and is off in the editor.
Uses a list with an icon picker and a checkbox in each row, @supports, logical properties (it mirrors in right-to-left languages).
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
name: Timeline
status: experimental
description: 'Moments in order along a line: a history, the steps of a process, a programme. Alternating sides on wide screens, each with a date, an icon and a text.'
group: Content
props:
type: object
properties:
heading:
type: string
title: Heading
examples: ['Our story']
items:
type: array
title: Moments
x-builder-summary: title
minItems: 1
items:
type: object
properties:
date:
type: string
title: 'Date or step'
description: '"1998", "May 2024", "Step 1".'
examples: ['2024']
title:
type: string
title: Title
examples: ['What happened']
text:
type: string
title: Text
x-builder-widget: textarea
icon:
type: string
title: Icon
description: 'In the marker on the line, when the markers show icons.'
x-builder-widget: icon
x-builder-icon-class: 'bi bi-{name}'
enum: [star, heart, check-circle, lightning, trophy, rocket, shield-check, clock, calendar-event, geo-alt, people, person, chat-dots, envelope, telephone, globe, cart, bag, gift, tag, truck, basket, cup-hot, egg-fried, fire, leaf, flower1, sun, moon, snow, droplet, award, bookmark, camera, music-note, play-circle, graph-up, gear, lock, info-circle]
highlight:
type: boolean
title: Highlight
description: 'Shows this moment in the accent colour.'
required: [title]
examples:
- - { date: '1998', title: 'A kitchen in Milan', text: 'Nonna Lucia teaches her neighbours to make fresh pasta.', icon: egg-fried }
- { date: '2009', title: 'The first school', text: 'Twelve places, one long table and a wood oven.', icon: fire }
- { date: '2017', title: 'Classes for children', text: 'Saturday mornings become the busiest of the week.', icon: people }
- { date: '2024', title: 'Ten thousand cooks', text: 'Someone learns to cook with us every day of the year.', icon: trophy, highlight: true }
layout:
type: string
title: Arrangement
description: 'Alternating puts the moments on both sides of the line from tablet width on; at the start keeps them on one side.'
enum: [alternate, start]
meta:enum: { alternate: Alternating, start: 'At the start' }
examples: [alternate]
markers:
type: string
title: Markers
enum: [dot, icon, number]
meta:enum: { dot: Dots, icon: Icons, number: Numbers }
examples: [icon]
reveal:
type: boolean
title: 'Appear while scrolling'
description: 'Each moment fades in as it scrolls into view, in browsers that can do that with CSS only. Not for visitors who prefer less motion.'
examples: [true]
required: [items]
thirdPartySettings:
frame_editor:
icon: list
example: { type: 'frame_demo_umami:timeline', props: { heading: 'How a class goes', layout: start, markers: number, items: [ { date: '18:00', title: 'Welcome and aprons on' }, { date: '18:15', title: 'Dough by hand', text: 'Flour, eggs and patience.' }, { date: '20:00', title: 'Dinner together', highlight: true } ] } }{#
/**
* @file
* Timeline: an ordered list along a line. CSS only.
*/
#}
<section {{ attributes.addClass('timeline', 'timeline--' ~ layout|default('alternate'), 'timeline--markers-' ~ markers|default('icon'), reveal is same as(false) ? 'timeline--static' : 'timeline--reveal') }}>
{% if heading %}<h2 class="timeline__heading">{{ heading }}</h2>{% endif %}
<ol class="timeline__items">
{% for item in items %}
<li class="timeline__item{{ item.highlight ? ' timeline__item--highlight' }}">
<span class="timeline__marker" aria-hidden="true">
{%- if markers == 'number' %}{{ loop.index }}{% elseif markers|default('icon') == 'icon' and item.icon %}<i class="bi bi-{{ item.icon }}"></i>{% endif -%}
</span>
<div class="timeline__card">
{% if item.date %}<p class="timeline__date">{{ item.date }}</p>{% endif %}
<h3 class="timeline__title">{{ item.title }}</h3>
{% if item.text %}<p class="timeline__text">{{ item.text }}</p>{% endif %}
</div>
</li>
{% endfor %}
</ol>
</section>.timeline { --timeline-accent: var(--frame-accent, #008068); --timeline-line: color-mix(in srgb, var(--timeline-accent) 25%, transparent); --timeline-marker: 2.5rem; margin-block: 0 var(--frame-space-l, 2rem); }
.timeline__heading { margin: 0 0 var(--frame-space-l, 2rem); text-align: center; }
.timeline__items { position: relative; display: grid; gap: var(--frame-space-l, 2rem); margin: 0; padding: 0; list-style: none; }
.timeline__items::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: calc(var(--timeline-marker) / 2 - 1px); width: 2px; background: var(--timeline-line); }
.timeline__item { position: relative; display: grid; grid-template-columns: var(--timeline-marker) minmax(0, 1fr); gap: var(--frame-space-m, 1rem); align-items: start; }
.timeline__marker {
z-index: 1; display: grid; place-items: center; width: var(--timeline-marker); height: var(--timeline-marker); border: 2px solid var(--timeline-accent);
border-radius: 50%; background: #fff; color: var(--timeline-accent); font-weight: 700; font-size: 1rem;
}
.timeline--markers-dot .timeline__marker { width: 1rem; height: 1rem; margin: 0.75rem auto 0; background: var(--timeline-accent); }
.timeline__item--highlight .timeline__marker { background: var(--timeline-accent); color: #fff; box-shadow: 0 0 0 6px color-mix(in srgb, var(--timeline-accent) 18%, transparent); }
.timeline__card { padding: var(--frame-space-m, 1rem) 1.25rem; border-radius: 0.75rem; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%); }
.timeline__item--highlight .timeline__card { outline: 2px solid var(--timeline-accent); }
.timeline__date { margin: 0 0 0.2rem; color: var(--timeline-accent); font-size: 0.875rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.timeline__title { margin: 0; font-size: 1.2rem; }
.timeline__text { margin: 0.4rem 0 0; opacity: 0.85; }
/* Alternating: the line in the middle, the cards on both sides. */
@media (min-width: 48em) {
.timeline--alternate .timeline__items::before { inset-inline-start: calc(50% - 1px); }
.timeline--alternate .timeline__item { grid-template-columns: minmax(0, 1fr) var(--timeline-marker) minmax(0, 1fr); }
.timeline--alternate .timeline__marker { grid-column: 2; grid-row: 1; }
.timeline--alternate .timeline__item:nth-child(odd) .timeline__card { grid-column: 1; grid-row: 1; text-align: end; }
.timeline--alternate .timeline__item:nth-child(even) .timeline__card { grid-column: 3; grid-row: 1; }
}
/* Each moment fades in as it scrolls into view: CSS scroll-driven animations, where the browser has them. */
@supports (animation-timeline: view()) {
@media (prefers-reduced-motion: no-preference) {
.timeline--reveal .timeline__card { animation: timeline-reveal linear both; animation-timeline: view(); animation-range: entry 0% cover 30%; }
}
}
@keyframes timeline-reveal {
from { opacity: 0; transform: translateY(1.5rem); }
to { opacity: 1; transform: none; }
}
/* Frame's canvas: everything visible at once. */
#frame-editor .timeline__card { animation: none; }Feature grid
components/feature-grid. Reasons, services or benefits in a grid.
| Prop | |
|---|---|
eyebrow, heading, intro | the header; the eyebrow is a short line in small capitals |
items | the list (up to 12): icon, title, text, url, link_label |
columns | 2, 3 or 4 on a wide screen; phones show one, tablets two |
look | Plain, Cards or With a border |
icon_position | above the title or beside the text |
icon_color | a colour of the theme's palette |
centered | header and items centred |
slot actions | buttons under the grid |
An item with a link and no link text is a link as a whole: the link of its title covers the card, so there is one link to tab to and the screen reader reads the title. With a link text, the link is a separate line under the text.
Uses a list with an icon picker and a link field (the editor's link field finds content of the site by its title), the colour widget (x-builder-widget: color) that offers only the theme's palette, a slot laid out with flex and its second rule for the editor.
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
name: 'Feature grid'
status: experimental
description: 'Reasons, services or benefits in a grid: each with an icon, a title, a short text and an optional link. Two to four columns, as plain items or cards.'
group: Content
props:
type: object
properties:
eyebrow:
type: string
title: 'Line above the heading'
description: 'A few words in small capitals: "Why us".'
examples: ['Why cook with us']
heading:
type: string
title: Heading
examples: ['Everything you need to cook with confidence']
intro:
type: string
title: Introduction
x-builder-widget: textarea
items:
type: array
title: Features
x-builder-summary: title
minItems: 1
maxItems: 12
items:
type: object
properties:
icon:
type: string
title: Icon
x-builder-widget: icon
x-builder-icon-class: 'bi bi-{name}'
enum: [star, heart, check-circle, lightning, trophy, rocket, shield-check, clock, calendar-event, geo-alt, people, person, chat-dots, envelope, telephone, globe, cart, bag, gift, tag, truck, basket, cup-hot, egg-fried, fire, leaf, flower1, sun, moon, snow, droplet, award, bookmark, camera, music-note, play-circle, graph-up, gear, lock, info-circle]
examples: [star]
title:
type: string
title: Title
examples: ['A feature']
text:
type: string
title: Text
x-builder-widget: textarea
url:
type: string
title: Link
format: uri-reference
link_label:
type: string
title: 'Link text'
description: 'Without it the whole item is the link.'
required: [title]
examples:
- - { icon: people, title: 'Small groups', text: 'Eight cooks at most, so the chef has time for each of you.' }
- { icon: basket, title: 'Market produce', text: 'Vegetables, cheese and flour from farms around the city.' }
- { icon: clock, title: 'Evening and weekend', text: 'Classes after work and on Saturday mornings.' }
- { icon: gift, title: 'A gift that lasts', text: 'Vouchers for any class, valid for a year.', url: '/contact', link_label: 'Buy a voucher' }
- { icon: cup-hot, title: 'Dinner included', text: 'Every class ends at the table, with what you cooked.' }
- { icon: award, title: 'Real chefs', text: 'Taught by cooks from the best kitchens in town.' }
columns:
type: integer
title: Columns
description: 'On a wide screen. Phones show one, tablets two.'
enum: [2, 3, 4]
examples: [3]
look:
type: string
title: Look
enum: [plain, cards, outline]
meta:enum: { plain: Plain, cards: Cards, outline: 'With a border' }
examples: [cards]
icon_position:
type: string
title: 'Icon position'
enum: [top, start]
meta:enum: { top: 'Above the title', start: 'Beside the text' }
examples: [top]
icon_color:
type: string
title: 'Icon colour'
description: 'A colour of the theme. Without one the accent colour.'
x-builder-widget: color
centered:
type: boolean
title: Centred
description: 'Heading and items centred.'
examples: [false]
required: [items]
slots:
actions:
title: Actions
description: 'Buttons under the grid.'
thirdPartySettings:
frame_editor:
icon: 'bi bi-grid-3x3-gap'
example: { type: 'frame_demo_umami:feature-grid', props: { eyebrow: 'Why us', heading: 'Cook with confidence', columns: 3, look: cards, icon_position: top, items: [ { icon: people, title: 'Small groups', text: 'Eight cooks at most.' }, { icon: basket, title: 'Market produce', text: 'From farms around the city.' }, { icon: clock, title: 'Evenings', text: 'Classes after work.' } ], actions: [ { type: 'frame:button', props: { label: 'See the classes', url: '/classes', variant: primary } } ] } }{#
/**
* @file
* Feature grid: a list of items with an icon, a title, a text and a link.
*/
#}
<section {{ attributes.addClass('feature-grid', 'feature-grid--' ~ look|default('cards'), 'feature-grid--icon-' ~ icon_position|default('top'), 'feature-grid--cols-' ~ columns|default(3), centered ? 'feature-grid--centered' : null) }}>
{% if eyebrow or heading or intro %}
<header class="feature-grid__header">
{% if eyebrow %}<p class="feature-grid__eyebrow">{{ eyebrow }}</p>{% endif %}
{% if heading %}<h2 class="feature-grid__heading">{{ heading }}</h2>{% endif %}
{% if intro %}<p class="feature-grid__intro">{{ intro }}</p>{% endif %}
</header>
{% endif %}
<ul class="feature-grid__items"{% if icon_color %} style="--feature-icon-color: {{ icon_color }}"{% endif %}>
{% for item in items %}
<li class="feature-grid__item{{ item.url and not item.link_label ? ' feature-grid__item--linked' }}">
{% if item.icon %}<span class="feature-grid__icon" aria-hidden="true"><i class="bi bi-{{ item.icon }}"></i></span>{% endif %}
<div class="feature-grid__body">
<h3 class="feature-grid__title">
{%- if item.url and not item.link_label %}<a href="{{ item.url }}">{{ item.title }}</a>{% else %}{{ item.title }}{% endif -%}
</h3>
{% if item.text %}<p class="feature-grid__text">{{ item.text }}</p>{% endif %}
{% if item.url and item.link_label %}<a class="feature-grid__link" href="{{ item.url }}">{{ item.link_label }}<i class="bi bi-arrow-right" aria-hidden="true"></i></a>{% endif %}
</div>
</li>
{% endfor %}
</ul>
<div class="feature-grid__actions">{% block actions %}{% endblock %}</div>
</section>Comparison table
components/comparison-table. What each option includes, feature by feature.
| Prop | |
|---|---|
heading, caption | the caption is read by screen readers before the table, and shown under the heading |
columns | the options (up to 5): name, note (a price), highlight |
rows | feature, description, values (one per column, in the order of the columns) |
striped | every other row tinted |
A value yes is a check mark and no a dash, both with a text for screen readers (Included, Not included); any other value is shown as typed. A row with no values is a heading that groups the rows under it. The table is a real <table> with scope on its headers; on a phone it scrolls sideways inside a focusable region, and the first column stays in place.
Uses a list of lists (values inside each row): in a list of lists an empty value keeps its place, so an empty cell stays an empty cell.
Limitations. The values follow the columns by position: when a column is moved, move the values of each row too.
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
name: 'Comparison table'
status: experimental
description: 'What each option includes, feature by feature: plans, products or classes side by side. "yes" and "no" become check marks, the first column stays visible while the table scrolls on a phone.'
group: Content
help: |
Columns are the options compared. Each row is a feature with one value per column, in the order of the columns.
A value "yes" shows a check mark and "no" a dash, both read out to screen readers; any other text is shown as it is ("2 hours", "Up to 8"). A row with no values is a heading that groups the rows under it.
props:
type: object
properties:
heading:
type: string
title: Heading
examples: ['Compare the classes']
caption:
type: string
title: 'Description of the table'
description: 'Read by screen readers before the table; shown under the heading.'
examples: ['What each class includes.']
columns:
type: array
title: Columns
x-builder-summary: name
minItems: 1
maxItems: 5
items:
type: object
properties:
name:
type: string
title: Name
examples: ['Option']
note:
type: string
title: 'Line under the name'
description: 'A price or a short remark.'
highlight:
type: boolean
title: Highlight
description: 'The recommended option, in the accent colour.'
required: [name]
examples:
- - { name: Taster, note: '€45' }
- { name: Classic, note: '€85', highlight: true }
- { name: 'Chef''s table', note: '€140' }
rows:
type: array
title: Rows
x-builder-summary: feature
items:
type: object
properties:
feature:
type: string
title: Feature
examples: ['A feature']
description:
type: string
title: Explanation
description: 'A short note under the feature.'
values:
type: array
title: 'Values, one per column'
items:
type: string
title: Value
required: [feature]
examples:
- - { feature: 'In the kitchen' }
- { feature: Length, values: ['2 hours', '3 hours', '4 hours'] }
- { feature: 'Cooks per class', values: ['Up to 12', 'Up to 8', 'Up to 4'] }
- { feature: 'Apron to take home', values: ['no', 'yes', 'yes'] }
- { feature: 'At the table' }
- { feature: 'Dinner with wine', description: 'Soft drinks for under-18s.', values: ['no', 'yes', 'yes'] }
- { feature: 'Recipes by e-mail', values: ['yes', 'yes', 'yes'] }
- { feature: 'Dessert from the chef', values: ['no', 'no', 'yes'] }
striped:
type: boolean
title: 'Striped rows'
examples: [true]
required: [columns, rows]
thirdPartySettings:
frame_editor:
icon: table
example: { type: 'frame_demo_umami:comparison-table', props: { heading: 'Compare the plans', columns: [ { name: Basic, note: '€9' }, { name: Pro, note: '€19', highlight: true } ], rows: [ { feature: 'Recipes', values: ['50', 'All'] }, { feature: 'Live classes', values: ['no', 'yes'] } ] } }{#
/**
* @file
* Comparison table: a real table, scrolled sideways inside its region on narrow screens.
*/
#}
{% set caption_id = 'comparison-' ~ random() %}
<section {{ attributes.addClass('comparison', striped is same as(false) ? null : 'comparison--striped') }}>
{% if heading %}<h2 class="comparison__heading">{{ heading }}</h2>{% endif %}
<div class="comparison__scroll" role="region" tabindex="0" aria-labelledby="{{ caption_id }}">
<table class="comparison__table">
<caption id="{{ caption_id }}" class="{{ caption ? 'comparison__caption' : 'visually-hidden' }}">{{ caption|default(heading|default('Comparison'|t)) }}</caption>
<thead>
<tr>
<td class="comparison__corner"></td>
{% for column in columns %}
<th scope="col" class="comparison__column{{ column.highlight ? ' comparison__column--highlight' }}">
{% if column.highlight %}<span class="comparison__badge">{{ 'Recommended'|t }}</span>{% endif %}
<span class="comparison__name">{{ column.name }}</span>
{% if column.note %}<span class="comparison__note">{{ column.note }}</span>{% endif %}
</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in rows %}
{% if row.values is empty %}
<tr class="comparison__group"><th scope="colgroup" colspan="{{ columns|length + 1 }}">{{ row.feature }}</th></tr>
{% else %}
<tr>
<th scope="row" class="comparison__feature">
{{ row.feature }}
{% if row.description %}<span class="comparison__description">{{ row.description }}</span>{% endif %}
</th>
{% for column in columns %}
{% set value = row.values[loop.index0]|default('') %}
<td class="{{ column.highlight ? 'comparison__cell--highlight' }}">
{%- if value|lower in ['yes', 'true', '✓'] -%}
<i class="bi bi-check-circle-fill comparison__yes" aria-hidden="true"></i><span class="visually-hidden">{{ 'Included'|t }}</span>
{%- elseif value|lower in ['no', 'false', '-', '—'] -%}
<span class="comparison__no" aria-hidden="true">–</span><span class="visually-hidden">{{ 'Not included'|t }}</span>
{%- else -%}
{{ value }}
{%- endif -%}
</td>
{% endfor %}
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</section>Icon
components/icon. One icon, in a size, a colour of the theme, and optionally in a round badge. The icon is one of the Flowbite Icons of the theme's icon packs (Drupal's Icon API, frame_demo_umami.icons.yml), or a glyph of the Bootstrap Icons font. With a text for screen readers it is an image (role="img"); without, it is hidden from them.
The icon font (the second choice) is built from components/icon/index.js into assets/icon.css and attached on every page by the library frame_demo_umami/icons (in frame_demo_umami.info.yml). That is what lets every component print <i class="bi bi-…">, and lets the editor draw the icons of its icon picker (x-builder-widget: icon with x-builder-icon-class: 'bi bi-{name}') and of the Blocks panel (icon: 'bi bi-segmented-nav').
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
name: Icon
status: experimental
description: 'One icon of Bootstrap Icons, in a size and a colour of the theme, optionally in a round badge.'
group: Content
props:
type: object
properties:
name:
type: string
title: 'Bootstrap Icons font'
x-builder-widget: icon
x-builder-icon-class: 'bi bi-{name}'
x-builder-icon-library: frame_demo_umami/icons
enum: [star, heart, check-circle, lightning, trophy, rocket, shield-check, clock, calendar-event, geo-alt, people, person, chat-dots, envelope, telephone, globe, cart, bag, gift, tag, truck, basket, cup-hot, egg-fried, fire, leaf, flower1, sun, moon, snow, droplet, award, bookmark, camera, music-note, play-circle, graph-up, gear, lock, info-circle]
examples: [star]
icon:
type: string
title: 'Icon of the icon pack'
description: 'An icon of the Icon API pack of the theme. When one is chosen it is shown instead of the icon above.'
x-builder-widget: icon
x-builder-icon-packs: [frame_demo_umami_flowbite_outline, frame_demo_umami_flowbite_solid]
size:
type: string
title: Size
enum: [s, m, l, xl]
meta:enum: { s: Small, m: Medium, l: Large, xl: 'Extra large' }
examples: [m]
color:
type: string
title: Colour
description: 'A colour of the theme. Without one the icon has the colour of the text.'
x-builder-widget: color
badge:
type: boolean
title: 'In a round badge'
description: 'A soft circle of the icon colour behind the icon.'
examples: [false]
label:
type: string
title: 'Text for screen readers'
description: 'Leave empty when the icon only decorates text next to it.'
thirdPartySettings:
frame_editor:
icon: 'bi bi-star'
features: { background: false, border: false, width: false, icon: true }
example: { type: 'frame_demo_umami:icon', props: { name: trophy, size: l, color: green, badge: true } }
libraryOverrides:
dependencies:
- frame_demo_umami/icons{#
/**
* @file
* Icon: a glyph of Bootstrap Icons. The font comes from the library frame_demo_umami/icons.
*/
#}
{# The colour is on an inner element: the root element's style belongs to the features of Frame. #}
<span {{ attributes.addClass('fd-icon', 'fd-icon--' ~ size|default('m'), badge ? 'fd-icon--badge' : null) }}
{%- if label %} role="img" aria-label="{{ label }}"{% else %} aria-hidden="true"{% endif %}>
<span class="fd-icon__glyph"{% if color %} style="--fd-icon-color: {{ color }}"{% endif %}>{% if icon %}{{ icon }}{% elseif name %}<i class="bi bi-{{ name }}"></i>{% endif %}</span>
</span>// The icon font (Bootstrap Icons), built to assets/icon.css. The library frame_demo_umami/icons attaches it on every
// page of the theme, so icons work in every component and in the icon picker of the editor.
import 'bootstrap-icons/font/bootstrap-icons.min.css';Recipe explorer
components/recipe-explorer. The recipes of the site as a slider or a grid, with filters by category and difficulty, a search and a sort that answer without a page load. React. It is the component of the video of Frame on the Umami demo.
| Prop | |
|---|---|
heading, text | above the recipes; the heading takes tokens (Cook with [site:name]) |
endpoint | the address of the JSON list: the REST display of a view. Without a leading slash it follows the language of the page (api/recipes is /es/api/recipes on a Spanish page) |
url, link_label | a link next to the heading, picked from the content of the site |
layout, per_view | a slider or a grid, with two, three or four recipes in a row |
controls | what visitors get: the filter by category, the filter by difficulty, the search, the sort |
card_style, accent, radius | the look of a card, a colour of the theme, a step of its spacing scale |
It has a slot, Extra, for components under the recipes (a button, a call to action).
The data is a view. demo/builder-demos-setup.php makes one, Recipe explorer, with a REST export display at /api/recipes (core's REST and Serialization modules) whose rows are title, url, image, category, difficulty, cooking and preparation. The filters are made from the rows: a new category on the site is a new filter. For filters, sorts and a pager that the view defines, see An interactive view.
Uses a list of choices as checkboxes (type: array with an enum), a link (format: uri-reference), a colour and a length of the theme, and three things about React in the editor:
- A slot next to the React root, not in it. Twig prints the heading,
<div class="recipe-explorer__app">and the slot as siblings, and React mounts into the__appelement only. So what is dropped into the slot stays Drupal's markup, on the page and in the editor. - It mounts in the editor although it has a slot. The editor runs no behaviors for a component with a slot (an island that replaces its children would remove the drop zone).
index.jsxalso listens toframe-editor:renderedand mounts then, and unmounts the roots whose element the editor replaced. - Its filters work in Edit mode: the toolbar and the arrows have
data-frame-editor-control(Controls that work in Edit mode). The cards do not: a click on them selects the component.
Limitations. The filters work on the rows the endpoint returns (the view limits them to 24): for hundreds of recipes, filter in the view. The rows of an address are fetched once per page load.
Tag chip and Category pill
components/tag-chip and components/category-pill. Small rounded labels, a link when they have an address. They are made for the items of a list: a Field block of tags set to Show as: Components shows every tag as a chip or a pill (Fields with many values).
| Prop | |
|---|---|
text | the name |
url | where it goes; empty for a label that is not a link |
tone, size | Tag chip: soft, solid or outline; small or medium |
color | Category pill: the colour of the dot |
Uses item: [entity_label, link, text] in the component file (what an item gives the component), a colour from the accent of the theme, CSS only.
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
name: Tag chip
status: experimental
description: 'A rounded chip for a tag or a category, a link when it has an address. Made for the items of a list.'
group: Content
help: |
Use it as the item component of a field with many values (tags, categories): in the settings of the Field block choose Show as: Components, then Tag chip. Every value becomes a chip, in a Flex wrapper that wraps onto more lines.
Switch on Link items to make each chip go to its term. The colour variants are Soft (tinted), Solid and Outline.
props:
type: object
properties:
text:
type: string
title: Text
description: 'The name of the tag.'
examples: ['Vegetarian']
url:
type: string
title: Link
format: uri-reference
description: 'Where the chip goes. Leave empty for a chip that is not a link.'
tone:
type: string
title: Colour
enum: [soft, solid, outline]
meta:enum: { soft: Soft, solid: Solid, outline: Outline }
examples: [soft]
size:
type: string
title: Size
enum: [s, m]
meta:enum: { s: Small, m: Medium }
examples: [m]
required: [text]
thirdPartySettings:
frame_editor:
# The look: the enum prop is the Variant of the editor, and the template maps it with html_cva().
variant_prop: tone
# Inline content: it can sit on the baseline, the middle or the top of the line (Text, Vertical alignment).
features: { vertical_align: true }
icon: tooltip
provides: [text]
item: [entity_label, link, text]
example: { type: 'frame_demo_umami:tag-chip', props: { text: 'Vegetarian', tone: soft, size: m } }{#
/**
* @file
* Tag chip: a rounded label, a link when it has a `url`.
*/
#}
{% set tag = url ? 'a' : 'span' %}
{% set cva = html_cva('tag-chip', {
tone: {
soft: 'tag-chip--soft',
solid: 'tag-chip--solid',
outline: 'tag-chip--outline',
},
size: {
s: 'tag-chip--s',
m: 'tag-chip--m',
},
}, [], {tone: 'soft', size: 'm'}) %}
<{{ tag }} {{ attributes.addClass(cva.apply({tone: tone|default(null), size: size|default(null)}|filter(v => v is not null))) }}{% if url %} href="{{ url }}"{% endif %}>{{ text }}</{{ tag }}>/* Tag chip. The colours come from the accent of the theme. */
.tag-chip { --chip-accent: var(--frame-accent, #008068); display: inline-block; padding: 0.3em 0.85em; border: 1px solid transparent; border-radius: 999px; background: color-mix(in srgb, var(--chip-accent) 14%, transparent); color: color-mix(in srgb, var(--chip-accent) 80%, #000); font-size: 0.875rem; font-weight: 600; line-height: 1.3; text-decoration: none; white-space: nowrap; }
.tag-chip--s { padding: 0.15em 0.65em; font-size: 0.75rem; }
.tag-chip--solid { background: var(--chip-accent); color: var(--frame-accent-contrast, #fff); }
.tag-chip--outline { border-color: var(--chip-accent); background: transparent; }
a.tag-chip { transition: background-color 0.15s, color 0.15s; }
a.tag-chip:is(:hover, :focus-visible) { background: var(--chip-accent); color: var(--frame-accent-contrast, #fff); }
a.tag-chip:focus-visible { outline: 3px solid color-mix(in srgb, var(--chip-accent) 40%, transparent); outline-offset: 2px; }