| 196 |
196 |
|
pub mod form;
|
| 197 |
197 |
|
pub mod list;
|
| 198 |
198 |
|
|
|
199 |
+ |
use crate::list::part_class;
|
| 199 |
200 |
|
use makeover_geometry::{Density, SizeClass};
|
| 200 |
201 |
|
// Re-exported rather than redefined. An app assembling its own stylesheet out
|
| 201 |
202 |
|
// of this crate's pieces needs the same layer name, and most such apps depend
|
| 649 |
650 |
|
css
|
| 650 |
651 |
|
}
|
| 651 |
652 |
|
|
| 652 |
|
- |
/// The four parts of a list row.
|
|
653 |
+ |
/// The parts of a list row.
|
|
654 |
+ |
///
|
|
655 |
+ |
/// The list is written out rather than derived because `RowPart` is
|
|
656 |
+ |
/// `#[non_exhaustive]` as of makeover-layout 0.9.0, so there is nothing to
|
|
657 |
+ |
/// iterate. A member added upstream emits no rule until it is named here, which
|
|
658 |
+ |
/// is the trade `non_exhaustive` makes: a silent gap instead of a build break.
|
|
659 |
+ |
/// [`part_class`] carries the same list and the same obligation.
|
| 653 |
660 |
|
fn row_rules(opts: &Emit) -> String {
|
| 654 |
661 |
|
let mut css = String::new();
|
| 655 |
662 |
|
let row = class("row", opts);
|
| 658 |
665 |
|
RowPart::Secondary,
|
| 659 |
666 |
|
RowPart::Meta,
|
| 660 |
667 |
|
RowPart::Actions,
|
|
668 |
+ |
RowPart::Tokens,
|
| 661 |
669 |
|
] {
|
| 662 |
|
- |
let name = match part {
|
| 663 |
|
- |
RowPart::Primary => "row-primary",
|
| 664 |
|
- |
RowPart::Secondary => "row-secondary",
|
| 665 |
|
- |
RowPart::Meta => "row-meta",
|
| 666 |
|
- |
RowPart::Actions => "row-actions",
|
| 667 |
|
- |
};
|
| 668 |
|
- |
let c = class(name, opts);
|
|
670 |
+ |
let c = class(part_class(part), opts);
|
| 669 |
671 |
|
|
| 670 |
672 |
|
// Actions carry controls rather than text, and `RowPart::intent` says
|
| 671 |
673 |
|
// so by returning the same intent inheriting already gives. Pinning it
|
| 672 |
|
- |
// would be louder than saying nothing.
|
| 673 |
|
- |
if !matches!(part, RowPart::Actions) {
|
|
674 |
+ |
// would be louder than saying nothing. Tokens answer alike, for their
|
|
675 |
+ |
// own reason: each token carries its own tone, and a colour on the
|
|
676 |
+ |
// strip would fight the things sitting in it.
|
|
677 |
+ |
if !matches!(part, RowPart::Actions | RowPart::Tokens) {
|
| 674 |
678 |
|
let _ = writeln!(css, ".{c} {{\n color: var(--{});\n}}", part.intent());
|
| 675 |
679 |
|
}
|
| 676 |
680 |
|
|
| 1272 |
1276 |
|
assert!(!css.contains(".row-actions {\n color:"));
|
| 1273 |
1277 |
|
}
|
| 1274 |
1278 |
|
|
|
1279 |
+ |
#[test]
|
|
1280 |
+ |
fn the_token_strip_takes_no_colour_of_its_own() {
|
|
1281 |
+ |
// makeover-layout 0.9.0. A token carries its own tone, so a colour on
|
|
1282 |
+ |
// the strip would be a rule fighting the things sitting in it -- the
|
|
1283 |
+ |
// same reasoning as actions, reached for a different reason.
|
|
1284 |
+ |
let css = row_rules(&Emit::default());
|
|
1285 |
+ |
assert!(!css.contains(".row-tokens {\n color:"));
|
|
1286 |
+ |
}
|
|
1287 |
+ |
|
|
1288 |
+ |
#[test]
|
|
1289 |
+ |
fn an_unknown_row_part_renders_plainly_rather_than_failing_to_build() {
|
|
1290 |
+ |
// What `#[non_exhaustive]` bought and what it cost. `part_class` can no
|
|
1291 |
+ |
// longer be exhaustive, so a member added upstream lands as a bare
|
|
1292 |
+ |
// class with no rule instead of stopping the build. Asserting the
|
|
1293 |
+ |
// fallback exists is what keeps it from being written as `unreachable!`
|
|
1294 |
+ |
// by someone who reads the match as closed.
|
|
1295 |
+ |
assert_eq!(part_class(RowPart::Tokens), "row-tokens");
|
|
1296 |
+ |
assert_eq!(part_class(RowPart::Meta), "row-meta");
|
|
1297 |
+ |
}
|
|
1298 |
+ |
|
| 1275 |
1299 |
|
#[test]
|
| 1276 |
1300 |
|
fn the_progress_trough_is_a_well() {
|
| 1277 |
1301 |
|
let css = progress_rules(&Emit::default());
|