# Linear Progress

Displays the status of a task that takes a long time.

Build a Progress in this project that looks and behaves like Linear's. Measured from the running Linear app (linear.app). 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/progress) if it has none.

Fidelity: Derived from Linear's switch track and accent tokens. The indeterminate animation is a guess.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--text-secondary` | `lch(19.588% 1.25 282)` | `lch(90.451% 1.2 272)` |
| `--text-tertiary` | `lch(39.176% 1.25 282)` | `lch(61.803% 1.2 272)` |
| `--accent` | `lch(53% 52.26 286.91)` | `lch(47.918% 59.303 288.421)` |
| `--switch-bg` | `lch(82.484% 0.054 281.837)` | `lch(47.575% 0.736 251.7)` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--font-weight-normal` | `450` | `450` |
| `--radius-rounded` | `9999px` | `9999px` |
| `--speed-regular` | `0.25s` | `0.25s` |
| `--ease-out-quad` | `cubic-bezier(0.25, 0.46, 0.45, 0.94)` | `cubic-bezier(0.25, 0.46, 0.45, 0.94)` |
| `--ease-in-out-quad` | `cubic-bezier(0.455, 0.03, 0.515, 0.955)` | `cubic-bezier(0.455, 0.03, 0.515, 0.955)` |

## CSS

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

```css
@keyframes linear-progress-indeterminate {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

[data-style="linear"] {
  .ui-progress {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    row-gap: 8px;
    width: 240px;
    max-width: 100%;
    font-size: var(--font-size-small);
    line-height: 1.5;
  }

  .ui-progress-label {
    font-weight: var(--font-weight-normal);
    color: var(--text-secondary);
  }

  .ui-progress-value {
    font-size: var(--font-size-mini);
    font-weight: var(--font-weight-normal);
    font-variant-numeric: tabular-nums;
    color: var(--text-tertiary);
  }

  .ui-progress-track {
    grid-column: 1 / -1;
    position: relative;
    height: 4px;
    overflow: hidden;
    border-radius: var(--radius-rounded);
    background-color: var(--switch-bg);
  }

  .ui-progress-indicator {
    border-radius: inherit;
    background-color: var(--accent);
    transition: width var(--speed-regular) var(--ease-out-quad);

    &[data-indeterminate] {
      width: 40%;
      animation: linear-progress-indeterminate 1.2s var(--ease-in-out-quad) infinite;
    }
  }


  @media (prefers-reduced-motion: reduce) {
    .ui-progress-indicator[data-indeterminate] {
      width: 100%;
      animation: none;
      opacity: 0.5;
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Progress as BaseProgress } from "@base-ui/react/progress";

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

function Root({
  className,
  variant,
  size,
  ...props
}: Omit<BaseProgress.Root.Props, "className"> & { className?: string; variant?: string; size?: string }) {
  return <BaseProgress.Root className={join("ui-progress", className)} data-variant={variant} data-size={size} {...props} />;
}

function Label({ className, ...props }: Omit<BaseProgress.Label.Props, "className"> & { className?: string }) {
  return <BaseProgress.Label className={join("ui-progress-label", className)} {...props} />;
}

function Value({ className, ...props }: Omit<BaseProgress.Value.Props, "className"> & { className?: string }) {
  return <BaseProgress.Value className={join("ui-progress-value", className)} {...props} />;
}

function Track({ className, ...props }: Omit<BaseProgress.Track.Props, "className"> & { className?: string }) {
  return (
    <BaseProgress.Track className={join("ui-progress-track", className)} {...props}>
      <BaseProgress.Indicator className="ui-progress-indicator" />
    </BaseProgress.Track>
  );
}

export const Progress = {
  Root,
  Label,
  Value,
  Track,
};
```

## Example

```tsx
import { Progress } from "@replicas/ui";

export default function ProgressDemo() {
  return (
    <Progress.Root value={16} max={25}>
      <Progress.Label>Uploading</Progress.Label>
      <Progress.Value>{(_, value) => `${value} of 25 files`}</Progress.Value>
      <Progress.Track />
    </Progress.Root>
  );
}
```

## Foundations

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