page DeviceFramecomponent { seo { title = "DeviceFrame component" description = "Theme-aware, responsive device frame component." } view {
W WRNexusJS
base component

DeviceFrame

Theme-aware, responsive device frame component.

@wrnexus/ui 0.5.014 props1 slots2 events

Usage

Components are auto-discovered. Use the component directly in any .wrn view:

<DeviceFrame
  size="default"
  color="primary"
  title="Device Frame"
  description="description"
  items="[]"
/>

Legacy mount name: data-component="DeviceFrame".

Props and attributes

PropTypeRequirementDefault
sizestringOptional"default"
colorstringOptional"primary"
titlestringOptional"Device Frame"
descriptionstringOptional""
itemsstringOptional[]
variantstringOptional"default"
devicestringOptional"phone"
orientationstringOptional"portrait"
srcstringOptional""
srcdocstringOptional""
frameTitlestringOptional"Device preview"
showToolbarbooleanOptionaltrue
allowstringOptional""
classstringOptional""

Slots

  • default

Events

  • change
  • rotate

Source contract

Installed source: components/DeviceFrame.wrn

component DeviceFrame {
  props {
    @event change = function
    @event rotate = function
    size = "default"
    color = "primary"
    title = "Device Frame"
    description = ""
    items = []
    variant = "default"
    device = "phone"
    orientation = "portrait"
    src = ""
    srcdoc = ""
    frameTitle = "Device preview"
    showToolbar = true
    allow = ""
    class = ""
  }
  state currentOrientation = orientation
  functions {
    function setDevice(nextDevice, sourceEvent) { $emit("change", { device: nextDevice, orientation: currentOrientation, sourceEvent: sourceEvent }) }
    function rotateFrame(sourceEvent) { currentOrientation = currentOrientation === "portrait" ? "landscape" : "portrait"; $emit("rotate", { device: device, orientation: currentOrientation, sourceEvent: sourceEvent }); $emit("change", { device: device, orientation: currentOrientation, sourceEvent: sourceEvent }) }
  }
  view {
        <section {...attrs} class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--device-frame wire-next--variant-{variant} {class}" data-device="{device}" data-orientation="{currentOrientation}">
        <header>
        <div>{#if title}<strong>{title}</strong>{/if}{#if description}<p>{description}</p>{/if}</div>{#if showToolbar}<div class="wire-next__device-actions" role="toolbar" aria-label="Preview device">{#each items as item}<button type="button" aria-pressed="{item.value === device}" @click="setDevice(item.value, event)">{item.label}</button>{/each}<button type="button" aria-label="Rotate preview" @click="rotateFrame(event)">↻</button>
        </div>{/if}</header>
        <div class="wire-next__device-shell">{#if src || srcdoc}<iframe title="{frameTitle}" src="{src}" srcdoc="{srcdoc}" allow="{allow}">
        </iframe>{:else}<div class="wire-next__device-content">
        <slot />
        </div>{/if}</div>
        </section>
    }
}
} }