# Thermal Provider

Thermal context provider: tracks heat and an idle, warming, combustion, cooling or depleted status from window activity, with a timed cool-down. Thermal parts fall back to a warm resting state without it.

Component · Thermal · https://01orbital.dev/docs/components/thermal-provider

## Installation

```bash
npx shadcn@latest add @01orbital/thermal-provider
```

## Usage

```tsx
"use client"

import {
  EmberLayer,
  ThermalText,
} from "@/components/thermal/thermal-atoms"
import {
  ThermalProvider,
  useThermalStatus,
} from "@/components/thermal/thermal-provider"
import { ThermalShell } from "@/components/thermal/thermal-shell"

// The provider is state; the shell, the embers and the readout make it
// visible. Move the cursor and the scene ignites; go idle and it cools.
function Status() {
  const status = useThermalStatus()
  return <ThermalText>{status}</ThermalText>
}

export default function ThermalProviderDemo() {
  return (
    <ThermalProvider cooldownDelay={3000} depletionTime={5000}>
      <ThermalShell className="grid min-h-full w-full flex-1 place-items-center">
        <EmberLayer particleCount={18} />
        <Status />
      </ThermalShell>
    </ThermalProvider>
  )
}
```

This example installs with everything it uses:

```bash
npx shadcn@latest add @01orbital/thermal-provider-demo
```

## API reference

### ThermalProvider

Holds the shared heat state for the thermal parts inside it, such as `EmberLayer` and `ThermalText`. By default, activity anywhere in the window (moving the mouse, typing, scrolling or touching) warms it through "WARMING" to "COMBUSTION"; after a pause it moves to "COOLING", then "DEPLETED".

Read and change the state with `useThermal`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `React.ReactNode` |  | The content that shares this heat state, such as an `EmberLayer` and `ThermalText`. |
| `initialStatus?` | `ThermalStatus` | `"IDLE"` | The status before any activity. Defaults to "IDLE". |
| `cooldownDelay?` | `number` | `5000` | Milliseconds without activity before the status moves to "COOLING". Defaults to 5000. |
| `depletionTime?` | `number` | `8000` | Milliseconds from "COOLING" to "DEPLETED", when heat resets to 0. Defaults to 8000. |
| `autoManage?` | `boolean` | `true` | Listens for activity in the window and runs the status changes and timers itself. Set it to false to set the status yourself through `useThermal`. Defaults to true. |
