# Desk Computer

An isometric late-90s desk computer drawn as one line-art SVG: a CRT on a swivel base showing a browser with a search box, a mid-tower with a CD-ROM and floppy drive, a 104-key keyboard, a ball mouse on its pad, a speaker and a CD-R in its jewel case. Focus it and type: the keys go down and the text lands in the search box, and Enter searches while the hard-drive LED flickers. Drag the mouse around its pad and its cable follows while the cursor moves on the screen. Click the jewel case and the tray slides out, the disc flies in and AutoPlay opens; click the drive to eject it. Escape or the monitor's power button collapses the picture to a line and a dot. It assembles itself on arrival and on every theme change, and while nobody touches it, it gives itself a tour.

<demo-desk-computer>



</demo-desk-computer>

## Installation

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

The drawing is about 490 KB of SVG, so it is fetched at mount instead of shipped in your bundle. Save [desk-computer.svg](https://nxui.geoql.in/library/desk-computer.svg) to `public/library/desk-computer.svg`, or point `src` at wherever you serve it.

## Usage

```vue
<script setup lang="ts">
  import { computed } from 'vue';
  import DeskComputer from '~/components/ui/desk-computer/DeskComputer.vue';

  const colorMode = useColorMode();
  const theme = computed(() => (colorMode.value === 'dark' ? 'dark' : 'light'));
</script>

<template>
  <DeskComputer :theme="theme" src="/library/desk-computer.svg" />
</template>
```

Without `fill` it keeps the drawing's own 1000:760 shape at the width of its container. With `fill` it covers its container edge to edge and centres the figure in it.

## Props

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

<tbody>
  <tr>
    <td>
      <code>
        theme
      </code>
    </td>
    
    <td>
      <code>
        'light' | 'dark'
      </code>
    </td>
    
    <td>
      <code>
        'light'
      </code>
    </td>
    
    <td>
      Colour theme. Changing it replays the assembly.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        sound
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Synthesised key clicks, CRT power-on hum and power-off zap. Only your own input makes sound, never the tour.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fill
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Fill the container edge to edge instead of keeping the 1000:760 shape.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        src
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '/library/desk-computer.svg'
      </code>
    </td>
    
    <td>
      Where the drawing is served from.
    </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>

## Interactions

<table>
<thead>
  <tr>
    <th>
      Input
    </th>
    
    <th>
      Effect
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Type a character
    </td>
    
    <td>
      The key goes down and the character lands in the search box.
    </td>
  </tr>
  
  <tr>
    <td>
      Backspace
    </td>
    
    <td>
      Deletes the last character.
    </td>
  </tr>
  
  <tr>
    <td>
      Enter
    </td>
    
    <td>
      Searches: the box clears and the hard-drive LED flickers.
    </td>
  </tr>
  
  <tr>
    <td>
      Escape, or the monitor button
    </td>
    
    <td>
      Switches the screen off (collapse to a line and a dot) or on (warm-up).
    </td>
  </tr>
  
  <tr>
    <td>
      Caps Lock
    </td>
    
    <td>
      Toggles the keyboard's Caps Lock LED.
    </td>
  </tr>
  
  <tr>
    <td>
      Click a key on the drawing
    </td>
    
    <td>
      Presses that key.
    </td>
  </tr>
  
  <tr>
    <td>
      Drag the mouse
    </td>
    
    <td>
      The mouse slides on its pad, the cable follows, the cursor moves on screen.
    </td>
  </tr>
  
  <tr>
    <td>
      Click the mouse
    </td>
    
    <td>
      Clicks where the cursor is: focuses the search box or closes AutoPlay.
    </td>
  </tr>
  
  <tr>
    <td>
      Click the jewel case
    </td>
    
    <td>
      The tray opens, the disc flies in, the tray shuts and AutoPlay appears.
    </td>
  </tr>
  
  <tr>
    <td>
      Click the drive
    </td>
    
    <td>
      Ejects the disc back to its case, or opens and shuts an empty tray.
    </td>
  </tr>
</tbody>
</table>

The tour stops on your first input and resumes after nine quiet seconds.

## Accessibility

- The stage is a focusable `role="group"` with a label that lists the controls. It takes keys while focused and shows a dashed focus ring for keyboard users; the ring hides once you use a pointer.
- A polite `role="status"` live region announces what happened: "Screen on.", "Searching for …", "Loading the CD.", "AutoPlay: CD-R in drive D.", "Ejecting the CD."
- Sound needs a user gesture. The audio context is created on your first key or press, and the tour never makes a sound.
- With reduced motion the assembly, the caret blink and the tour are off, and every move jumps to its end.
- The animation loop only runs while something moves and the figure is on screen.

Ported from [Desk Computer](https://pinui.xyz/components/desk-computer) by Pin UI, MIT licence.
