# Productivity Dashboard

A daily overview in one card. The tabs switch the time range: the energy percentage rolls digit by digit, the bars spring to their new heights and the peak tooltip follows the tallest bar. Open the `⋯` menu on Focus to pick a preset; the timer starts at once, the ring fills as time passes and the sound waveform comes alive. The expand button on Sleep grows the tile into a full-width sleep-stage chart that draws itself; close it to collapse back. The demo plays this tour on its own until you touch it.

<demo-productivity-dashboard>



</demo-productivity-dashboard>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/productivity-dashboard.json"
```

## Usage

```vue
<script setup lang="ts">
  import { ref } from 'vue';
  import ProductivityDashboard from '~/components/ui/productivity-dashboard/ProductivityDashboard.vue';
  import type { ProductivityRange } from '~/components/ui/productivity-dashboard/types';

  const range = ref('today');
  const expanded = ref(false);

  const ranges: ProductivityRange[] = [
    {
      value: 'today',
      label: 'Today',
      average: 78,
      caption: 'Average today',
      delta: '+6% vs yesterday',
      trend: 'up',
      bars: [
        { label: '6a', value: 24 },
        { label: '12p', value: 80 },
        { label: '6p', value: 68 },
      ],
    },
  ];
</script>

<template>
  <ProductivityDashboard
    v-model:range="range"
    v-model:expanded="expanded"
    name="Mira"
    date="Tuesday, 17 November"
    :ranges="ranges"
  />
</template>
```

Every data prop has a default, so `<ProductivityDashboard />` renders the full card. The defaults are exported as `DEFAULT_RANGES`, `DEFAULT_SLEEP`, `DEFAULT_SESSIONS` and `DEFAULT_SOUND` if you want to change one field.

## Props

<table>
<thead>
  <tr>
    <th>
      Prop
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        range
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      first range
    </td>
    
    <td>
      <code>
        v-model:range
      </code>
      
      . The active tab value.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        expanded
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      <code>
        v-model:expanded
      </code>
      
      . Shows the full sleep view over the grid.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Mira'
      </code>
    </td>
    
    <td>
      Person greeted in the header.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        greeting
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Good evening'
      </code>
    </td>
    
    <td>
      Text before the name.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        date
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Tuesday, 17 November'
      </code>
    </td>
    
    <td>
      Line under the greeting.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        avatar
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      Avatar image URL. Initials show when empty.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ranges
      </code>
    </td>
    
    <td>
      <code>
        ProductivityRange[]
      </code>
    </td>
    
    <td>
      three ranges
    </td>
    
    <td>
      Tabs and energy data, one entry per tab.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        sleep
      </code>
    </td>
    
    <td>
      <code>
        ProductivitySleep
      </code>
    </td>
    
    <td>
      sample night
    </td>
    
    <td>
      Sleep tile, dot matrix and hypnogram data.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        sessions
      </code>
    </td>
    
    <td>
      <code>
        ProductivitySession[]
      </code>
    </td>
    
    <td>
      Pomodoro, Deep work, …
    </td>
    
    <td>
      Focus presets in the menu. The first one is the value after <strong>
        Stop
      </strong>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        sound
      </code>
    </td>
    
    <td>
      <code>
        ProductivitySound
      </code>
    </td>
    
    <td>
      <code>
        Rain on glass
      </code>
    </td>
    
    <td>
      Title and subtitle of the sound player.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unread
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Shows the dot on the bell button.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        class
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      Extra classes for the root element.
    </td>
  </tr>
</tbody>
</table>

## Data shapes

<table>
<thead>
  <tr>
    <th>
      Type
    </th>
    
    <th>
      Fields
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ProductivityRange
      </code>
    </td>
    
    <td>
      <code>
        value
      </code>
      
      , <code>
        label
      </code>
      
      , <code>
        average
      </code>
      
       (0–100), <code>
        caption
      </code>
      
      , <code>
        delta
      </code>
      
      , <code>
        trend
      </code>
      
       (<code>
        'up' | 'down'
      </code>
      
      ), <code>
        bars
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ProductivityBar
      </code>
    </td>
    
    <td>
      <code>
        label
      </code>
      
      , <code>
        value
      </code>
      
       (0–100). The tallest bar gets the tooltip.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ProductivitySleep
      </code>
    </td>
    
    <td>
      <code>
        duration
      </code>
      
      , <code>
        summary
      </code>
      
      , <code>
        period
      </code>
      
      , <code>
        columns
      </code>
      
       (0–4 lit dots each), <code>
        stats
      </code>
      
      , <code>
        steps
      </code>
      
      , <code>
        ticks
      </code>
      
      , <code>
        insight
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ProductivitySleepStep
      </code>
    </td>
    
    <td>
      <code>
        stage
      </code>
      
       (0 deep, 1 light, 2 REM, 3 awake), <code>
        minutes
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ProductivityTick
      </code>
    </td>
    
    <td>
      <code>
        at
      </code>
      
       (minutes after the start of the night), <code>
        label
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ProductivitySession
      </code>
    </td>
    
    <td>
      <code>
        id
      </code>
      
      , <code>
        label
      </code>
      
      , <code>
        minutes
      </code>
      
      , <code>
        icon
      </code>
      
       (Lucide name without the prefix)
    </td>
  </tr>
</tbody>
</table>

## Events

<table>
<thead>
  <tr>
    <th>
      Event
    </th>
    
    <th>
      Payload
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        start
      </code>
    </td>
    
    <td>
      <code>
        ProductivitySession
      </code>
    </td>
    
    <td>
      A focus session started.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        stop
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      The running session was stopped.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        complete
      </code>
    </td>
    
    <td>
      <code>
        ProductivitySession
      </code>
    </td>
    
    <td>
      The timer reached <code>
        00:00
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        open-energy
      </code>
    </td>
    
    <td>
      <code>
        ProductivityRange
      </code>
    </td>
    
    <td>
      The chevron on the Energy tile was clicked.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        notifications
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      The bell button was clicked.
    </td>
  </tr>
</tbody>
</table>

## Methods

Call these through a template ref: `start(id?)`, `stop()`, `select(id)`, `openMenu()`, `closeMenu()`, `expand()`, `collapse()` and `setRange(value)`.

## Accessibility

- The range switch is a `tablist`. Arrow keys, Home and End move between tabs, and the Energy tile is the `tabpanel`.
- The Focus menu is a `menu` of `menuitemradio` items. Arrow keys move, Enter selects, Escape closes and returns focus to the trigger.
- The timer uses `role="timer"`, and the sound status is announced through `aria-live`.
- The expanded sleep view is labelled as a dialog. Escape or the close button collapses it, and focus moves between the expand and close buttons.
- Charts have text labels for screen readers. With reduced motion on, every transition is instant and the waveform stays still.
