feat: lay our own pages out as interface rather than as articles
This commit is contained in:
parent
e7a8e91334
commit
dfba1cfb16
8 changed files with 162 additions and 55 deletions
|
|
@ -9,7 +9,7 @@ import 'mews_urls.dart';
|
|||
|
||||
/// Separates independent labels on one line. A separator is layout, so it is a
|
||||
/// constant here rather than a message.
|
||||
const actionSeparator = ' ';
|
||||
const actionSeparator = ' · ';
|
||||
|
||||
/// A link with its label: a choice in a group, or an action on a row. For an
|
||||
/// action [current] is always false.
|
||||
|
|
@ -59,10 +59,9 @@ List<MewsBlock> chrome({
|
|||
];
|
||||
}
|
||||
|
||||
/// One row in a list: the item, then an optional note on its own line. A date
|
||||
/// goes inside the link, the way a Mews page writes its own dated links (spec
|
||||
/// 6.1), so the whole row is one target. One paragraph per row keeps rows
|
||||
/// close together, since each paragraph carries its own bottom padding.
|
||||
/// One row in a list: the item as a link, then its note and date on a second,
|
||||
/// quieter line, then its chips and actions. One paragraph per row keeps the
|
||||
/// lines together, since each paragraph carries its own bottom padding.
|
||||
MewsListItem itemRow({
|
||||
required String href,
|
||||
required String label,
|
||||
|
|
@ -72,23 +71,28 @@ MewsListItem itemRow({
|
|||
List<Choice> chips = const [],
|
||||
List<Choice> actions = const [],
|
||||
}) {
|
||||
final text = date == null ? label : '$date $label';
|
||||
final meta = [?note, ?date];
|
||||
return MewsListItem([
|
||||
ParagraphBlock([
|
||||
MewsLink(href, [
|
||||
if (strong)
|
||||
MewsEmphasis(EmphasisStyle.strong, [MewsText(text)])
|
||||
MewsEmphasis(EmphasisStyle.strong, [MewsText(label)])
|
||||
else
|
||||
MewsText(text),
|
||||
MewsText(label),
|
||||
]),
|
||||
if (note != null) ...[
|
||||
if (meta.isNotEmpty) ...[
|
||||
const MewsLineBreak(),
|
||||
MewsEmphasis(EmphasisStyle.emphasis, [MewsText(note)]),
|
||||
MewsEmphasis(
|
||||
EmphasisStyle.emphasis, [MewsText(meta.join(actionSeparator))]),
|
||||
],
|
||||
if (chips.isNotEmpty) ...[
|
||||
const MewsLineBreak(),
|
||||
..._separated(
|
||||
[for (final chip in chips) MewsLink(chip.href, [MewsText(chip.label)])]),
|
||||
// A leading hash tells a tag apart from the actions beside it, which
|
||||
// links alone give no way to distinguish.
|
||||
..._separated([
|
||||
for (final chip in chips)
|
||||
MewsLink(chip.href, [MewsText('#${chip.label}')]),
|
||||
]),
|
||||
],
|
||||
if (actions.isNotEmpty) ...[
|
||||
const MewsLineBreak(),
|
||||
|
|
@ -175,6 +179,16 @@ FormBlock textForm({
|
|||
);
|
||||
}
|
||||
|
||||
/// A line of links with the separator between them, never trailing. Returns
|
||||
/// nothing when there is no link to show, so a page never holds an empty line.
|
||||
List<MewsBlock> linkLine(List<Choice> links) {
|
||||
if (links.isEmpty) return const [];
|
||||
return [
|
||||
ParagraphBlock(_separated(
|
||||
[for (final link in links) MewsLink(link.href, [MewsText(link.label)])])),
|
||||
];
|
||||
}
|
||||
|
||||
/// A plain list of links, used for menus and library lists alike.
|
||||
ListBlock itemList(List<MewsListItem> items) =>
|
||||
ListBlock(ordered: false, start: 1, items: items);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue