From eaba067d8cf3fa42706d4bb3f0ee4a80a7850f1e Mon Sep 17 00:00:00 2001 From: Waozi Date: Mon, 23 Nov 2026 04:31:45 -0300 Subject: [PATCH] Name the native form for percentage radii, box-shadow through var() and pseudo-elements From the trial's lower-frequency items: border-radius: 50% says that 999px rounds a pill (Kryon clamps a radius to half the shorter side), a box-shadow written through var() says what native box-shadow takes, and a pseudo-element says to draw the part as its own widget. --- CHANGELOG.md | 2 +- src/parser/properties.zi | 16 +++++++++++++++- src/parser/selectors.zi | 2 +- tests/css_parse_behavior.zi | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcdeae9..a0276ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- HTML type selectors that are one Kryon widget match it natively: `a` (Link), `p` (ParagraphText), `button`, `input` (TextField), `textarea` (TextArea), `select` (Dropdown), `img` (Image) and `body` (App). Headings, tables, `label` and plain containers fail with the native form (`h2`: every heading level is Heading, give each level a class). Declarations only the browser applies, and common web properties Kryon has no native form of (`position` and its offsets, `backdrop-filter`, named grid areas, `box-sizing`, `aspect-ratio`, `object-fit`, `overflow-x`/`-y`, `place-items`, `appearance`, `float`), now say what native Kryon does instead: `z-index`, `cursor`, `display: none` and `inline-*`, unequal grid tracks, and sizes in `min()` with a percentage among them. `css_tool check` exits with status 1 when it skipped anything natively, and stays at 0 for browser-only declarations alone. +- HTML type selectors that are one Kryon widget match it natively: `a` (Link), `p` (ParagraphText), `button`, `input` (TextField), `textarea` (TextArea), `select` (Dropdown), `img` (Image) and `body` (App). Headings, tables, `label` and plain containers fail with the native form (`h2`: every heading level is Heading, give each level a class). Declarations only the browser applies, and common web properties Kryon has no native form of (`position` and its offsets, `backdrop-filter`, named grid areas, `box-sizing`, `aspect-ratio`, `object-fit`, `overflow-x`/`-y`, `place-items`, `appearance`, `float`), now say what native Kryon does instead: `z-index`, `cursor`, `display: none` and `inline-*`, unequal grid tracks, and sizes in `min()` with a percentage among them; a percentage `border-radius` (999px rounds a pill), `box-shadow` through `var()` and pseudo-elements name the native form too. `css_tool check` exits with status 1 when it skipped anything natively, and stays at 0 for browser-only declarations alone. - Compiled packs store each rule sparse: a four-word mask of which of its 116 words are set, then only those words. The Material pack shrinks the app starter's portable bundle by 96,289 bytes (4,105,197 to 4,008,908). A pack carries `compiled.rule_count`; one without it is refused as stale, and `css_tool` regenerates it. diff --git a/src/parser/properties.zi b/src/parser/properties.zi index 75f6dbe..322a478 100644 --- a/src/parser/properties.zi +++ b/src/parser/properties.zi @@ -699,6 +699,15 @@ CssApplyProperty :: (p: *CssParser, name: CssName, end: s32) -> s32 { CssClearBorderSides(p, true, false) return ifx CssFailed(p) then -1 else CssScopeNative } else if CssNameEquals(name, "border-radius") { + CssSkipSpace(p) + origin := p.cursor + percentage, percent := CssReadPercent(p) + unused percentage + p.cursor = origin + if percent { + CssFail(p, "a percentage radius is not native; border-radius: 999px rounds a pill, and a square into a circle") + return -1 + } CssReadSymmetric(p, end, cast(s32)CssFieldRadius, name, 4) CssCheckRoundedSides(p, name) return ifx CssFailed(p) then -1 else CssScopeNative @@ -759,10 +768,15 @@ CssApplyProperty :: (p: *CssParser, name: CssName, end: s32) -> s32 { return ifx CssFailed(p) then -1 else CssScopeNative } else if CssNameEquals(name, "font") || CssNameEquals(name, "box-shadow") { status := p.status - native := ifx CssNameEquals(name, "font") then CssApplyFontShorthand(p, end) else CssApplyBoxShadow(p, end) + shadow := CssNameEquals(name, "box-shadow") + native := ifx shadow then CssApplyBoxShadow(p, end) else CssApplyFontShorthand(p, end) if !native || CssFailed(p) { p.status = status p.diagnostic_length = 0 + if shadow { + return CssPassWebDeclaration(p, + "native box-shadow takes none or shadows of px, rem or em lengths and a color, written out rather than through var(), and paints the elevation of the largest blur") + } return CssPassWebDeclaration(p) } p.cursor = p.pending_end diff --git a/src/parser/selectors.zi b/src/parser/selectors.zi index 1264715..fe066e1 100644 --- a/src/parser/selectors.zi +++ b/src/parser/selectors.zi @@ -201,7 +201,7 @@ CssReadSelectorParts :: (p: *CssParser, pending: *CssPendingSelector) -> s32 { if CssFailed(p) { return -1 } } else if byte == #char ":" { if CssPeek(p, 1) == #char ":" { - CssFail(p, "pseudo-elements are outside Kryon CSS") + CssFail(p, "pseudo-elements are outside Kryon CSS; draw the extra part as its own widget") return -1 } CssAdvance(p, 1) diff --git a/tests/css_parse_behavior.zi b/tests/css_parse_behavior.zi index 656cf49..3100700 100644 --- a/tests/css_parse_behavior.zi +++ b/tests/css_parse_behavior.zi @@ -84,6 +84,8 @@ Values :: () { ParseFails("Row { backdrop-filter: blur(8px); }", "nothing blurs what lies behind", "backdrop-filter") ParseFails("Grid { grid-area: main; }", "native Grid places children in order", "grid-area") ParseFails("Row { padding: 8px 12px 10px; }", "write padding: VERTICAL HORIZONTAL", "unequal block padding") + ParseFails("Button { border-radius: 50%; }", "border-radius: 999px rounds a pill", "percentage radius") + ParseFails("Row { box-shadow: var(--shadow); }", "native box-shadow takes none or shadows", "box-shadow through var()") if Builds("Column:hover { transform: translateY(-2px) scale(1.05); } Button { rotate: 45deg; scale: 1.1 0.9; transform-origin: left 25%; transition: transform 150ms linear; } Text { transform: rotate(90deg) scale(2, 1) translate(4px, 0); }", "transforms") { lifted := Rule(0).box