| 159 |
159 |
|
//! the same magnitude with its sign off the depth. Both values are the measured
|
| 160 |
160 |
|
//! consensus rather than a new opinion.
|
| 161 |
161 |
|
//!
|
|
162 |
+ |
//! # 0.25.0: a cell says what it holds
|
|
163 |
+ |
//!
|
|
164 |
+ |
//! 0.23.0 gave a table its layout and left every cell the same. One `.cell`
|
|
165 |
+ |
//! carried the whole thing, so a cell holding text and a cell holding a button
|
|
166 |
+ |
//! were one class and one content colour, and a control in a cell was painted
|
|
167 |
+ |
//! as text. That is the drift [`RowPart::intent`](makeover_layout::RowPart)
|
|
168 |
+ |
//! has prevented for list rows since 0.2.0 and prevented for nothing here.
|
|
169 |
+ |
//!
|
|
170 |
+ |
//! makeover-layout 0.14.0's [`CellPart`](makeover_layout::CellPart) names the
|
|
171 |
+ |
//! four things a cell holds, and [`table_rules`] turns them into
|
|
172 |
+ |
//! `.cell-value`, `.cell-tokens`, `.cell-actions` and `.cell-link`. Only the
|
|
173 |
+ |
//! first takes a colour: a token carries its own tone, an action is a control
|
|
174 |
+ |
//! rather than text, and a link takes the action colour from the anchor it is.
|
|
175 |
+ |
//!
|
|
176 |
+ |
//! The colour going on `.cell-value` rather than on `.cell` is the fix rather
|
|
177 |
+ |
//! than an implementation detail. On the container it cascades into the parts
|
|
178 |
+ |
//! that are not text, which is the bug said in one rule.
|
|
179 |
+ |
//!
|
|
180 |
+ |
//! [`list::Cell::part`] is `Option<CellPart>` here, where it was
|
|
181 |
+ |
//! `Option<RowPart>`. A table cell borrowing the list row's vocabulary was the
|
|
182 |
+ |
//! drift with a type on it: the two answer different questions, and only one of
|
|
183 |
+ |
//! them was ever about a cell.
|
|
184 |
+ |
//!
|
| 162 |
185 |
|
//! # 0.23.0: a table lays itself out, and a row shows its controls
|
| 163 |
186 |
|
//!
|
| 164 |
187 |
|
//! Three things a description could say and this renderer had no rule for,
|
| 237 |
260 |
|
pub mod meter;
|
| 238 |
261 |
|
pub mod placeholder;
|
| 239 |
262 |
|
|
| 240 |
|
- |
use crate::list::part_class;
|
|
263 |
+ |
use crate::list::{cell_part_class, part_class};
|
| 241 |
264 |
|
use makeover_geometry::{Density, SizeClass};
|
| 242 |
265 |
|
// Re-exported rather than redefined. An app assembling its own stylesheet out
|
| 243 |
266 |
|
// of this crate's pieces needs the same layer name, and most such apps depend
|
| 245 |
268 |
|
// `tables.css` in its own build.rs from [`list::narrowing_css`], and those
|
| 246 |
269 |
|
// rules are as generated as the ones here.
|
| 247 |
270 |
|
pub use makeover_geometry::{CSS_LAYER, in_css_layer};
|
| 248 |
|
- |
use makeover_layout::{Bevel, Depth, Fill, Intent, RowPart, Selector, State, Token, Tone};
|
|
271 |
+ |
use makeover_layout::{
|
|
272 |
+ |
Bevel, CellPart, Depth, Fill, Intent, RowPart, Selector, State, Token, Tone,
|
|
273 |
+ |
};
|
| 249 |
274 |
|
use makeover_touch::Affordance;
|
| 250 |
275 |
|
use std::fmt::Write as _;
|
| 251 |
276 |
|
|
| 1027 |
1052 |
|
));
|
| 1028 |
1053 |
|
}
|
| 1029 |
1054 |
|
|
|
1055 |
+ |
// What is inside a cell, which the table side could not say until
|
|
1056 |
+ |
// makeover-layout 0.14.0. Every cell was one `.cell` and one content
|
|
1057 |
+ |
// colour, so a button in a cell was painted as text -- the drift
|
|
1058 |
+ |
// `RowPart::intent` has prevented for list rows since 0.2.0 and prevented
|
|
1059 |
+ |
// for nothing here.
|
|
1060 |
+ |
//
|
|
1061 |
+ |
// The colour goes on `.cell-value` rather than on `.cell`, and that
|
|
1062 |
+ |
// placement is the whole fix. On the container it would cascade into the
|
|
1063 |
+ |
// tokens and the controls sitting beside the text, which is the bug said
|
|
1064 |
+ |
// in one rule; on the part that is text, it reaches text and stops.
|
|
1065 |
+ |
for part in [
|
|
1066 |
+ |
CellPart::Value,
|
|
1067 |
+ |
CellPart::Tokens,
|
|
1068 |
+ |
CellPart::Actions,
|
|
1069 |
+ |
CellPart::Link,
|
|
1070 |
+ |
] {
|
|
1071 |
+ |
// Three of the four inherit, each for its own reason: a token carries
|
|
1072 |
+ |
// its own tone, an action is a control rather than text, and a link
|
|
1073 |
+ |
// takes the action colour from the anchor it is. `CellPart::intent`
|
|
1074 |
+ |
// says so by answering with the intent inheriting already gives, and
|
|
1075 |
+ |
// pinning that would be louder than saying nothing.
|
|
1076 |
+ |
//
|
|
1077 |
+ |
// Written as a skip-list rather than as a match on Value, so a member
|
|
1078 |
+ |
// added upstream gets its intent emitted rather than being silently
|
|
1079 |
+ |
// dropped. That is the same trade `part_class`'s fallback makes: land
|
|
1080 |
+ |
// plainly, never land as nothing.
|
|
1081 |
+ |
if !matches!(part, CellPart::Tokens | CellPart::Actions | CellPart::Link) {
|
|
1082 |
+ |
let _ = writeln!(
|
|
1083 |
+ |
css,
|
|
1084 |
+ |
".{} {{\n color: var(--{});\n}}",
|
|
1085 |
+ |
class(cell_part_class(part), opts),
|
|
1086 |
+ |
part.intent()
|
|
1087 |
+ |
);
|
|
1088 |
+ |
}
|
|
1089 |
+ |
}
|
|
1090 |
+ |
|
| 1030 |
1091 |
|
css
|
| 1031 |
1092 |
|
}
|
| 1032 |
1093 |
|
|
| 1710 |
1771 |
|
assert!(!css.contains("grid-template-columns"), "{css}");
|
| 1711 |
1772 |
|
}
|
| 1712 |
1773 |
|
|
|
1774 |
+ |
#[test]
|
|
1775 |
+ |
fn a_control_in_a_cell_is_not_painted_as_text() {
|
|
1776 |
+ |
// The point of makeover-layout 0.14.0's CellPart, and the table-side
|
|
1777 |
+ |
// twin of `the_three_text_parts_take_their_intents_and_actions_inherits`
|
|
1778 |
+ |
// above. One `.cell` and one content colour meant a button in a cell
|
|
1779 |
+ |
// inherited it.
|
|
1780 |
+ |
let css = table_rules(&Emit::default());
|
|
1781 |
+ |
|
|
1782 |
+ |
assert!(
|
|
1783 |
+ |
css.contains(".cell-value {\n color: var(--content);"),
|
|
1784 |
+ |
"{css}"
|
|
1785 |
+ |
);
|
|
1786 |
+ |
assert!(!css.contains(".cell-actions {\n color:"), "{css}");
|
|
1787 |
+ |
assert!(!css.contains(".cell-tokens {\n color:"), "{css}");
|
|
1788 |
+ |
assert!(!css.contains(".cell-link {\n color:"), "{css}");
|
|
1789 |
+ |
|
|
1790 |
+ |
// The colour is on the part that is text, never on the container. On
|
|
1791 |
+ |
// `.cell` it would cascade into the three parts that are not text,
|
|
1792 |
+ |
// which is the bug written as one rule.
|
|
1793 |
+ |
assert!(!css.contains(".cell {\n color:"), "{css}");
|
|
1794 |
+ |
}
|
|
1795 |
+ |
|
|
1796 |
+ |
#[test]
|
|
1797 |
+ |
fn an_unknown_cell_part_renders_plainly_rather_than_failing_to_build() {
|
|
1798 |
+ |
// `part_class`'s obligation, taken on for the table side too. CellPart
|
|
1799 |
+ |
// is `#[non_exhaustive]`, so a member added upstream must land as a
|
|
1800 |
+ |
// bare class rather than as a build that stops.
|
|
1801 |
+ |
assert_eq!(cell_part_class(CellPart::Value), "cell-value");
|
|
1802 |
+ |
assert_eq!(cell_part_class(CellPart::Actions), "cell-actions");
|
|
1803 |
+ |
}
|
|
1804 |
+ |
|
| 1713 |
1805 |
|
#[test]
|
| 1714 |
1806 |
|
fn a_column_drops_by_its_priority_and_never_by_its_position() {
|
| 1715 |
1807 |
|
let css = component_rules(&Emit::default());
|