| 290 |
290 |
|
// rules are as generated as the ones here.
|
| 291 |
291 |
|
pub use makeover_geometry::{CSS_LAYER, in_css_layer};
|
| 292 |
292 |
|
use makeover_layout::{
|
| 293 |
|
- |
Bevel, CellPart, Depth, Fill, Intent, RowPart, Selector, Sort, State, Token, Tone,
|
|
293 |
+ |
Bevel, CellPart, Depth, Fill, Flow, Intent, RowPart, Selector, Sort, State, Token, Tone,
|
| 294 |
294 |
|
};
|
| 295 |
295 |
|
use makeover_touch::Affordance;
|
| 296 |
296 |
|
use std::fmt::Write as _;
|
| 953 |
953 |
|
// until pointed at. A table cell's actions were never hidden, so the
|
| 954 |
954 |
|
// two arrangements now agree.
|
| 955 |
955 |
|
}
|
|
956 |
+ |
|
|
957 |
+ |
// A part that may take two lines. `Flow::Tight` gets no rule: one line is
|
|
958 |
+ |
// what a run already does, and restating it here would put a declaration on
|
|
959 |
+ |
// every part in every row to say nothing.
|
|
960 |
+ |
//
|
|
961 |
+ |
// This is the shape both webview apps had already written by hand and
|
|
962 |
+ |
// commented -- Balanced Breakfast on a feed row's title, goingson on a
|
|
963 |
+ |
// problem's body -- which is the whole argument for the description
|
|
964 |
+ |
// carrying it. `-webkit-` prefixed and unprefixed together: the prefixed
|
|
965 |
+ |
// trio is what every engine actually implements, and `line-clamp` is the
|
|
966 |
+ |
// standard property landing behind it.
|
|
967 |
+ |
let _ = writeln!(
|
|
968 |
+ |
css,
|
|
969 |
+ |
".{} {{\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: {lines};\n line-clamp: {lines};\n overflow: hidden;\n}}",
|
|
970 |
+ |
class("row-relaxed", opts),
|
|
971 |
+ |
lines = Flow::Relaxed.lines()
|
|
972 |
+ |
);
|
|
973 |
+ |
|
| 956 |
974 |
|
css
|
| 957 |
975 |
|
}
|
| 958 |
976 |
|
|
| 2309 |
2327 |
|
}
|
| 2310 |
2328 |
|
}
|
| 2311 |
2329 |
|
|
|
2330 |
+ |
#[test]
|
|
2331 |
+ |
fn a_relaxed_part_clamps_and_a_tight_one_says_nothing() {
|
|
2332 |
+ |
let css = stylesheet(&Emit::default());
|
|
2333 |
+ |
assert!(css.contains(".row-relaxed {"));
|
|
2334 |
+ |
assert!(css.contains("-webkit-line-clamp: 2;"));
|
|
2335 |
+ |
// The count is `Flow`'s, not this crate's. If the tier ever means three
|
|
2336 |
+ |
// lines, this fails here rather than in an app.
|
|
2337 |
+ |
assert!(css.contains(&format!("line-clamp: {};", Flow::Relaxed.lines())));
|
|
2338 |
+ |
// Tight gets no rule at all: one line is what a run already does, and a
|
|
2339 |
+ |
// class per part saying so is a declaration that changes nothing.
|
|
2340 |
+ |
assert!(!css.contains("row-tight"));
|
|
2341 |
+ |
assert_eq!(crate::list::flow_class(Flow::Relaxed), Some("row-relaxed"));
|
|
2342 |
+ |
assert_eq!(crate::list::flow_class(Flow::Tight), None);
|
|
2343 |
+ |
// Emitted, therefore checkable: an app's dead-vocabulary seal and the
|
|
2344 |
+ |
// overlap check both read `vocabulary::names`, so a class the renderer
|
|
2345 |
+ |
// can write and that list does not carry is invisible to both.
|
|
2346 |
+ |
assert!(crate::vocabulary::names(&Emit::default()).contains("row-relaxed"));
|
|
2347 |
+ |
}
|
|
2348 |
+ |
|
| 2312 |
2349 |
|
#[test]
|
| 2313 |
2350 |
|
fn the_whole_sheet_still_names_every_colour() {
|
| 2314 |
2351 |
|
// The crate's founding property, asserted over the component layer and
|
| 2424 |
2461 |
|
| "block"
|
| 2425 |
2462 |
|
| "cover"
|
| 2426 |
2463 |
|
| "contain"
|
|
2464 |
+ |
// A relaxed part's three, and the third is the
|
|
2465 |
+ |
// awkward one. `-webkit-box` and `vertical` are
|
|
2466 |
+ |
// structure: they say the part is a box of lines
|
|
2467 |
+ |
// stacked downward, which is the only way CSS lets
|
|
2468 |
+ |
// anyone ask for a clamp at all.
|
|
2469 |
+ |
//
|
|
2470 |
+ |
// `2` is a count of lines, not a length. The
|
|
2471 |
+ |
// distinction this crate holds is between naming a
|
|
2472 |
+ |
// magnitude -- a padding, a height, a font size,
|
|
2473 |
+ |
// all of which belong to makeover-geometry -- and
|
|
2474 |
+ |
// naming how many of something there are. A line's
|
|
2475 |
+ |
// height is still the app's, so two lines is
|
|
2476 |
+ |
// whatever two of the app's lines come to, and
|
|
2477 |
+ |
// nothing here decides how tall that is. It is also
|
|
2478 |
+ |
// not a value picked here: it is `Flow::Relaxed`'s
|
|
2479 |
+ |
// own answer arriving unchanged, the same way
|
|
2480 |
+ |
// `cover` and `contain` are `Fit`'s.
|
|
2481 |
+ |
| "-webkit-box"
|
|
2482 |
+ |
| "vertical"
|
|
2483 |
+ |
| "2"
|
| 2427 |
2484 |
|
),
|
| 2428 |
2485 |
|
"unrecognised literal value: {line}"
|
| 2429 |
2486 |
|
);
|