Mothership workspace
| Owner | Ada Lovelace |
|---|---|
| Status | Active |
| Updated on |
Active Storage images with low-resolution previews and explicit lifecycle states.
app/components/nitro_kit/progressive_image.rbNitroKit::ProgressiveImage.new(attachment:, alt:, size: :md, decorative: false)A decorative low-resolution variant covers the full image until browser decoding succeeds.
test/dummy/app/components/gallery/components/progressive_image_page.rbrender NitroKit::ProgressiveImage.new(
attachment: image_attachment,
alt: "Abstract indigo workspace illustration",
size: :lg,
id: "gallery-progressive-image-loaded"
)Closed sizes request predictable one- and two-density Active Storage variants without accepting arbitrary processing options.
test/dummy/app/components/gallery/components/progressive_image_page.rbNitroKit::ProgressiveImage::SIZES.each do |size|
sample(size.to_s.upcase, slug: size) do
render NitroKit::ProgressiveImage.new(
attachment: image_attachment,
alt: "Abstract indigo workspace illustration",
size:,
id: "gallery-progressive-image-#{size}"
)
end
endEmpty markup is complete on the server; failed loads reveal the fallback while preserving informative alt text.
test/dummy/app/components/gallery/components/progressive_image_page.rbsample("Empty attachment", slug: "empty") do
render NitroKit::ProgressiveImage.new(
attachment: nil,
alt: "Workspace cover",
size: :sm,
id: "gallery-progressive-image-empty"
)
end
sample("Failed variant", slug: "error") do
render NitroKit::ProgressiveImage.new(
attachment: broken_attachment,
alt: "Unavailable workspace cover",
size: :sm,
id: "gallery-progressive-image-error"
)
endThe placeholder never enters the accessibility tree; decorative full images also use an empty alt.
test/dummy/app/components/gallery/components/progressive_image_page.rbrender NitroKit::ProgressiveImage.new(
attachment: image_attachment,
alt: nil,
decorative: true,
size: :md,
id: "gallery-progressive-image-decorative"
)Progressive media, a card, status, and record details compose without utility classes or helper registration.
| Owner | Ada Lovelace |
|---|---|
| Status | Active |
| Updated on |
test/dummy/app/components/gallery/components/progressive_image_page.rbrender NitroKit::Card.new(id: "gallery-progressive-image-card") do |card|
card.full do
render NitroKit::ProgressiveImage.new(
attachment: image_attachment,
alt: "Abstract indigo workspace illustration",
size: :lg,
id: "gallery-progressive-image-card-media"
)
end
card.title(SUMMARY.title, level: 3)
card.body do
render NitroKit::DetailsTable.new(SUMMARY, id: "gallery-progressive-image-card-details") do |details|
details.field(:owner)
details.field(:status) do |status|
render NitroKit::Badge.new(
status.to_s.humanize,
id: "gallery-progressive-image-card-status",
color: :success,
size: :sm
)
end
details.field(:updated_on)
end
end
endConstructor options, rendered root, closed vocabularies, and compound boundary for this component, exactly as shipped.
docs/component_contracts.md · NitroKit::ProgressiveImage
attachment:alt: nil, size: :md, decorative: false, id: nildiv[data-nk=progressive-image]; sizes sm md lg; states empty loading loaded erroralt: is required unless decorative: true, and non-decorative attached images require non-blank alt text. The fallback surfaces that alt text, falling back to I18n.t("nitro_kit.progressive_image.unavailable") when there is none. Only an attached image can change after render, so only that fallback is a role="status" live region; the never-attached empty state is ordinary static content. data-enhanced on the root is the controller-connected flag shared with AppShell; it is deliberately not data-state, which already carries the closed load-state vocabulary.Instructions for coding agents, repeated on every component page so one fetched page has enough context. Humans can usually skip this section.
test/dummy/app/components/gallery/agent_rules.rb
render NitroKit::Button.new("Save", variant: :primary).ArgumentError; this component's accepted options are in the contract above.html: for HTML, aria: for ARIA, and data: for application data. class and style are forbidden, including inside html:.NitroKit::Component::RESERVED_DATA_ATTRIBUTES: data-nk, data-slot, data-variant, data-size, data-nk-escape, data-enhanced, data-state, data-disabled, data-required, data-orientation, data-presentation, data-placement, data-layout, data-side, data-field-type, data-dir, data-gap, data-align, data-justify, data-wrap, data-cols, data-mode, data-key. Do not pass them through data:. data-action, data-controller are additive and compose with Nitro behavior.desperately_need_a_class:. It requires a non-blank String and marks the exception with data-nk-escape="class".data-nk; owned parts emit component-qualified data-slot values such as field-control or card-title. Select on those attributes, never on classes.--nk-* custom properties in an application stylesheet. Variables beginning with --_nk-* are private component mechanics.NitroKit::Flex and NitroKit::Grid for layout. Parents own external placement and available width; components own their intrinsic geometry.data-state when styling or behavior also needs it.