Overview
The types module (src/utils/types.ts) exports TypeScript type definitions used throughout stevenson.space for type-safe schedule management, theme configuration, and period tracking.
Schedule Types
Schedule
A schedule can be either single-day (like most schedules) or multi-day (like Finals week).
type Schedule = SingleDaySchedule | MultiDaySchedule ;
The name of the schedule mode (e.g., “Normal”, “Half Periods”)
Whether this is a user-defined custom schedule
Array of start times in 24-hour format (e.g., [“8:00”, “9:00”])
Array of end times in 24-hour format
Array of period names (e.g., [“1”, “2”, “3”])
The name of the schedule mode
Whether this is a user-defined custom schedule
start
string[] | string[][]
required
Start times - can be 2D array for multi-day schedules
end
string[] | string[][]
required
End times - can be 2D array for multi-day schedules
periods
string[] | string[][]
required
Period names - can be 2D array for multi-day schedules
ScheduleCollection
Groups multiple schedule modes together for a specific date range.
The type of schedule (e.g., “Standard Schedule”, “Late Arrival”)
Whether this is a special schedule
Array of date patterns this schedule applies to
Array of schedule modes available for this schedule type
Optional alternative names for this schedule
CustomSchedules
Format for storing user-defined schedules in localStorage.
type CustomSchedules = Record < string , Schedule []>
Example:
const customSchedules : CustomSchedules = {
"My Schedule" : [
{
name: "Normal" ,
isCustom: true ,
start: [ "8:00" , "9:30" , "11:00" ],
end: [ "9:20" , "10:50" , "12:20" ],
periods: [ "1" , "2" , "3" ]
}
]
};
Period Types
Period
Represents a class period, passing period, or before/after school time.
type Period =
| { beforeSchool : true , afterSchool ?: false }
| { beforeSchool ?: false , afterSchool : true }
| { beforeSchool ?: false , afterSchool ?: false , name : string , start : string , end : string }
The Period type is a discriminated union with three variants: Before School: Indicates time before first period
After School: Indicates time after last period
During School: Period name (e.g., “1”, “2”) or ”!Passing” for passing periods
Start time in 24-hour format (e.g., “8:00”)
End time in 24-hour format (e.g., “9:20”)
Example Usage:
import { Period } from '@/utils/types' ;
// Before school
const beforeSchool : Period = { beforeSchool: true };
// Regular period
const period1 : Period = {
name: "1" ,
start: "8:00" ,
end: "9:20"
};
// Passing period (prefixed with !)
const passing : Period = {
name: "!Passing" ,
start: "9:20" ,
end: "9:30"
};
Theme Types
Theme
Defines the complete structure for a visual theme.
Display name of the theme
visibility
'show' | 'draft' | 'hide'
required
Controls whether theme appears in theme selector
timing
'always' | 'never' | 'season' | string
required
When to recommend this theme
Homepage message advertising the theme
Date pattern for seasonal themes (e.g., “12/1-12/31”)
Complete styling configuration (see ThemeStyling below)
ThemeStyling
Defines all visual styling properties for a theme.
Background color (CSS color value)
Secondary background color for cards and panels
Accent color for interactive elements
Desktop background image URL
Mobile background image URL
Color of the bar below the header
Text color for regular icon cards
Text color for inverted icon cards
Array of particle image URLs
Number of particles to display
Horizontal drift strength
Example Theme:
import { Theme } from '@/utils/types' ;
const winterTheme : Theme = {
metadata: {
name: "Winter Wonderland" ,
author: "Student Council"
},
visibility: "show" ,
recommended: {
timing: "season" ,
message: "Get into the winter spirit!"
},
seasonalDates: "12/1-2/28" ,
styling: {
base: "dark" ,
background: "#1a2332" ,
accent: "#64b5f6" ,
text: {
primary: "#ffffff" ,
secondary: "#b0bec5" ,
tertiary: "#78909c"
},
particles: {
images: [ "/images/snowflake.png" ],
speed: 2 ,
count: 50
}
}
};
Utility Types
NonEmptyArray
Ensures an array has at least one element.
type NonEmptyArray < T > = { 0 : T } & T [];
MapStateToComputed
Helper type for mapping Vuex/Pinia state to computed properties.
type MapStateToComputed < S > = {
[ K in keyof S ] : () => S [ K ]
}
Example:
import { MapStateToComputed } from '@/utils/types' ;
interface MyState {
count : number ;
name : string ;
}
// Creates: { count: () => number, name: () => string }
type MyComputed = MapStateToComputed < MyState >;
Usage in Components
import { Schedule , Period , Theme } from '@/utils/types' ;
import { useScheduleStore } from '@/stores/schedules' ;
export default {
setup () {
const scheduleStore = useScheduleStore ();
// Type-safe schedule access
const currentSchedule : Schedule = scheduleStore . currentSchedule ;
// Type-safe period checking
const checkPeriod = ( period : Period ) => {
if ( period . beforeSchool ) {
console . log ( 'Before school' );
} else if ( period . afterSchool ) {
console . log ( 'After school' );
} else {
console . log ( `Period ${ period . name } : ${ period . start } - ${ period . end } ` );
}
};
}
} ;