# Timetable

Source: https://ecosphere.dev/docs/layout/timetable (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

A week as a fixed time gutter plus one absolutely-positioned column per day.

`import { EcoTimetable } from "vue-ecosphere"`

## A week, with today, the now-line, a free slot and two clashes

Colour is the subject, not the state. A clash is a glyph in the corner — warning for a soft clash, danger for one that cannot ship.

Vue (vue-ecosphere):

```vue
<EcoTimetable
  card
  :days="days"
  :rows="rows"
  :events="events"
  :slots="[{ day: 1, start: '11:40', end: '12:30' }]"
  :now="{ day: 0, time: '9:52' }"
  :subjects="['Mathematics', 'Physics', 'English', 'Biology', 'Social science', 'Chemistry']"
  @select="open"
  @slot="assign"
/>

// rows: one 56px row per period; a break is a band across every day
[
  { label: "P1 · 8:00", start: "8:00", end: "8:50" },
  …
  { label: "10:30", start: "10:30", end: "10:50", break: true },
  …
]
// events: placed by start and end, coloured by subject
[
  { day: 0, start: "8:00", end: "8:50", title: "Mathematics", hint: "R. Menon · 9B-Home", subject: 1 },
  { day: 0, start: "9:40", end: "10:30", title: "Physics", hint: "S. Gupta · Lab 201", subject: 2, now: true },
  { day: 0, start: "10:50", end: "11:40", title: "Chemistry", hint: "K. Iyer · Lab 204", subject: 6, crit: true },
  { day: 2, start: "12:30", end: "13:20", title: "Mathematics", hint: "R. Menon · 9B-Home", subject: 1, warn: true },
  …
]
```

React (react-ecosphere):

```tsx
<EcoTimetable
  card
  days={days}
  rows={rows}
  events={events}
  slots={[{ day: 1, start: "11:40", end: "12:30" }]}
  now={{ day: 0, time: "9:52" }}
  subjects={["Mathematics", "Physics", "English", "Biology", "Social science", "Chemistry"]}
  onSelect={open}
  onSlot={assign}
/>

// rows: one 56px row per period; a break is a band across every day
[
  { label: "P1 · 8:00", start: "8:00", end: "8:50" },
  …
  { label: "10:30", start: "10:30", end: "10:50", break: true },
  …
]
// events: placed by start and end, coloured by subject
[
  { day: 0, start: "8:00", end: "8:50", title: "Mathematics", hint: "R. Menon · 9B-Home", subject: 1 },
  { day: 0, start: "9:40", end: "10:30", title: "Physics", hint: "S. Gupta · Lab 201", subject: 2, now: true },
  { day: 0, start: "10:50", end: "11:40", title: "Chemistry", hint: "K. Iyer · Lab 204", subject: 6, crit: true },
  { day: 2, start: "12:30", end: "13:20", title: "Mathematics", hint: "R. Menon · 9B-Home", subject: 1, warn: true },
  …
]
```

## Double periods and mid-period starts

An event spans as many rows as its times cover, and one that starts mid-period lands where it actually starts.

Vue (vue-ecosphere):

```vue
<EcoTimetable
  card
  :days="[{ label: 'Mon', date: 14 }, { label: 'Tue', date: 15 }]"
  :rows="rows"
  :events="[
    { day: 0, start: '8:00', end: '9:40', title: 'Chemistry practical', hint: 'K. Iyer · Lab 204', subject: 6 },
    { day: 1, start: '9:15', end: '10:30', title: 'Physics', hint: 'S. Gupta · Lab 201', subject: 2 },
  ]"
/>
```

React (react-ecosphere):

```tsx
<EcoTimetable
  card
  days={[{ label: "Mon", date: 14 }, { label: "Tue", date: 15 }]}
  rows={rows}
  events={[
    { day: 0, start: "8:00", end: "9:40", title: "Chemistry practical", hint: "K. Iyer · Lab 204", subject: 6 },
    { day: 1, start: "9:15", end: "10:30", title: "Physics", hint: "S. Gupta · Lab 201", subject: 2 },
  ]}
/>
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `days` | `{ label, date?, today? }[]` | — | Day columns; today takes the tinted column and accent header. |
| `rows` | `{ label?, start, end, break? }[]` | — | Periods top to bottom, one 56px row each (times as H:MM). A break row draws a ttbreak band across every day. |
| `events` | `TimetableEvent[]` | [] | { day, start, end, title, hint?, subject? 1–6, warn?, crit?, now? }. Placed by time, so a double period is one element. |
| `slots` | `{ day, start, end, label? }[]` | [] | Empty periods as dashed targets ("+ Free"). |
| `now` | `{ day, time } \| null` | null | The now-line: a 1px danger rule with a dot and the time, which never eats a click. |
| `subjects` | `string[]` | [] | Legend under the grid, in subj1…subj6 order. |
| `card` | `boolean` | false | Wrap the grid in the flush card (card › card__body, no padding) with the legend under the card, as the artifact lays it out. |
| `@select / @slot` | `event` | — | An event or an empty slot was clicked. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `days` | `{ label, date?, today? }[]` | — | Day columns; today takes the tinted column and accent header. |
| `rows` | `{ label?, start, end, break? }[]` | — | Periods top to bottom, one 56px row each (times as H:MM). A break row draws a ttbreak band across every day. |
| `events` | `TimetableEvent[]` | [] | { day, start, end, title, hint?, subject? 1–6, warn?, crit?, now? }. Placed by time, so a double period is one element. |
| `slots` | `{ day, start, end, label? }[]` | [] | Empty periods as dashed targets ("+ Free"). |
| `now` | `{ day, time } \| null` | null | The now-line: a 1px danger rule with a dot and the time, which never eats a click. |
| `subjects` | `string[]` | [] | Legend under the grid, in subj1…subj6 order. |
| `card` | `boolean` | false | Wrap the grid in the flush card (card › card__body, no padding) with the legend under the card, as the artifact lays it out. |
| `onSelect / onSlot` | `event` | — | An event or an empty slot was clicked. |
