Skip to content

Commit bae3284

Browse files
authored
Merge pull request #17 from gethinode/develop
feat(docs): update preview block documentation
2 parents d7aac03 + 7de8182 commit bae3284

1 file changed

Lines changed: 57 additions & 18 deletions

File tree

content/blocks/preview.md

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,34 @@ Set the `device` argument to specify which device view to display by default. Op
4040
- _bookshop_name: preview
4141
heading:
4242
title: Tablet Preview
43-
content: Opens in tablet view (672×896)
43+
content: Opens in tablet view (820×1180 logical pixels)
4444
url: "https://en.wikipedia.org/wiki/Hugo_(software)"
4545
device: tablet
4646
```
4747

4848
{{< /example-bookshop >}}
4949
<!-- markdownlint-enable MD037 -->
5050

51+
### Strict aspect ratio
52+
53+
By default the desktop preview fills the full container width and height (responsive mode). Set `desktop-responsive: false` to use a strict 16:10 contain fit instead — the full 1440 × 900px frame is always visible with no clipping, leaving symmetric gaps above and below when the container is wider than it is tall.
54+
55+
<!-- markdownlint-disable MD037 -->
56+
{{< example-bookshop lang="bookshop" >}}
57+
58+
```yml
59+
- _bookshop_name: preview
60+
heading:
61+
title: Strict Aspect Ratio
62+
content: Full 1440×900px frame always visible, no clipping
63+
url: "https://en.wikipedia.org/wiki/Hugo_(software)"
64+
device: desktop
65+
desktop-responsive: false
66+
```
67+
68+
{{< /example-bookshop >}}
69+
<!-- markdownlint-enable MD037 -->
70+
5171
### Full-width preview
5272

5373
Use `cover: true` and `fluid: true` for a full-width preview layout, ideal for showcasing responsive designs.
@@ -156,39 +176,58 @@ This allows embedding localhost sites during development while maintaining secur
156176

157177
## Device dimensions
158178

159-
The preview component uses **fixed widths** and **flexible heights**:
179+
Device dimensions use **logical pixels** (CSS pixels), which is what browsers and responsive design tools use for layout. Physical pixels depend on the device pixel ratio (DPR) of the hardware display.
160180

161-
- **Desktop**: 1200px width (fixed)
162-
- **Tablet**: 672px width (fixed)
163-
- **Mobile**: 375px width (fixed)
181+
| Device | Logical resolution | Aspect ratio | DPR reference |
182+
|--------|-------------------|--------------|---------------|
183+
| Desktop | 1440 × 900px | 16:10 | @1× (MacBook / laptop) |
184+
| Tablet | 820 × 1180px | ~9:13 | @2× (iPad 10th gen / iPad Air M2) |
185+
| Mobile | 402 × 874px | 9:19.5 | @3× (iPhone 17 Pro, 460 ppi) |
164186

165-
**Heights** adapt to available viewport space:
187+
A website loaded inside the iframe sees a viewport matching these logical pixel dimensions, so breakpoints and responsive layouts behave exactly as they would on the real device.
166188

167-
```scss
168-
height: calc(100vh - controls - navbar - margins)
169-
min-height: 400px
189+
### Auto-scaling
190+
191+
JavaScript scales each device on page load and on every browser resize. Tablet and mobile always use a **contain fit** — the largest scale where neither dimension is clipped:
192+
193+
```
194+
scale = min(containerWidth / deviceWidth, containerHeight / deviceHeight, 1)
170195
```
171196

172-
Content within panels scrolls vertically when it exceeds the panel height.
197+
Desktop scaling depends on the `desktop-responsive` argument:
198+
199+
| Mode | `desktop-responsive` | Behaviour |
200+
|------|----------------------|-----------|
201+
| Responsive (default) | `true` | Scales to fill the full container width; iframe height is adjusted dynamically so the container height is also filled. The site inside sees a 1440px-wide viewport. |
202+
| Strict aspect ratio | `false` | Contain fit — the full 1440 × 900px frame is always visible; symmetric gaps may appear above and below on wide containers. |
203+
204+
The zoom recalculates on page load and whenever the browser window is resized.
205+
206+
**Container height** adapts to available viewport space and is capped so tall devices
207+
(tablet: 1180px logical) are never rendered beyond the available screen area:
208+
209+
```scss
210+
height: min(calc(100vh - controls - navbar - 4rem),
211+
calc(var(--max-section-height, 1024px) - controls));
212+
min-height: 400px;
213+
```
173214

174215
### Responsive visibility
175216

176217
The component automatically shows or hides device previews **based on viewport width only**:
177218

178-
- **Small screens (< 768px)**: Mobile preview only
179-
- **Medium screens (768px-1199px)**: Tablet and mobile previews
180-
- **Large screens (≥ 1200px)**: All three previews
181-
182-
**Height does not affect panel visibility** - panels adjust their height to fit the viewport, and content scrolls if needed.
219+
- **Small screens (< 640px)**: Mobile preview only
220+
- **Medium screens (640px–1023px)**: Tablet and mobile previews
221+
- **Large screens (≥ 1024px)**: All three previews
183222

184223
Buttons for hidden device views are automatically hidden from the control bar, and the active view automatically switches when a panel becomes unavailable.
185224

186225
### Container constraints
187226

188-
Desktop preview (1200px width) works best with:
227+
In responsive mode (default), the desktop preview fills whatever container it is placed in. For best results with `desktop-responsive: false` or when using `cover: true`:
189228

190-
- `fluid: true` or `width: 12` for full-width layouts
191-
- Container-xxl or larger for proper display
229+
- Use `fluid: true` or `width: 12` for full-width layouts
230+
- Use a container at least as wide as the desired desktop zoom level
192231

193232
## Security
194233

0 commit comments

Comments
 (0)