Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ these studies establishes an optimal duration for a sub-30-second silent clip:

## Files to use as the reference

The image tutorial and PNG-to-PDF blog guides share the same player and watch-page layout:
The image and layout tutorials share the same player and watch-page layout as the
PNG-to-PDF blog guides:

| File | Responsibility |
| --- | --- |
| [TutorialVideo.js](src/components/Video/TutorialVideo.js) | Shared playback behavior and `VideoObject` generated from the actual media URLs. |
| [RecordedVideo.js](src/components/Video/RecordedVideo.js) | Shared recording player and small **Open video →** action for any guide. |
| [image-tutorial-videos.json](src/data/image-tutorial-videos.json) | Shared recording details, metadata, watch and guide paths, and on-screen instructions for both image editions. |
| [layout-tutorial-videos.json](src/data/layout-tutorial-videos.json) | Shared recording details for the image-next-to-text tutorial's Pro walkthrough. |
| [png-pdf-videos.json](src/data/png-pdf-videos.json) | Recording details for the conversion and page-settings blog walkthroughs. |
| [ImageTutorialVideo.js](src/components/Video/ImageTutorialVideo.js) and [PngPdfVideo.js](src/components/Video/PngPdfVideo.js) | Thin article components that choose a recording; `showWatchLink` adds **Open video →**. |
| [VideoWatchPage.js](src/components/Video/VideoWatchPage.js) and [its styles](src/components/Video/VideoWatchPage.module.css) | Shared watch-page layout, metadata, return link, transcript, and responsive presentation. |
| [Pro route](src/pages/videos/add-image-phoenix-pro.js) and [Community route](src/pages/videos/add-image-phoenix-community.js) | Separate `/videos/...` pages, one recording per page. |
| [Pro layout route](src/pages/videos/image-next-to-text-phoenix-pro.js) | The same watch-page pattern linked to the image-next-to-text tutorial. |
| [PNG conversion route](src/pages/videos/convert-png-to-pdf.js) and [page-settings route](src/pages/videos/png-to-pdf-page-settings.js) | The same watch-page pattern linked to blog guides. |
| [tutorial-media-manifest.json](scripts/tutorial-media-manifest.json) | Capture provenance, project, measured duration, and any requested duration limit. |
| [verify-tutorials.cjs](scripts/verify-tutorials.cjs) | Checks the built tutorial pages, media, watch pages, and publication metadata. |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ npm run verify:tutorials
```

The checks cover tutorial links and anchors, image descriptions, video metadata
and captions, AI documentation indexes, and the contents of both practice ZIPs.
and captions, AI documentation indexes, and the contents of the practice ZIPs.
`npm run build` refreshes the API documentation from its source repository. If
the API files are already generated locally, `npm run docusaurus -- build` builds
the current checkout without refreshing them.
Expand Down
182 changes: 182 additions & 0 deletions docs/10-Tutorials/08-image-text-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
---
title: Put an image next to text in Phoenix Code
sidebar_label: Put an image next to text
slug: /tutorials/image-text-layout
description: Put an image next to text using Phoenix Pro's Layout controls or CSS in Community. Follow the steps with a practice project, screenshots, and a short video.
image: /tutorials/media/layout-result-desktop.png
toc_max_heading_level: 2
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import TutorialIcon from '@site/src/components/TutorialIcon';
import RecordedVideo from '@site/src/components/Video/RecordedVideo';
import layoutVideos from '@site/src/data/layout-tutorial-videos.json';

To put an image beside text in Phoenix Code, set their shared **container** to **Flex**. A container is the HTML element around both items.

- **Phoenix Pro:** select the container in Live Preview and use the **Layout** controls.
- **Community (free):** add four layout settings to your CSS file.

The practice project below includes the photo and HTML. You'll change the layout, then check that the photo and text sit side by side on a wide screen and stack on a phone.

## 1. Open the practice project

1. [Download the image and text practice project](/tutorials/image-text-layout.zip).
2. Extract the ZIP. On Windows, right-click it and choose **Extract All**. On macOS, double-click it. On Linux, use your file manager's **Extract** option.
3. In Phoenix Code, click the <TutorialIcon name="startProject" label="folder with a plus" /> at the top left. Choose **Open Folder…**, then select the extracted `image-text-layout` folder.
4. Open `index.html` from the file list. If Live Preview is closed, click the <TutorialIcon name="preview" label="lightning bolt" /> on the right.
5. If you're asked, choose **Trust & Execute Preview** for this practice project.

The folder contains `index.html`, `styles.css`, and `images/woodland.jpg`. In the preview, look for **“Plan a woodland walk”** and the woodland photo.

To open the practice folder, use the desktop app or the web app in Chrome or Edge. See [Open Folder](/docs/quick-start-project#open-folder) for more help.

## 2. Put the photo and text in a row

Choose your edition below. Both use the `.feature` container around the photo and text.

<Tabs groupId="tutorial-edition" queryString="edition" defaultValue="pro">
<TabItem value="pro" label="Phoenix Pro">

### Select the shared container

1. Click the <TutorialIcon name="expand" label="maximize icon" /> in the preview toolbar to enter **Design Mode**. The preview will fill the workspace.
2. Click the <TutorialIcon name="pen" label="pen button" /> if it's gray. An <TutorialIcon name="pen" active label="orange pen" /> means **Edit Mode** is on.
3. Click an empty part of the pale green area around the photo and text. The blue selection box should surround **both** the photo and the text. Look for **section** and **.feature** in the floating toolbar.

If the blue outline surrounds only the photo, click the empty pale green space beside it to select the whole `.feature` container.

[![The selected section.feature container surrounds the photo and text in Phoenix Pro Design Mode](/tutorials/media/layout-select-container.png)](/tutorials/media/layout-select-container.png)

### Set the layout

Keep **Save changes to** set to **Inline** (the default). Pro will save these settings in the selected section of `index.html`.

1. Click <TutorialIcon name="layout" label="Layout" /> in the Styles Bar. Look for the rectangle divided into smaller boxes. Hover over it to see **Layout – Block**.
2. In the **Display** tab, change **Block** to **Flex**. Leave **Direction** as **Row** (the arrow pointing right).
3. Under **Placement**, choose the **middle-left dot** (the tooltip is **Center / Left**). This keeps the row on the left and centers the photo and text vertically.
4. Change **Wrap** from **No Wrap** to **Wrap**. This lets the text move below the photo on narrow screens.
5. Set **Gap** to **24** and leave the unit as **px**. Press **Enter** to apply it.

[![Layout panel in Phoenix Pro with Flex, Row, Center / Left placement, Wrap, and a 24 px gap](/tutorials/media/layout-flex-settings.png)](/tutorials/media/layout-flex-settings.png)

Close the panel with its <TutorialIcon name="close" label="X" />. Keep **index.html** selected and click the <TutorialIcon name="save" label="floppy-disk icon" /> next to the file list to save your changes. Hover over it to see **Save File**. You can stay in Design Mode.

### Watch the steps

The video starts with the project open in Design Mode and Edit Mode on. Follow along as we select the container, change the layout, and check the result.

<RecordedVideo video={layoutVideos.pro} showWatchLink />

</TabItem>
<TabItem value="community" label="Community (free)">

### Find the shared container

Keep the code editor and Live Preview side by side. If the editor is hidden, click the <TutorialIcon name="restore" label="restore icon" /> in the preview toolbar.

In `index.html`, find the section with `class="feature"`. Inside it are the image (`<img>`) and a `<div class="feature-text">` holding the heading and paragraphs:

```html
<section class="feature" aria-label="Walk suggestion">
<img src="images/woodland.jpg"
alt="A sunlit path between tall trees"
width="1200" height="675">
<div class="feature-text">
<h2>Take the scenic route</h2>
<p>Your text goes here.</p>
</div>
</section>
```

This HTML is already in the practice project. The example above uses shorter text so you can see the structure.

### Add four CSS settings

If you've already done the Pro steps, extract a fresh copy of the practice project. The Pro settings saved in `index.html` take priority over the CSS below, so start with the original files.

1. Open `styles.css` from the file list.
2. Find the `.feature` rule, just below the comment **“Add your layout settings inside this rule”**.
3. Keep the `padding` and `background` lines. Add the four highlighted lines between the same opening `{` and closing `}`:

```css {4-7}
.feature {
padding: 24px;
background: #edf1e7;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 24px;
}
```

4. Save with **Ctrl+S** on Windows/Linux or **Cmd+S** on macOS. Check Live Preview: the text should now sit next to the photo when there's enough room.

[![The four layout settings in styles.css beside the photo and text in Live Preview](/tutorials/media/layout-community-css.png)](/tutorials/media/layout-community-css.png)

- `display: flex` puts the photo and text side by side.
- `flex-wrap: wrap` lets the text move below the photo when there isn't enough room.
- `align-items: center` keeps the photo and text centered vertically.
- `gap: 24px` adds 24 pixels of space between them.

The practice project already sets the photo's width and lets the text fill the space beside it.

</TabItem>
</Tabs>

## 3. Check the result at two sizes

In Pro, turn off the <TutorialIcon name="pen" label="pen button" /> to see the finished page without selection outlines.

- **Wide preview:** photo on the left, text on the right, with a gap between them.
- **Phone preview:** click the small down arrow next to the device icon in the preview toolbar. Select **iPhone 14 (390px)** or another phone width. The text should sit below the photo, with no need to scroll left or right. Select **Fit to screen** to return to the full preview width.

[![The finished photo and text row in the wide Live Preview in Phoenix Code](/tutorials/media/layout-result-desktop.png)](/tutorials/media/layout-result-desktop.png)

## Use the layout on your own page

On your own page, put the image and a text `<div>` inside the same `<section>` or `<div>`. Apply **Flex** to the outer element using the steps for your edition above. Keep the heading and paragraphs inside the text element so they move together.

To use the CSS below, give the outer element `class="feature"` and the text element `class="feature-text"`, as in the HTML example. Add these settings to your stylesheet below the `.feature` rule so the image and text fit both wide and narrow screens:

```css
.feature img {
display: block;
width: 320px;
max-width: 100%;
height: auto;
}

.feature-text {
flex: 1 1 260px;
min-width: 0;
}
```

The photo is `320px` wide but can shrink to fit its container. The text uses `260px` as a starting width and grows to fill the space beside the photo. Change these two sizes to suit your content.

Need a different picture? Follow [Add an image to your website](/docs/tutorials/add-images). For more controls, see the [Styles Bar Layout guide](/docs/Pro%20Features/styles-bar#layout) or [MDN's introduction to Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Flexible_box_layout/Basic_concepts).

## Frequently asked questions

<details>
<summary>Why is the text still below the image?</summary>

Check that **Flex** is set on the container holding both the image and the text. In Community, make sure you've saved `styles.css` and linked it from `index.html`. On a narrow screen, the text should be below the photo. Widen the preview or choose **Fit to screen** to see the row.

</details>

<details>
<summary>Can I put two images side by side instead?</summary>

Yes. Put both `<img>` elements directly inside the same container and apply the same Flex, Wrap, and Gap settings to it. Set the image widths so both fit in the row. Keep Wrap on so one image can go below the other on smaller screens.

</details>

<details>
<summary>Do I need Phoenix Pro for Flexbox?</summary>

No. Flexbox works in both editions. In Pro, use the Layout controls. In Community, edit the CSS and check your changes in Live Preview.

</details>
1 change: 1 addition & 0 deletions docs/10-Tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The guides open with **Phoenix Pro**, using Design Mode for visual editing. Choo

## Try something else

- **[Put an image next to text](/docs/tutorials/image-text-layout):** arrange a photo and text with Flexbox, then check that they stack neatly on a phone. Includes its own practice project.
- **[Build a page with Bootstrap](/docs/tutorials/bootstrap):** open a ready-made page, change its button color, and try it at a phone-sized width.
- **[Run your first Python program](/docs/tutorials/run-python):** create a file and make it print a message in the desktop app.

Expand Down
2 changes: 1 addition & 1 deletion scripts/package-tutorials.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('node:path');
const {zipSync} = require('fflate');

const TUTORIALS = path.join(__dirname, '../static/tutorials');
const PROJECTS = ['first-website', 'bootstrap-starter'];
const PROJECTS = ['first-website', 'bootstrap-starter', 'image-text-layout'];

function projectFiles(folder, relative = '') {
const files = {};
Expand Down
33 changes: 33 additions & 0 deletions scripts/tutorial-media-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
},
"bootstrap-starter": {
"index.html": "71e816a1452cbd3ecb090b4268397aff8fcb6d585cd599c8551ae9f4bcea5461"
},
"image-text-layout": {
"images/woodland.jpg": "95ef6002ec0119b339ccf05f4eb5801563845a94092fe294454bb931f8dec556",
"index.html": "5ecd0f57d1829a47df753540f99ee3a626c92b9017fa9202483c593a9eb6aa6f",
"styles.css": "e10ac2b85a95c49d4f219f9213e447f30efb25fac73ee513c034c3323d3864b0"
}
},
"recordings": [
Expand Down Expand Up @@ -145,6 +150,34 @@
],
"presentation": "Real converter interface and native menus, followed by the actual downloaded file opened in the Chromium PDF viewer; original page layout preserved",
"result_captured_at": "2026-11-12T05:45:27.346Z"
},
{
"file": "static/tutorials/media/pro-image-text-layout.mp4",
"project": "image-text-layout",
"workflow": "Design Mode throughout: select the shared section, keep the default Inline target, set Flex, Center / Left, Wrap, and a 24 px gap; click Save File to save index.html, disable Edit Mode, and choose iPhone 14 to check wrapping.",
"captured_at": "2026-11-17T10:29:48.833Z",
"on_screen_instructions": true,
"highlighted_controls": true,
"system_file_picker_recorded": false,
"duration_seconds": 26,
"duration_limit_seconds": 30,
"frame_size": [
1360,
964
],
"caption_placement": "Instruction strip above the recording, clear of the controls",
"presentation": "Full-resolution Chrome screencast of real Phoenix Pro pointer and keyboard actions. The prepared practice project is already open. Timing is slowed uniformly to 26 seconds for readable instructions.",
"verification": [
"The saved index.html section has inline display:flex, align-items:center, flex-wrap:wrap, gap:24px and justify-content:flex-start",
"index.html is no longer dirty after clicking Save File",
"Computed layout uses Flex, Wrap, centered alignment, and a 24 px gap",
"The recorded phone preview stacks the text below the photo",
"The separate Community editor workflow saves the four CSS declarations; the wide preview forms a row, and the 390 px preview stacks with a 24 px gap and no horizontal overflow",
"Production documentation build, tutorial release tests, tutorial asset verification, and local destination checks passed",
"Article and watch page checked at 1440 px and 390 px widths in light and dark themes with no horizontal page overflow",
"Visible muted playback, offscreen pause, reader pause preservation, seeking, reduced-motion manual playback, keyboard FAQ use, and watch-page return navigation verified in Chrome",
"Article-to-watch-page navigation and return each retain one VideoObject without duplicate metadata"
]
}
],
"sample_photo": {
Expand Down
8 changes: 5 additions & 3 deletions scripts/verify-tutorials.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ const {TUTORIALS, PROJECTS, projectFiles} = require('./package-tutorials.cjs');
const {PUBLICATIONS_PATH, validatePublications} = require('../plugins/tutorial-media/publications');
const imageVideos = require('../src/data/image-tutorial-videos.json');
const pngPdfVideos = require('../src/data/png-pdf-videos.json');
const layoutVideos = require('../src/data/layout-tutorial-videos.json');

const SITE = path.join(__dirname, '..');
const ORIGIN = 'https://docs.phcode.dev';
const GUIDES = ['tutorials', 'tutorials/add-images', 'tutorials/link-pages',
'tutorials/share-website', 'tutorials/bootstrap', 'tutorials/run-python',
'tutorials/find-and-replace', 'tutorials/replace-in-files', 'Features/find-in-files'];
'tutorials/find-and-replace', 'tutorials/replace-in-files', 'Features/find-in-files',
'tutorials/image-text-layout'];
const BLOGS = ['how-to-convert-png-to-pdf-free-online', 'how-to-convert-png-to-pdf-without-losing-quality'];
const ARTICLE_ROUTES = [...GUIDES.map(guide => '/docs/' + guide), ...BLOGS.map(slug => '/blog/' + slug)];
const WATCH_VIDEOS = [...Object.values(imageVideos), ...Object.values(pngPdfVideos)];
const WATCH_VIDEOS = [...Object.values(imageVideos), ...Object.values(pngPdfVideos), ...Object.values(layoutVideos)];

function videoDuration(file) {
const data = fs.readFileSync(file);
Expand Down Expand Up @@ -215,7 +217,7 @@ function verify(build, release = false) {
assert(Buffer.from(archive[`${project}/${name}`]).equals(content), `Stale practice file: ${project}/${name}`);
}
}
return `PASS: ${GUIDES.length} guides, ${BLOGS.length} blog posts, local links and anchors, screenshots, 5 image FAQs, ${videos.length} videos with captions, ${WATCH_VIDEOS.length} video watch pages, ${indexLinks} AI-index links, and both practice ZIPs.` +
return `PASS: ${GUIDES.length} guides, ${BLOGS.length} blog posts, local links and anchors, screenshots, 5 image FAQs, ${videos.length} videos with captions, ${WATCH_VIDEOS.length} video watch pages, ${indexLinks} AI-index links, and ${PROJECTS.length} practice ZIPs.` +
(release ? ' Release publication dates are complete.' : ' Preview metadata verified.');
}

Expand Down
Loading
Loading