Repository navigation
rune-kit: Kit::metrics for Button/Switch sizes, field box, TextArea type and Checkbox colours - #2172
Merged
Merged
Conversation
…ype and Checkbox colours
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #573 (the five components in the issue body).
What changed
Kit::metrics: rune_kit::Metrics, defined incrates/rune-kit/src/tokens/metrics.rs. Every entry isNoneby default, andNonekeeps today's built-in values, which still followk.radius/k.ty/k.cwhen the control is built.button: Option<BySize<ButtonMetrics>>: pushButtonheight, horizontal padding, radius and icon perControlSize. Replaces the privatepush_metrics; the deprecatedButtonSizesizes keep their own metrics.switch: Option<BySize<SwitchMetrics>>: compactSwitchtrack and knob sizes and inset per size. The built-in table isSwitchMetrics::NS_SWITCH. The web and standard looks are unchanged.field: Option<FieldMetrics>:TextInputheight and large height, horizontal padding (the leading spacer, leading-icon inset, right padding and clear-button margin all follow it; with no leading icon the text starts at least 6 pt in, because of the existing 6 pt gap), and the shared shell's radius and focus/invalid outline.focus_offsetis measured outward from the box edge asEl::outlinetakes it:-focus_widthkeeps the ring just inside, 0 or more draws a halo outside.TextAreatakes the radius and outline.text_area: Option<TextAreaMetrics>:TextAreatext style and padding. The minimum and max-height calculations use the padding.checkbox: Option<CheckboxColors>: checked/mixed fill, border and mark. Custom colours also stay under the pointer, withc.hoveroverlaid.ButtonMetrics::kit,SwitchMetrics::NS_SWITCH,FieldMetrics::kit,TextAreaMetrics::kitandCheckboxColors::kitreturn today's values.Kit::neutralandthemes/opencodesetmetrics: Metrics::default(). Apps that buildKitas a struct literal must add that field too; the changelog entry says so.changelog/unreleased/2026-11-25-kit-metrics.md.Not covered: the extra components from the issue comments (Menu/Select/Dialog/Toast/SegmentedControl radii, Keybind caps,
IconButtonhit target).Testing
crates/rune-kit/tests/integration/kit_metrics.rs:rows * line + 2 * padding), against 80 by default;crates/rune-kit/src/controls/checkbox_tests.rs: custom checked fill, border and mark at rest;State::Hoverkeepsover(c.hover, fill)rather thansurface_hover; unchecked boxes and kits without custom colours look as before.cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaidandcargo check --workspace --all-targetsstill need to run in CI or locally.scripts/file-size.sh(no errors) and the public-repo hygiene grep on the diff (no matches).Closes #573