LuxelEspañol

Luxel v0.2 · Guide · part 1 of 2

Views

A view is a TSX file that describes one page. It runs once, at build time, in Node. Its output is a template with slots, not a component that runs later. This page covers the components, how binds are typed, layout, styles, and what you can compute at build time.

A view file

// src/views/contacts.view.tsx → view id "contacts" import { Action, Field, Row, Stack, Status, Text, View } from '@luxel-framework/ui'; export default function Contacts() { return ( ‹View title="Contacts" dataClass="internal" className="page"> ‹Text id="title" as="h1">Contacts‹/Text> ‹Text bind="contacts.summary" as="p" className="summary" /> ‹Row as="form" className="form"> ‹Field name="name" label="Name" maxLength={60} required /> ‹Action id="add" event="contact.add" status="result" className="button">Add‹/Action> ‹/Row> ‹Status id="result" errorClassName="notice notice--error" successClassName="notice notice--success" /> ‹/View> ); }

Rules that hold for every view:

  • The default export returns exactly one ‹View> (LUXEL-E018).
  • Components come from @luxel-framework/ui or are your own plain functions. There are no HTML elements: ‹div> and ‹button> are type errors and LUXEL-E004.
  • No React import (LUXEL-E002), no hooks (LUXEL-E003), no function props such as onClick (LUXEL-E001).

Your tsconfig.json needs "jsx": "react-jsx" and "jsxImportSource": "@luxel-framework/ui". The template created by create-luxel already has both.

Components

ComponentWhat it isProps
ViewThe root, one per filetitle (required), dataClass (required: public, internal, confidential, restricted), version, trustDomain, as, className, messages
StackA group (a vertical one, by convention)as, className
RowA group (a horizontal one, by convention)as, className
TextStatic text, or server state with bindid, bind, as, className, label, labelClassName; in item templates state, stateClasses
FieldAn inputname, label, type, placeholder, autoComplete, maxLength, required, min, max, className, labelClassName
SelectA select whose options the server sendsname, label, options, required, className, labelClassName
ActionA button that sends a server eventid, event, status, busyLabel, onSuccess, fields, param, poll, className, busyClassName
LinkA plain link to another view of this app (‹a href>, fixed at build time)to (required: a view id), id, className
StatusWhere an action's errors and confirmations appearid, className, errorClassName, successClassName
CollectionA keyed, dynamic list of server itemsbind, itemKey, maxItems, id, label, as, className, changeEvent, changeStatus
ChartA column chartcolumns, scale, label, className, columnClassName
BarA bar inside a collection itemvalue, scale, vertical, className, barClassName

Any other prop is LUXEL-E010. A value the prop does not accept is LUXEL-E011. Every component has TypeScript types and JSDoc, so your editor completes props as it does for React.

dataClass has no default on purpose: classifying what a view shows is a security decision. luxel check refuses a public view that shows data above policies.publicMaxDataClass (LUXEL-E039).

Field, Select, Action and Status are covered in Forms; Collection in Collections; Chart and Bar in Charts.

Links

‹Link to="orders">Orders‹/Link> is a plain link to another view (or page) of this app (ADR-058). The compiler writes ‹a href="orders">: the address is the view's id, relative to the current page, so from /dom/home it opens /dom/orders in the same variant. The browser follows it on its own: it works without JavaScript and search engines can follow it.

to is always a view id, also when the target has a clean path (Routes). The compiler looks the target up in the route table and writes its address: ‹Link to="pricing"> becomes ‹a href="/pricing"> when the pricing view declares path: '/pricing'. When the linking view or the target has a path, the address written is absolute (a relative one would be wrong on a nested path such as /docs/getting-started), and both views must be served in the same single variant. You never write a path in a link: to="/pricing" does not build (LUXEL-E011).

  • to is fixed when you build. It must be a view or page of luxel.config served in every variant the linking view is served in, or the build stops (LUXEL-E059). It is never data: to={item.id} or an address from the server state does not build (LUXEL-E028, LUXEL-E043).
  • A link cannot go to another site, and cannot carry a query or a parameter. To open one record, use an ‹Action event="…" param={item.id}> whose handler stores the selection and returns ctx.navigate('detail').
  • Links are not allowed in a collection's item template (LUXEL-E015); a raw ‹a> is LUXEL-E004.
  • id is the link's zone id (default link-‹to>); give one when a view links twice to the same view.

Sign-out button

‹Logout to="login">Sign out‹/Logout> is a sign-out button that works without JavaScript: a form of its own that posts to the framework's sign-out route. Where the browser goes afterwards (to, or the view's loginView) is fixed when you build and is the same for the whole app (LUXEL-E066). See Sessions.

Text: static or bound

‹Text id="title" as="h1">Contacts‹/Text> {/* static: needs an id */} ‹Text bind="contacts.summary" as="p" /> {/* bound: the id defaults to "summary" */}

  • A static Text needs an id, unique in the view (LUXEL-E009, LUXEL-E005).
  • A bound Text shows the value of a state path. Its children, if any, are the initial text.
  • Text is always painted as text, never as HTML.
  • Text must be inside a Text. Text directly inside a container is LUXEL-E017.

as for Text: h1, h2, p, span (default), strong, td, th, li.

Typed slots: binds are checked against the contract

Every bind, options, columns and scale names a path of the view's contract, and the leaf type of that path decides what can show it:

Contract leafWhere it goesWhat the server sends
text()‹Text bind>A string or a message (ctx.message, ctx.plural)
money()‹Text bind label="…"> (no children)Integer cents; the host formats them
date()‹Text bind>An ISO date yyyy-mm-dd; the host formats it
quantity()‹Text bind>A number; the host formats it
number({ min, max })‹Chart scale>A raw number within the bounds
numbers({ min, max, length })‹Chart columns>Exactly length raw numbers
options({ max })‹Select options>Up to max { key, label }
Edit this page on GitHub

This page: 7.9 KB of JavaScript (Luxel's shared runtime), 0 KB from your app.

Measured when the site is built: the runtime files this page loads, compressed as they are sent.

Made by IntiOps. The Luxel 0.1.0 betas are on npm (0.1.0-beta.1, 0.1.0-beta.2), with an alpha of 0.2 (0.2.0-alpha.1): no external security review yet.