You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
3.9 KiB
157 lines
3.9 KiB
import type { Morfo } from '../types';
|
|
import { v } from '../types';
|
|
|
|
export const feedMorfo = {
|
|
name: 'Feed',
|
|
kebab: 'feed',
|
|
scope: ['soma', 'sema'],
|
|
expression: "family-default",
|
|
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/feed/',
|
|
texts: {
|
|
label: '#?components.feed.label|Feed'
|
|
},
|
|
events: [
|
|
{
|
|
// User asked for more items (infinite scroll trigger / load-more
|
|
// button). Soma owns whether/when to actually fetch. Per book
|
|
// cap. 23 `commit.submit` — user submitted their request. The
|
|
// actual fetch is downstream (sustain.processing →
|
|
// commit.complete + affirm or commit.fail + risk).
|
|
name: 'commit-submit-load-more',
|
|
semantic: {
|
|
family: 'commit',
|
|
verb: 'submit',
|
|
target: v.partRef('provider'),
|
|
intent: 'neutral',
|
|
sequence: 'post'
|
|
}
|
|
},
|
|
{
|
|
// Item focused via keyboard navigation (j/k or Arrow keys).
|
|
// Per book cap. 27 §5 `shift.navigate`.
|
|
name: 'shift-navigate-focus-item',
|
|
semantic: {
|
|
family: 'shift',
|
|
verb: 'navigate',
|
|
target: v.partRef('article'),
|
|
sequence: 'post'
|
|
}
|
|
}
|
|
],
|
|
parts: [
|
|
{
|
|
name: 'Provider',
|
|
kebab: 'provider',
|
|
archetype: 'provider',
|
|
kind: 'public',
|
|
defaultElement: 'section',
|
|
role: 'feed',
|
|
optional: false,
|
|
data: [{ attr: 'data-busy', value: v.propRef('busy'), severity: 'optional' }],
|
|
aria: [
|
|
{
|
|
attr: 'aria-label',
|
|
value: v.propRef('ariaLabel'),
|
|
severity: 'recommended'
|
|
},
|
|
{
|
|
attr: 'aria-labelledby',
|
|
value: v.propRef('ariaLabelledby'),
|
|
condition: { when: 'prop-truthy', prop: 'ariaLabelledby' },
|
|
severity: 'optional'
|
|
},
|
|
{
|
|
attr: 'aria-busy',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'busy' }
|
|
}
|
|
],
|
|
keyboard: [
|
|
{ key: 'PageDown', action: 'next-item' },
|
|
{ key: 'PageUp', action: 'prev-item' },
|
|
{ key: 'Ctrl+Home', action: 'first-item' },
|
|
{ key: 'Ctrl+End', action: 'last-item' }
|
|
]
|
|
},
|
|
{
|
|
name: 'Article',
|
|
kebab: 'article',
|
|
archetype: 'item',
|
|
kind: 'public',
|
|
defaultElement: 'article',
|
|
role: 'article',
|
|
optional: false,
|
|
data: [
|
|
{ attr: 'data-posinset', value: v.propRef('posinset'), emit: 'value' },
|
|
{ attr: 'data-level', value: v.propRef('level'), emit: 'value' }
|
|
],
|
|
aria: [
|
|
{ attr: 'aria-posinset', value: v.propRef('posinset') },
|
|
{ attr: 'aria-setsize', value: v.propRef('setsize') },
|
|
{
|
|
attr: 'aria-labelledby',
|
|
value: v.partRef('article-title'),
|
|
condition: { when: 'part-present', part: 'article-title' },
|
|
severity: 'recommended'
|
|
},
|
|
{
|
|
attr: 'aria-describedby',
|
|
value: v.partRef('article-description'),
|
|
condition: { when: 'part-present', part: 'article-description' },
|
|
severity: 'optional'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'ArticleTitle',
|
|
kebab: 'article-title',
|
|
archetype: 'title',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
role: 'heading',
|
|
optional: true,
|
|
data: [],
|
|
aria: [{ attr: 'aria-level', value: v.propRef('level') }]
|
|
},
|
|
{
|
|
name: 'ArticleDescription',
|
|
kebab: 'article-description',
|
|
archetype: 'description',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: true,
|
|
data: [],
|
|
aria: []
|
|
},
|
|
{
|
|
name: 'Thread',
|
|
kebab: 'thread',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
role: 'feed',
|
|
optional: true,
|
|
data: [{ attr: 'data-level', value: v.propRef('level'), emit: 'value' }],
|
|
aria: [
|
|
{
|
|
attr: 'aria-labelledby',
|
|
value: v.partRef('article-title'),
|
|
condition: { when: 'part-present', part: 'article-title' },
|
|
severity: 'optional'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'Sentinel',
|
|
kebab: 'sentinel',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: true,
|
|
data: [
|
|
{ attr: 'data-intersecting', value: v.propRef('intersecting'), severity: 'optional' }
|
|
],
|
|
aria: [{ attr: 'aria-hidden', value: v.literal('true') }]
|
|
}
|
|
]
|
|
} as const satisfies Morfo;
|