Skip to content

CSSThemeCompiler: support theme constants, font sizes, and spacing semantics for parity #6024

Open

Description

@shai-almog

com.codename1.ui.css.CSSThemeCompiler should support the following syntax and theme semantics for parity with the standard Codename One CSS compiler (com.codename1.designer.css.CSSTheme).

Theme constants

  • Recognize #Constants { ... } as a theme-constant block, while retaining @constants support.
  • Preserve constant-name case. For example, includeNativeBool must produce @includeNativeBool, not @includenativebool. Ordinary CSS property names can remain case-insensitive.
  • Decode quoted constant values: both 'true' and "true" should produce the string true, without quote delimiters. Unquoted values should continue to work.
  • Exclude constant blocks from ordinary UIID rule processing.
#Constants {
    includeNativeBool: true;
    customMessage: "Hello";
}

Expected theme entries include @includeNativeBool = "true" and @customMessage = "Hello".

Font sizes

Support font-size with mm, px, and pt, including correct conversion and integration with font-family. Size declarations should also work without a family declaration and remain associated with the correct component state.

Label {
    font-family: "native:MainRegular";
    font-size: 3mm;
}

The resulting theme should resolve to a usable font at the requested size, with the same sizing semantics as the standard CSS compiler.

Padding and margin

  • Expand one-, two-, three-, and four-value CSS shorthand correctly.
  • Convert CSS top/right/bottom/left order to Codename One's top/bottom/left/right storage order.
  • Emit the corresponding per-side unit metadata, preserving mm, px, and % semantics and converting pt consistently with the standard compiler. Mixed-unit declarations should preserve each side's unit.

For example:

Label {
    padding: 1px 2px 3px 4px;
    margin: 1mm 2mm;
}

Expected padding values in theme storage order are 1,3,4,2. Expected margin values are 1,1,2,2, with millimeter unit metadata for all four sides.

Current gaps and validation

Source inspection of the current default branch shows that compileConstants() recognizes only @constants, parseDeclarations() lowercases all names and retains quoted values, font-size has no handler, and normalizeBox() preserves CSS ordering while scalar() only strips px.

Add regression coverage for the examples above, all shorthand lengths, mixed units, and state-specific font/spacing declarations. Compare generated theme values and resolved styles against the standard CSS compiler, and retain coverage for existing @constants behavior.

Source: CSSThemeCompiler.java.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions