# Shopify Place

A place with a map, rating, hours and actions.

Build a Place in this project that looks and behaves like Shopify's. Measured from the running Shopify app (admin.shopify.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.

Fidelity: Concept, not a real feature. Designed from Sidekick chat card, Polaris star rating and buttons. Sidekick has no place card. A map strip with a critical pin over a chat card, with the rating, hours in success or critical text and Polaris primary and secondary buttons.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--p-color-bg-surface` | `#fff` | `#1a1a1a` |
| `--p-color-bg-surface-secondary` | `#f7f7f7` | `#282828` |
| `--p-color-icon` | `#101010` | `#dcdcdc` |
| `--p-color-icon-critical-accent` | `#e2221a` | `#f78086` |
| `--p-color-text` | `#101010` | `#eee` |
| `--p-color-text-critical-accent` | `rgba(206,31,24,1)` | `#f78086` |
| `--p-color-text-secondary` | `rgba(74,74,74,1)` | `#aaa` |
| `--p-color-text-success-accent` | `rgba(58,126,9,1)` | `#2ced83` |
| `--p-font-family-sans` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` |
| `--p-font-size-300` | `.75rem` | `.75rem` |
| `--p-font-weight-medium` | `500` | `500` |
| `--p-font-weight-semibold` | `600` | `600` |
| `--p-space-025` | `.0625rem` | `.0625rem` |
| `--p-space-050` | `.125rem` | `.125rem` |
| `--p-space-200` | `.5rem` | `.5rem` |
| `--p-space-300` | `.75rem` | `.75rem` |
| `--p-space-800` | `2rem` | `2rem` |
| `--p-font-size-325` | `.8125rem` | `.8125rem` |
| `--p-font-line-height-400` | `1rem` | `1rem` |
| `--p-font-line-height-500` | `1.25rem` | `1.25rem` |
| `--p-space-250` | `.625rem` | `.625rem` |
| `--p-shadow-100` | `0rem .3125rem .3125rem -.15625rem rgba(0,0,0,.03), 0rem .1875rem .1875rem -.09375rem #00000005, 0rem .125rem .125rem -.0625rem #00000005, 0rem .0625rem .0625rem -.03125rem #00000008, 0rem .03125rem .03125rem 0rem #0000000a, 0rem 0rem 0rem .0625rem #0000000f` | `0rem 0rem 0rem .0625rem #dcdcdc24, 0rem .0625rem 0rem 0rem #ffffff08, 0rem .15625rem .03125rem 0rem #00000057, 0rem .25rem .25rem -.09375rem #0000001f, 0rem .3125rem .3125rem -.15625rem #0000003d` |
| `--sidekick-chat-card-radius` | `.625rem` | `.625rem` |

## CSS

Scoped under `[data-style="shopify"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="shopify"] {
  .ui-place {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: var(--p-space-025);
    border-radius: var(--sidekick-chat-card-radius);
    background-color: var(--p-color-bg-surface);
    box-shadow: var(--p-shadow-100);
    color: var(--p-color-text);
    font-family: var(--p-font-family-sans);
    font-size: var(--p-font-size-300);
    line-height: var(--p-font-line-height-400);
    letter-spacing: normal;
  }

  .ui-place-media {
    position: relative;
    display: block;
    height: 8rem;
    overflow: hidden;
    border-radius: calc(var(--sidekick-chat-card-radius) - var(--p-space-025));
    background-color: var(--p-color-bg-surface-secondary);

    & > img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  &[data-theme="dark"] .ui-place-media > img {
    filter: brightness(0.75) saturate(0.85);
  }

  .ui-place-pin {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    display: flex;
    color: var(--p-color-icon-critical-accent);
    translate: -50% -100%;
    filter: drop-shadow(0 var(--p-space-025) var(--p-space-050) #0000004d);

    & svg {
      width: var(--p-space-800);
      height: var(--p-space-800);
    }
  }

  .ui-place-content {
    display: flex;
    flex-direction: column;
    gap: var(--p-space-050);
    min-width: 0;
    padding: var(--p-space-250) var(--p-space-300) 0;
  }

  .ui-place-title {
    color: var(--p-color-text);
    font-size: var(--p-font-size-325);
    font-weight: var(--p-font-weight-semibold);
    line-height: var(--p-font-line-height-500);
  }

  .ui-place-rating {
    display: inline-flex;
    align-items: center;
    gap: var(--p-space-050);
    color: var(--p-color-text-secondary);

    & svg {
      flex-shrink: 0;
      width: var(--p-space-300);
      height: var(--p-space-300);
      color: var(--p-color-icon);
    }
  }

  .ui-place-rating-value {
    color: var(--p-color-text);
    font-weight: var(--p-font-weight-medium);
  }

  .ui-place-meta,
  .ui-place-address {
    overflow: hidden;
    color: var(--p-color-text-secondary);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .ui-place-hours {
    color: var(--p-color-text-critical-accent);
    font-weight: var(--p-font-weight-medium);

    &[data-open] {
      color: var(--p-color-text-success-accent);
    }
  }

  .ui-place-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--p-space-200);
    padding: var(--p-space-300);
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import type { ComponentProps } from "react";
import { join } from "./utils";

function Root({ className, ...props }: ComponentProps<"article">) {
  return <article className={join("ui-place", className)} {...props} />;
}

type MediaProps = ComponentProps<"span"> & { src: string; alt?: string };

function Media({ className, src, alt = "", children, ...props }: MediaProps) {
  return (
    <span className={join("ui-place-media", className)} {...props}>
      <img src={src} alt={alt} />
      {children}
    </span>
  );
}

function Pin({ className, ...props }: ComponentProps<"span">) {
  return (
    <span className={join("ui-place-pin", className)} aria-hidden {...props}>
      <svg viewBox="0 0 16 16" fill="currentColor">
        <path d="M8 1.5a4.75 4.75 0 0 0-4.75 4.75c0 3.4 4.75 8.25 4.75 8.25s4.75-4.85 4.75-8.25A4.75 4.75 0 0 0 8 1.5zm0 6.5a1.75 1.75 0 1 1 0-3.5 1.75 1.75 0 0 1 0 3.5z" />
      </svg>
    </span>
  );
}

const part = (name: string) =>
  function Part({ className, ...props }: ComponentProps<"div">) {
    return <div className={join(`ui-place-${name}`, className)} {...props} />;
  };

const text = (name: string) =>
  function Text({ className, ...props }: ComponentProps<"span">) {
    return <span className={join(`ui-place-${name}`, className)} {...props} />;
  };

type RatingProps = Omit<ComponentProps<"span">, "children"> & { value: number; count?: number };

function Rating({ className, value, count, ...props }: RatingProps) {
  return (
    <span className={join("ui-place-rating", className)} aria-label={`Rated ${value} out of 5`} {...props}>
      <span className="ui-place-rating-value" aria-hidden>
        {value.toFixed(1)}
      </span>
      <svg viewBox="0 0 16 16" fill="currentColor" aria-hidden>
        <path d="M8 1.75l1.9 3.95 4.35.6-3.17 3.02.78 4.3L8 11.55 4.14 13.62l.78-4.3L1.75 6.3l4.35-.6z" />
      </svg>
      {count === undefined ? null : (
        <span className="ui-place-rating-count" aria-hidden>
          ({count.toLocaleString("en-US")})
        </span>
      )}
    </span>
  );
}

type HoursProps = ComponentProps<"span"> & { open?: boolean };

function Hours({ className, open = true, ...props }: HoursProps) {
  return <span className={join("ui-place-hours", className)} data-open={open || undefined} {...props} />;
}

export const Place = {
  Root,
  Media,
  Pin,
  Content: part("content"),
  Title: text("title"),
  Rating,
  Meta: text("meta"),
  Address: text("address"),
  Hours,
  Actions: part("actions"),
};
```

## Example

```tsx
import { Button, Place } from "@replicas/ui";

const map = `data:image/svg+xml,${encodeURIComponent(
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 160"><rect width="480" height="160" fill="#eef0eb"/><path d="M0 52h480M0 118h480M96 0v160M248 0v160M392 0v160" stroke="#fff" stroke-width="10"/><path d="M0 86c120-20 240 30 480-6" stroke="#fff" stroke-width="16" fill="none"/><path d="M0 86c120-20 240 30 480-6" stroke="#f6d77a" stroke-width="6" fill="none"/><rect x="268" y="14" width="104" height="26" rx="4" fill="#cfe5c4"/><rect x="116" y="130" width="112" height="22" rx="4" fill="#cfe5c4"/><path d="M412 0h68v40h-68z" fill="#c9dcef"/></svg>',
)}`;

export default function PlaceDemo() {
  return (
    <Place.Root style={{ width: "100%", maxWidth: 480 }}>
      <Place.Media src={map} alt="Map around Tartine Bakery">
        <Place.Pin />
      </Place.Media>
      <Place.Content>
        <Place.Title>Tartine Bakery</Place.Title>
        <Place.Rating value={4.6} count={2140} />
        <Place.Meta>Bakery · $$ · 0.8 km</Place.Meta>
        <Place.Address>600 Guerrero St, San Francisco</Place.Address>
        <Place.Hours open>Open · Closes 7 PM</Place.Hours>
      </Place.Content>
      <Place.Actions>
        <Button variant="primary" size="small">
          Directions
        </Button>
        <Button size="small">Call</Button>
        <Button size="small">Website</Button>
      </Place.Actions>
    </Place.Root>
  );
}
```

## Foundations

The rest of the Shopify style, as a skill: https://replicas.raphaelsalaja.com/skills/shopify/SKILL.md