Class ColorSlug

java.lang.Object
com.iizix.prop.ColorSlug

public final class ColorSlug extends Object
The slug of a palette color: the CSS custom property, --izc-<slug>, that a color reference becomes on the client (THEME-DESIGN.md section 4.2, ruling Q11).

The slug is a pure function of the reference string, computed the same way here and in iz/prop/color.js (GColor.slug), so that the server's app block and the client's var() meet on one name without the name travelling on the wire: the module prefix Mod: becomes mod-, a leading /style/ is dropped, every / becomes -, the whole is lower-cased, and every other character outside a-z0-9 becomes -, runs collapsed, ends trimmed. Lib:/style/Brand/Primary is lib-brand-primary, /style/Brand/Primary is brand-primary, the role Accent is accent.

Two different paths can fold to one slug (Brand/Primary and brand-primary, or the same style-relative path in two modules). The generator of the app block (AppPaletteCSS) claims every slug in a ColorSlug.Table and refuses a colliding pair rather than letting one silently win.

Author:
Christopher Mindus
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    The slug table of one app block: every custom property name the block defines and what defines it, so that two definitions of one name are found rather than let the later one win.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The prefix of every palette custom property: --izc-.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    of(String ref)
    Gets the slug of a color reference.
    static String
    Gets the custom property of a color reference: PREFIX and the slug.
  • Field Details

  • Method Details

    • of

      public static String of(String ref)
      Gets the slug of a color reference.
      Parameters:
      ref - The reference, without the leading %: a module-qualified Mod:/style/A/B, a module-relative /style/A/B, or a bare name.
      Returns:
      The slug, possibly empty for a reference of nothing but separators.
      Throws:
      NullPointerException - If ref is null.
    • property

      public static String property(String ref)
      Gets the custom property of a color reference: PREFIX and the slug.
      Parameters:
      ref - The reference, as for of(String).
      Returns:
      The custom property name, e.g. --izc-lib-brand-primary.