Skip to content

Components ​

Trek's admin UI is built with ViewComponent, Stimulus and Turbo, styled with PostCSS and Radix colors, with light & dark themes.

UI components ​

The main building blocks, all in the Trek:: namespace:

ComponentPurpose
LayoutComponentadmin layout, with header, menu and panel slots
HeaderComponenttop navigation bar
MenuComponentsidebar navigation, with polymorphic slots
BrandComponentlogo, title & subtitle area
DialogComponentmodal dialogs, with configurable title and buttons
TabsComponenttabbed interfaces
ButtonComponentbuttons & button-styled links
ListComponentrecord lists
PropertiesComponentkey-value property display
PaginationComponentKaminari-backed pagination
ToasterComponent / Toaster::ToastComponentflash notifications
HeadingComponentheadings
SectionComponenta titled section of a page, with an optional hint under its heading
GateComponentthe frame of the sign-in and password reset screens: a centred card under the brand
IconComponentSVG icon renderer
Dashboard::SectionComponent / Dashboard::TileComponentdashboard sections of shortcut tiles

Dashboard tiles ​

A tile is a link by default. With method:, it issues another HTTP method through Turbo (as a data-turbo-method link), so a tile can create a record in one click rather than open a form; data: adds attributes to the link, such as a confirmation:

ruby
s.with_tile(
  text: "New weekly draft",
  icon: "trek/add",
  href: [:draft_current_week, :admin, :newsletters],
  method: :post,
  data: { turbo_confirm: "Create this week's draft?" }
)

Form components ​

Rendered by the form builder helpers, under Trek::Form:::

GroupComponent, FieldsetComponent, ActionsComponent (configurable aspect & classnames), ErrorsComponent, TextFieldComponent, ImageFieldComponent, SoundFieldComponent, SwitchBoxComponent, CollectionSelectComponent, GroupedCollectionSelectComponent, LinkSelectComponent and ContentEditorComponent.

Content editor ​

Trek::Form::ContentEditorComponent wraps the Tiptap editor and accepts nodes, blocks and floating (all enabled by default) to toggle the text buttons, the block buttons and the floating menu, and autofocus:

ruby
f.content_editor :intro, nodes: false, floating: false

Content is stored as ProseMirror JSON and rendered with formatted_content. Image uploads (Uppy), link insertion and prompts are served by the panel controllers. See the Content editor guide for its toolbar, how content is stored and rendered, and how to customize it.

Released under the MIT License.