# Visitors Dialog

A popup that opens on top of the entire page.

Build a Dialog in this project that looks and behaves like Visitors's. Measured from the running Visitors app (visitors.now). 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](https://base-ui.com/react/components/dialog) if it has none.

Fidelity: Partly measured from Visitors' shipped component classes for the dialog. 24px radius, shadow, 200ms fade and scale, overlay and padding are read from the component. No dialog opens on the public pages without saving something, so it wasn't checked live.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--fg-3` | `#666` | `#bbbcc3` |
| `--fg-4` | `#181925` | `#eaeaeb` |
| `--shadow-3` | `0px 1px 3px #0000000f, 0px 8px 16px #0000000f, 0px 0px 0px 1px #00000005` | `0px 1px 3px #0000000f, 0px 8px 16px #0000000f, 0px 0px 0px 1px #00000005` |
| `--dialog-bg` | `#fff` | `#14141f` |
| `--dialog-text` | `#666` | `#bbbcc3` |
| `--overlay` | `color-mix(in srgb, var(--fg-4) 20%, transparent)` | `color-mix(in srgb, var(--fg-4) 20%, transparent)` |
| `--font-regular` | `"OpenRunde", "Open Runde", "Inter", sans-serif` | `"OpenRunde", "Open Runde", "Inter", sans-serif` |
| `--letter-spacing` | `-0.32px` | `-0.32px` |
| `--font-size-regular` | `1rem` | `1rem` |
| `--font-size-title3` | `1.25rem` | `1.25rem` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-dialog` | `1.5rem` | `1.5rem` |
| `--ease-in-out` | `cubic-bezier(0.4, 0, 0.2, 1)` | `cubic-bezier(0.4, 0, 0.2, 1)` |
| `--duration-dialog` | `200ms` | `200ms` |

## CSS

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

```css
[data-style="visitors"] {
  .ui-dialog-backdrop {
    position: fixed;
    inset: 0;
    background-color: var(--overlay);
    transition: opacity var(--duration-dialog) var(--ease-in-out);

    &[data-starting-style],
    &[data-ending-style] {
      opacity: 0;
    }
  }

  .ui-dialog-popup {
    box-sizing: border-box;
    position: fixed;
    top: 50%;
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: min(400px, calc(100% - 2rem));
    padding: 24px;
    border-radius: var(--radius-dialog);
    corner-shape: superellipse(1.125);
    background-color: var(--dialog-bg);
    box-shadow: var(--shadow-3);
    color: var(--dialog-text);
    font-family: var(--font-regular);
    font-size: var(--font-size-regular);
    line-height: 24px;
    letter-spacing: var(--letter-spacing);
    text-align: center;
    -webkit-font-smoothing: antialiased;
    outline: none;
    translate: -50% -50%;
    transition: all var(--duration-dialog) var(--ease-in-out);

    &[data-starting-style],
    &[data-ending-style] {
      opacity: 0;
      scale: 0.95;
    }

    &[data-size="small"] {
      max-width: min(360px, calc(100% - 2rem));
    }

    &[data-size="large"] {
      max-width: min(560px, calc(100% - 2rem));
    }

    & > p {
      max-width: 320px;
      margin: 0;
      color: var(--fg-3);
    }

    & > .ui-button:last-child {
      margin-top: 10px;
    }
  }

  .ui-dialog-title {
    margin: 0;
    color: var(--fg-4);
    font-size: var(--font-size-title3);
    font-weight: var(--font-weight-medium);
    line-height: 1.2;
    text-align: center;
  }

  @media (prefers-reduced-motion: reduce) {
    .ui-dialog-popup {
      transition-property: opacity;

      &[data-starting-style],
      &[data-ending-style] {
        scale: 1;
      }
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
import { usePortalContainer } from "./portal";

const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);

function Popup({
  className,
  size,
  ...props
}: Omit<BaseDialog.Popup.Props, "className"> & { className?: string; size?: string }) {
  return (
    <BaseDialog.Portal container={usePortalContainer()}>
      <BaseDialog.Backdrop className="ui-dialog-backdrop" />
      <BaseDialog.Popup className={join("ui-dialog-popup", className)} data-size={size} {...props} />
    </BaseDialog.Portal>
  );
}

function Title({ className, ...props }: Omit<BaseDialog.Title.Props, "className"> & { className?: string }) {
  return <BaseDialog.Title className={join("ui-dialog-title", className)} {...props} />;
}

export const Dialog = {
  Root: BaseDialog.Root,
  Trigger: BaseDialog.Trigger,
  Close: BaseDialog.Close,
  Description: BaseDialog.Description,
  Popup,
  Title,
};
```

## Example

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

export default function DialogDemo() {
  return (
    <Dialog.Root>
      <Dialog.Trigger render={<Button variant="primary">Remove member</Button>} />
      <Dialog.Popup>
        <div style={{ display: "flex", flexDirection: "column", gap: 8, padding: "18px 18.5px 12px" }}>
          <Dialog.Title>Remove Jordan Lee?</Dialog.Title>
          <Dialog.Description style={{ margin: 0 }}>
            They will lose access to every project and file in the workspace.
          </Dialog.Description>
        </div>
        <div style={{ display: "flex", justifyContent: "flex-end", gap: 8, padding: "12px" }}>
          <Dialog.Close render={<Button>Cancel</Button>} />
          <Dialog.Close render={<Button variant="primary">Remove</Button>} />
        </div>
      </Dialog.Popup>
    </Dialog.Root>
  );
}
```

## Foundations

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