1. Docs
  2. Cookbook

Pick the right match (MoviePlz)

After you rename a title, the likeliest matches from a movie database, each with a This one button that the server answers, from MoviePlz.

2 steps · ends in a choice of matches, each one tap from saved

When you fix a title's name in MoviePlz, its server asks The Movie Database which film or series that is, and sends back the best matches to choose from. The choice is one tap, and the box is replaced by the title with its new poster. The titles and descriptions here are invented.

Step 1 of 2

The matches as the server sends them

A box with an id, title-12, and a question: which one is it? Then one card per match, its kind, year and a line of its description, each with a This one button, and two ways out: No poster, and Decide later.

app.ham · step 1
<app>    <config primary_color="red"/>    <screen>        <app-bar title="Edit title"/>        <main>            <column style="w-full p-16">                <column id="title-12"                        style="w-full p-16 gap-10 rounded-2xl bg-red-50 dark:bg-red-950">                    <text style="font-lg font-bold">Which one is Harbor Lights?</text>                    <text style="muted font-sm">                        Pick the right one for its poster and description.                    </text>                    <column style="w-full rounded-xl bg-white dark:bg-grey-900">                        <flex column_widths="60px 1">                            <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900">                                <icon name="tv size-24 red"/>                            </column>                            <column style="px-12 py-10 gap-2">                                <text style="font-bold">Harbor Lights</text>                                <text style="muted font-sm">Series · 2019</text>                                <text style="muted font-xs">                                    A lighthouse town keeps a decades-old secret.                                </text>                                <button variant="filled"                                        size="sm"                                        style="mt-6">This one</button>                            </column>                        </flex>                    </column>                    <column style="w-full rounded-xl bg-white dark:bg-grey-900">                        <flex column_widths="60px 1">                            <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900">                                <icon name="movie size-24 red"/>                            </column>                            <column style="px-12 py-10 gap-2">                                <text style="font-bold">Harbor Lights</text>                                <text style="muted font-sm">Film · 1987</text>                                <text style="muted font-xs">                                    Two brothers race to save the family boatyard.                                </text>                                <button variant="filled"                                        size="sm"                                        style="mt-6">This one</button>                            </column>                        </flex>                    </column>                    <column style="w-full rounded-xl bg-white dark:bg-grey-900">                        <flex column_widths="60px 1">                            <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900">                                <icon name="movie size-24 red"/>                            </column>                            <column style="px-12 py-10 gap-2">                                <text style="font-bold">The Harbor Lights</text>                                <text style="muted font-sm">Film · 2004</text>                                <text style="muted font-xs">                                    A singer returns home for one last summer.                                </text>                                <button variant="filled"                                        size="sm"                                        style="mt-6">This one</button>                            </column>                        </flex>                    </column>                    <row style="gap-8">                        <button variant="outlined"                                size="sm">No poster</button>                        <button variant="text"                                size="sm">Decide later</button>                    </row>                </column>            </column>        </main>    </screen></app>
Step 1 on a phone: The matches as the server sends them Step 1 on a phone, dark: The matches as the server sends them
Step 1, drawn by the engine from the snippet beside it.

Step 2 of 2

Each choice goes to the server

Every button posts to the server and swaps the whole box with the answer: action="/host/library/12/match?pick=1", method="POST", target="#title-12" and swap="outer". The server saves the pick and sends the title back, now with its poster and description, in the box's place. Decide later fetches the title as it was. No state lives on the phone: what the box shows is whatever the server last sent.

MoviePlz's own markup: the matches.

app.ham · step 224 new lines
<app>    <config primary_color="red"/>    <screen>        <app-bar title="Edit title"/>        <main>            <column style="w-full p-16">                <column id="title-12"                        style="w-full p-16 gap-10 rounded-2xl bg-red-50 dark:bg-red-950">                    <text style="font-lg font-bold">Which one is Harbor Lights?</text>                    <text style="muted font-sm">                        Pick the right one for its poster and description.                    </text>                    <column style="w-full rounded-xl bg-white dark:bg-grey-900">                        <flex column_widths="60px 1">                            <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900">                                <icon name="tv size-24 red"/>                            </column>                            <column style="px-12 py-10 gap-2">                                <text style="font-bold">Harbor Lights</text>                                <text style="muted font-sm">Series · 2019</text>                                <text style="muted font-xs">                                    A lighthouse town keeps a decades-old secret.                                </text>                                <button action="/host/library/12/match?pick=0"                                        method="POST"                                        target="#title-12"                                        swap="outer"                                        variant="filled"                                        size="sm"                                        style="mt-6">This one</button>                            </column>                        </flex>                    </column>                    <column style="w-full rounded-xl bg-white dark:bg-grey-900">                        <flex column_widths="60px 1">                            <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900">                                <icon name="movie size-24 red"/>                            </column>                            <column style="px-12 py-10 gap-2">                                <text style="font-bold">Harbor Lights</text>                                <text style="muted font-sm">Film · 1987</text>                                <text style="muted font-xs">                                    Two brothers race to save the family boatyard.                                </text>                                <button action="/host/library/12/match?pick=1"                                        method="POST"                                        target="#title-12"                                        swap="outer"                                        variant="filled"                                        size="sm"                                        style="mt-6">This one</button>                            </column>                        </flex>                    </column>                    <column style="w-full rounded-xl bg-white dark:bg-grey-900">                        <flex column_widths="60px 1">                            <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900">                                <icon name="movie size-24 red"/>                            </column>                            <column style="px-12 py-10 gap-2">                                <text style="font-bold">The Harbor Lights</text>                                <text style="muted font-sm">Film · 2004</text>                                <text style="muted font-xs">                                    A singer returns home for one last summer.                                </text>                                <button action="/host/library/12/match?pick=2"                                        method="POST"                                        target="#title-12"                                        swap="outer"                                        variant="filled"                                        size="sm"                                        style="mt-6">This one</button>                            </column>                        </flex>                    </column>                    <row style="gap-8">                        <button action="/host/library/12/match?pick=none"                                method="POST"                                target="#title-12"                                swap="outer"                                variant="outlined"                                size="sm">No poster</button>                        <button action="/host/library/12/view.ham"                                target="#title-12"                                swap="outer"                                variant="text"                                size="sm">Decide later</button>                    </row>                </column>            </column>        </main>    </screen></app>
Step 2 on a phone: Each choice goes to the server Step 2 on a phone, dark: Each choice goes to the server
Step 2, drawn by the engine from the snippet beside it.

This page is also Markdown, and all of HAM is in llms.txt.