Data displayListingRow
Searchastronomic.dev# ListingRow
The same listing as a wide row, for a list beside a map or a short list on a page.
Interactive: inline script.
## Usage
```astro
import ListingRow from "@astronomic-dev/ui/components/ListingRow.astro";
```
## Examples
### One row
From 36rem of card, the photo at the start, about 2 to 3 against the text; from 48rem the facts beside the price and the title. Narrower, it is the card, one column.
```astro
---
import ListingRow from "@astronomic-dev/ui/components/ListingRow.astro";
import { fields, listings } from "../_data/vega.ts";
---
<div class="p-6">
<ListingRow listing={listings[2]} fields={fields} imageSizes="(min-width: 36rem) 20rem, 100vw" />
</div>
```
### A short list
Rows in a list, one under another, as beside a map or on an agent's page.
```astro
---
import ListingRow from "@astronomic-dev/ui/components/ListingRow.astro";
import { fields, listings } from "../_data/vega.ts";
---
<ul role="list" class="m-0 grid list-none gap-cards p-6">
{
listings.slice(3, 6).map((home) => (
<li>
<ListingRow listing={home} fields={fields} imageSizes="(min-width: 36rem) 20rem, 100vw" />
</li>
))
}
</ul>
```
## Props
### ListingRow
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `listing` | `ListingCardData` | None | The listing, as plain data (lib/listing-card.ts): id, href and title; address, status, price ({ amount, period: "once" \| "month" }) and priceNote; values by field key; image ({ src, width, height, alt, srcset? }, ready URLs, so a search can fill the same card in the browser); badge, footStart and footEnd. Anything missing is left out, with no empty box. |
| `fields` | `ListingField[]` | None | Your fields list (lib/listing.ts). The fact strip shows each field with card not false that has a value, in list order, in its format. |
| `mode` | `string` | None | The search's mode, such as "buy" or "rent": each fact's label and price value follow the field's labels and period for it. Pass the same mode to fillListingCard() for cards a search adds. Default: each field's label, and a price once. |
| `save` | `boolean` | `true` | Shows a SaveButton on the photo's top end. It comes after the title link in the Tab order. |
| `saveList` | `string` | None | The SaveButton's list name. Default: its own, "homes". |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h3"` | Element for the title, one level under the heading above the cards. |
| `imageComponent` | `ImageComponent` | None | Your image component, for a card the server renders on its own (a home page grid). A search's cards use the plain <img> with the listing's srcset, so leave it out there. |
| `imageSizes` | `string` | None | How wide the photo shows, as its sizes attribute, for the listing's srcset or your image component, such as "(min-width: 60rem) 25rem, 100vw". |
| `ratio` | `MediaRatio` | `"3/2"` | The photo's frame, width/height. |
| `mediaClass` | `string` | None | Classes for the photo's box, which holds the status and the badge. |
| `bodyClass` | `string` | None | Classes for the text column under (or beside) the photo. |
| `priceClass` | `string` | None | Classes for the price line: the amount, "/mo" and the note. |
| `priceNoteClass` | `string` | None | Classes for the note after the price, such as your own mark for a price cut. |
| `titleClass` | `string` | None | Classes for the title. |
| `factsClass` | `string` | None | Classes for the fact strip. |
| `footClass` | `string` | None | Classes for the foot line. |
| `class` | `string` | None | More classes on the <article>, merged with cn(), so yours win on conflicts. |
Any other attribute goes on the <article>.
## Accessibility
| Key | Action |
| --- | --- |
| Tab | Moves to the card's title link, then to its Save button. |
| Enter | On the title link: opens the listing. |
| Enter or Space | On Save: saves the listing, or takes it out of the saved list. |
- An <article> whose title is its one link: a click anywhere on the card follows it, and the focus ring goes round the whole card. The title alone names the link.
- The Save button comes right after the title link in the Tab order, and sits above the link, so it is its own control (see SaveButton).
- The facts are a description list: a screen reader reads each term with its value ("Beds, 3").
- The status and the badge on the photo are text in their own fill, so they read on any photo. Write the photo's alt, or "" when the title says it all.
- A missing fact, price or line leaves no empty cell and never prints "undefined".
- Tap targets: Save is 44px round.
ListingRow
FreeThe same listing as a wide row, for a list beside a map or a short list on a page.
- File
- ListingRow.astro
- Group
- Data display
- Kind
- Interactive: inline script
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
One row
From 36rem of card, the photo at the start, about 2 to 3 against the text; from 48rem the facts beside the price and the title. Narrower, it is the card, one column.
This preview did not load.
main.astro
examples/listingrow/main.astro
---
import ListingRow from "@astronomic-dev/ui/components/ListingRow.astro";
import { fields, listings } from "../_data/vega.ts";
---
<div class="p-6">
<ListingRow listing={listings[2]} fields={fields} imageSizes="(min-width: 36rem) 20rem, 100vw" />
</div>A short list
Rows in a list, one under another, as beside a map or on an agent's page.
This preview did not load.
list.astro
examples/listingrow/list.astro
---
import ListingRow from "@astronomic-dev/ui/components/ListingRow.astro";
import { fields, listings } from "../_data/vega.ts";
---
<ul role="list" class="m-0 grid list-none gap-cards p-6">
{
listings.slice(3, 6).map((home) => (
<li>
<ListingRow listing={home} fields={fields} imageSizes="(min-width: 36rem) 20rem, 100vw" />
</li>
))
}
</ul>Minimal · Light