Osy#betaRun it on Osyrin: osyrin.com

Reference / UI

A kit's own part instead of another's — replaces and ui-kit-replaces-this-part

replaces "Select" { use "LookSelect"; why "…"; }

A kit declares in its package.osy which parts of other kits (or which platform atoms) it offers its own for. In an app that uses the kit, osy lint's ui-kit-replaces-this-part (SHOULD) reports each page that draws a replaced part and names the kit's part to draw instead. Turn it off for one page with [SuppressWarning] on the component, or for the whole app on its app { } manifest.

stable1 example compiled by CIuilintkitspackages

Summary#

A kit knows when it has a better part than the one a page reaches for — the Osyrin look has its own dropdown, drawn as its boards draw it, where the browser's <select> looks different in every browser. The kit says so once, in its package.osy, and every app that uses it hears it from osy lint on the page that drew the other part.

replaces "Select" {
  use "LookSelect";
  why "the browser's own select cannot be drawn as the boards' §22 dropdown";
}

Signature#

replaces "<Part>" { use "<KitPart>"; [unless "<argument>";] [why "<reason>";] }
  • <Part> — the replaced part's bare name: a platform atom (Select) or another kit's component (SelectField).
  • use (required) — the kit's own component to draw instead. One the kit does not declare is a compile error in the kit (PACKAGE_REPLACES_UNKNOWN_PART).
  • unless — an argument whose presence makes the call a face the kit does not replace.
  • why — the reason the finding gives.

Description#

What the app hears#

ui-kit-replaces-this-part is a SHOULD finding on each call of a replaced part in one of the app's own components:

SHOULD  ui-kit-replaces-this-part  ShopPage (Select → LookSelect)
  'ShopPage' draws `Select`, and Osysharp.Look, which this app uses, offers `LookSelect` for it instead. The browser's own
  select cannot be drawn as the boards' §22 dropdown.
  → draw `LookSelect` here (`osy kit LookSelect` for its signature).

When is it silent?#

  • The app does not use a kit that declares the replacement.
  • The call carries the entry's unless argument (SelectField(…, detail: …) draws its own list).
  • The app declares its own component of the replaced name — that is not the part the kit means.
  • The call is inside a kit's code. The rule judges the app's own pages.

Turning it off#

For one page, say why on the component: [SuppressWarning("ui-kit-replaces-this-part")]. For the whole app, put it on the app { } manifest. The kit an app uses is an app-wide choice, so this rule also accepts the manifest form, which covers every page:

[SuppressWarning("ui-kit-replaces-this-part")]
app Shop { use Osysharp.Look@0; }

What Osysharp.Look replaces#

ReplacedUseUnless
Select (the browser's select)LookSelect—
SelectFieldLookSelect (over an enum LookEnumSelect, over rows LookRefPicker)detail

A page that draws the look's own dropdown instead of Select gets no finding:

using Osysharp.Look;

[Route("/shop")]
[AllowAnonymous]
component ShopPage() {
  string size = "M";

  render {
    LookSelect("Size", size, ["S", "M", "L"]);
  }
}

See also#

Related

package.osy

The manifest that makes a git repository a publishable Osy# package. It names the package, says which of the…

A picker over every row — the SearchPicker

A Dropdown is usable for a few dozen options; over an entity that grows, past the first answer (about 2 MB of rows) the…

[SuppressWarning]

Accept ONE named warning about ONE declaration. Put it on whatever the finding is reported against — a function, an…