# An hourly forecast

The weather now in a big card, and the hours ahead as a strip of cards you scroll sideways.

A row that scrolls sideways is how many apps show what comes next: hours, days, stories, categories. In HAM it's an ordinary `<row>` with `scroll="x"`.

## Step 1: The weather and the hours

What it's like now, as three lines of text, and a `<@foreach>` over an `hour` table seeded with the afternoon: each hour's time, an icon name, the temperature and the chance of rain.

```ham
<app>
    <config primary_color="light-blue"/>
    <database name="weather"
              version="1">
        <model name="hour">
            <field name="time"/>
            <field name="icon"/>
            <field name="temp"
                   type="int"/>
            <field name="rain"
                   type="int"/>
            <seed>[{"time": "Now", "icon": "sunny", "temp": 24, "rain": 0}, {"time": "2 pm", "icon": "sunny", "temp": 25, "rain": 0}, {"time": "3 pm", "icon": "partly_cloudy_day", "temp": 25, "rain": 10}, {"time": "4 pm", "icon": "cloud", "temp": 23, "rain": 30}, {"time": "5 pm", "icon": "rainy", "temp": 21, "rain": 70}, {"time": "6 pm", "icon": "rainy", "temp": 20, "rain": 60}, {"time": "7 pm", "icon": "partly_cloudy_night", "temp": 19, "rain": 20}]</seed>
        </model>
    </database>
    <screen>
        <app-bar title="Lisbon"/>
        <main>
            <column style="w-full p-16 gap-16">
                <column>
                    <text>24°</text>
                    <text>Sunny, rain from 5 pm</text>
                    <text>High 25° · Low 17°</text>
                </column>
                <@foreach in="hour"
                          order="id"
                          as="h">
                    <text>
                        @{$h.time}: @{$h.temp}°, @{$h.rain}% rain
                    </text>
                </@foreach>
            </column>
        </main>
    </screen>
</app>
```

## Step 2: A strip you scroll sideways

`<row scroll="x" spacing="10">` lays the hours side by side, 10 points apart, and scrolls when they're wider than the screen. Each hour is a small card: the time, its weather icon (`name="$h.icon …"` reads the icon from the row), the temperature and the chance of rain.

```ham
<app>
    <config primary_color="light-blue"/>
    <database name="weather"
              version="1">
        <model name="hour">
            <field name="time"/>
            <field name="icon"/>
            <field name="temp"
                   type="int"/>
            <field name="rain"
                   type="int"/>
            <seed>[{"time": "Now", "icon": "sunny", "temp": 24, "rain": 0}, {"time": "2 pm", "icon": "sunny", "temp": 25, "rain": 0}, {"time": "3 pm", "icon": "partly_cloudy_day", "temp": 25, "rain": 10}, {"time": "4 pm", "icon": "cloud", "temp": 23, "rain": 30}, {"time": "5 pm", "icon": "rainy", "temp": 21, "rain": 70}, {"time": "6 pm", "icon": "rainy", "temp": 20, "rain": 60}, {"time": "7 pm", "icon": "partly_cloudy_night", "temp": 19, "rain": 20}]</seed>
        </model>
    </database>
    <screen>
        <app-bar title="Lisbon"/>
        <main>
            <column style="w-full p-16 gap-16">
                <column>
                    <text>24°</text>
                    <text>Sunny, rain from 5 pm</text>
                    <text>High 25° · Low 17°</text>
                </column>
                <text style="font-bold">Today</text>
                <row scroll="x"
                     spacing="10">
                    <@foreach in="hour"
                              order="id"
                              as="h">
                        <column style="w-72 py-14 gap-8 items-center rounded-2xl bg-grey-100 dark:bg-grey-900">
                            <text style="font-sm muted">@{$h.time}</text>
                            <icon name="$h.icon size-28 amber"/>
                            <text style="font-bold">@{$h.temp}°</text>
                            <text style="font-xs text-light-blue">@{$h.rain}%</text>
                        </column>
                    </@foreach>
                </row>
            </column>
        </main>
    </screen>
</app>
```

## Step 3: The big card

The current weather becomes a card that fades from light blue to cyan, with the temperature 64 points tall beside a sun, and the summary and the day's range in white.

```ham
<app>
    <config primary_color="light-blue"/>
    <database name="weather"
              version="1">
        <model name="hour">
            <field name="time"/>
            <field name="icon"/>
            <field name="temp"
                   type="int"/>
            <field name="rain"
                   type="int"/>
            <seed>[{"time": "Now", "icon": "sunny", "temp": 24, "rain": 0}, {"time": "2 pm", "icon": "sunny", "temp": 25, "rain": 0}, {"time": "3 pm", "icon": "partly_cloudy_day", "temp": 25, "rain": 10}, {"time": "4 pm", "icon": "cloud", "temp": 23, "rain": 30}, {"time": "5 pm", "icon": "rainy", "temp": 21, "rain": 70}, {"time": "6 pm", "icon": "rainy", "temp": 20, "rain": 60}, {"time": "7 pm", "icon": "partly_cloudy_night", "temp": 19, "rain": 20}]</seed>
        </model>
    </database>
    <screen>
        <app-bar title="Lisbon"/>
        <main>
            <column style="w-full p-16 gap-16">
                <column style="w-full p-24 gap-4 rounded-3xl gradient-tl-lightblue-cyan-br shadow-lg">
                    <row style="w-full items-center">
                        <text style="text-white font-size-64 font-bold"
                              flex="1">24°</text>
                        <icon name="sunny fill size-64 amber"/>
                    </row>
                    <text style="text-white font-bold">Sunny, rain from 5 pm</text>
                    <text style="text-white opacity-80 font-sm">High 25° · Low 17°</text>
                </column>
                <text style="font-bold">Today</text>
                <row scroll="x"
                     spacing="10">
                    <@foreach in="hour"
                              order="id"
                              as="h">
                        <column style="w-72 py-14 gap-8 items-center rounded-2xl bg-grey-100 dark:bg-grey-900">
                            <text style="font-sm muted">@{$h.time}</text>
                            <icon name="$h.icon size-28 amber"/>
                            <text style="font-bold">@{$h.temp}°</text>
                            <text style="font-xs text-light-blue">@{$h.rain}%</text>
                        </column>
                    </@foreach>
                </row>
            </column>
        </main>
    </screen>
</app>
```

All of HAM, for AI tools: https://hypeapps.dev/llms.txt
