# zidane-ui/views/preview

Import: `import { … } from 'zidane-ui/views/preview'`. Source: [ui/src/views/preview.ts](https://github.com/Tahul/zidane/blob/main/ui/src/views/preview.ts).

## Components

### `ViewPreview`

Component.

`zidane-ui/views/preview`: the page a view renderer loads, so the model
can see the view it made (docs/VIEWS.md, The model sees its result). An app
builds a small page that imports the kit's stylesheet and calls
`installViewPreviewPage`.

```ts
function ViewPreview(props: ViewPreviewProps): Element
```

**Parameters**

- `props` (`ViewPreviewProps`): [`ViewPreviewProps`](https://zidane.si/docs/reference/ui-views-preview.md#ViewPreviewProps).

**Returns** `Element`

**Props**

- `inputs?` (`boolean`): The requesting host has inputs on: Choice, Form and Action draw enabled.
- `view` (`Pick<StoredView, 'anchor' | 'id' | 'title' | 'tree' | 'alt' | 'origin' | 'sessionId' | 'createdAt' | 'heights'> & Partial<StoredView>`): The stored view to draw.

Source: [ui/src/views/ViewPreviewPage.tsx:81](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewPreviewPage.tsx#L81)

## Functions

### `installViewPreviewPage`

Function.

`zidane-ui/views/preview`: the page a view renderer loads, so the model
can see the view it made (docs/VIEWS.md, The model sees its result). An app
builds a small page that imports the kit's stylesheet and calls
`installViewPreviewPage`.

```ts
function installViewPreviewPage(options?: ViewPreviewPageOptions): ViewPreviewPageApi
```

**Parameters**

- `options?` (`ViewPreviewPageOptions`, default `{}`): [`ViewPreviewPageOptions`](https://zidane.si/docs/reference/ui-views-preview.md#ViewPreviewPageOptions).

**Returns** `ViewPreviewPageApi`

Source: [ui/src/views/ViewPreviewPage.tsx:235](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewPreviewPage.tsx#L235)

### `measureViewPreview`

Function.

`zidane-ui/views/preview`: the page a view renderer loads, so the model
can see the view it made (docs/VIEWS.md, The model sees its result). An app
builds a small page that imports the kit's stylesheet and calls
`installViewPreviewPage`.

```ts
function measureViewPreview(root: HTMLElement): ViewPreviewPageResult
```

**Parameters**

- `root` (`HTMLElement`): The page's root element.

**Returns** `ViewPreviewPageResult`

Source: [ui/src/views/ViewPreviewPage.tsx:165](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewPreviewPage.tsx#L165)

## Constants

### `VIEW_PREVIEW_SETTLE_MS`

Constant.

The longest the page waits for a view to hold still before it measures what is there, unless the driver says (`settleMs`).

```ts
const VIEW_PREVIEW_SETTLE_MS = 10_000
```

Source: [ui/src/views/ViewPreviewPage.tsx:38](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewPreviewPage.tsx#L38)

## Interfaces

### `ViewPreviewPageOptions`

Interface.

Options of [`installViewPreviewPage`](https://zidane.si/docs/reference/ui-views-preview.md#installViewPreviewPage).

```ts
interface ViewPreviewPageOptions
```

**Properties**

- `root?` (`HTMLElement`): Where the view draws. Default: `#root`.
- `themes?` (`{ dark?: string; light?: string }`): Theme ids for each appearance (`themeStylesheet`). Default: the built-in ones.

Source: [ui/src/views/ViewPreviewPage.tsx:222](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewPreviewPage.tsx#L222)

### `ViewPreviewProps`

Interface.

Props of [`ViewPreview`](https://zidane.si/docs/reference/ui-views-preview.md#ViewPreview).

```ts
interface ViewPreviewProps
```

**Properties**

- `inputs?` (`boolean`): The requesting host has inputs on: Choice, Form and Action draw enabled.
- `view` (`Pick<StoredView, 'anchor' | 'id' | 'title' | 'tree' | 'alt' | 'origin' | 'sessionId' | 'createdAt' | 'heights'> & Partial<StoredView>`): The stored view to draw.

Source: [ui/src/views/ViewPreviewPage.tsx:69](https://github.com/Tahul/zidane/blob/main/ui/src/views/ViewPreviewPage.tsx#L69)
