TableProperties and the NumberField story use form rows

Both were plain field rows in the old gallery and in DesignCraft's table
panel: number fields keep their number length instead of filling an
inspector column.
This commit is contained in:
aiongg
2026-11-12 14:32:52 +00:00
parent b47165073c
commit fbab72ae31
2 changed files with 4 additions and 5 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
use craft_behavior::{Mixed, Value};
use craft_ui::buttons::Button;
use craft_ui::choice::Checkbox;
use craft_ui::contract::{Bind, Entry, LabelScheme, NoValue, Outcome, Props as _, Show as _, ShowContainer as _, clicked};
use craft_ui::contract::{Bind, Entry, NoValue, Outcome, Props as _, Show as _, ShowContainer as _, clicked};
use craft_ui::form::{Field, FieldGroup};
use craft_ui::pickers::Select;
use craft_ui::runtime::env::{Env, Label, UnitKind};
@@ -231,7 +231,7 @@ impl<'a> TableProperties<'a> {
let words = Env::of(ui).words::<TablePropertiesWords>();
let (v, unit) = (self.values, self.unit);
let mut change = None;
let shown = FieldGroup::new(words.table.clone()).labels(LabelScheme::Inspector).show(ui, |ui, _| {
let shown = FieldGroup::new(words.table.clone()).show(ui, |ui, _| {
let mut set = |next: Option<TableChange>| change = change.take().or(next);
set(count(ui, &words.rows, v.rows, 1, TableChange::Rows));
set(count(ui, &words.columns, v.columns, 1, TableChange::Columns));
+2 -3
View File
@@ -1,7 +1,6 @@
//! Stories of `NumberField`.
use super::{NumberField, NumberPick};
use crate::contract::LabelScheme;
use crate::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _, Validity};
use crate::form::{Field, FieldGroup};
use crate::runtime::env::{Env, Message, UnitKind};
@@ -18,7 +17,7 @@ const RANGE: std::ops::RangeInclusive<f64> = 0.0..=100.0;
/// The range of the Invalid rows: the value 7 lies inside it.
const COLUMNS: std::ops::RangeInclusive<f64> = 1.0..=12.0;
/// A row of the states story, in the group's inspector rows.
/// A row of the states story, in the group's form rows.
fn row(label: &'static str) -> Field {
Field::new(label).id_salt(label)
}
@@ -44,7 +43,7 @@ fn refuse_all(_: &Option<f64>) -> Validity<Option<f64>> {
fn number_field(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let size = *data.choice("control_size", ControlSize::Md, &[("Sm", ControlSize::Sm), ("Md", ControlSize::Md)]);
let units = Env::of(ui).view().units();
let out = FieldGroup::new("Number field states").labels(LabelScheme::Inspector).show(ui, |ui, _| {
let out = FieldGroup::new("Number field states").show(ui, |ui, _| {
let first = row("Plain").show(ui, |ui, _| NumberField::new("Plain", Bind::bound(data.value("plain", Some(42.0)))).size(size).show(ui).edit);
row("With unit").show(ui, |ui, _| {
NumberField::new("Gap", Bind::bound(data.value("gap", Some(SIZE))))