DeviceFrame
Theme-aware, responsive device frame component.
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
| Prop | Type | Requirement | Default |
|---|---|---|---|
size | string | Optional | "default" |
color | string | Optional | "primary" |
title | string | Optional | "Device Frame" |
description | string | Optional | "" |
items | string | Optional | [] |
variant | string | Optional | "default" |
device | string | Optional | "phone" |
orientation | string | Optional | "portrait" |
src | string | Optional | "" |
srcdoc | string | Optional | "" |
frameTitle | string | Optional | "Device preview" |
showToolbar | boolean | Optional | true |
allow | string | Optional | "" |
class | string | Optional | "" |
Slots
default
Events
changerotate
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>
}
}