Switch from equicolor to unique-colors

As `equicolor` was throwing some TypeScript errors and is more
complicated than required
This commit is contained in:
Adam Goldsmith 2021-11-12 13:42:57 -05:00
parent 087601ba31
commit 9e04082b5b
3 changed files with 7 additions and 6 deletions

View File

@ -19,9 +19,9 @@
"@fullcalendar/icalendar": "^5.10.1", "@fullcalendar/icalendar": "^5.10.1",
"@fullcalendar/timegrid": "^5.6.0", "@fullcalendar/timegrid": "^5.6.0",
"@fullcalendar/vue3": "^5.10.0", "@fullcalendar/vue3": "^5.10.0",
"equicolor": "^1.1.0",
"ical.js": "github:ekreative/ical.js#var-ical", "ical.js": "github:ekreative/ical.js#var-ical",
"intl": "^1.2.5", "intl": "^1.2.5",
"unique-colors": "^1.0.1",
"vue": "^3.2.20" "vue": "^3.2.20"
} }
} }

View File

@ -4,7 +4,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, Ref } from 'vue'; import { ref, Ref } from 'vue';
import equicolor from 'equicolor/src/Equicolor'; import {unique_colors} from 'unique-colors';
import '@fullcalendar/core/vdom'; // solve problem with Vite import '@fullcalendar/core/vdom'; // solve problem with Vite
import FullCalendar, { import FullCalendar, {
@ -26,10 +26,7 @@ const calendars: { [key: string]: string } = {
room_reservations: 'f4ro53uklj2u6pr0se7ucskm6g@group.calendar.google.com', room_reservations: 'f4ro53uklj2u6pr0se7ucskm6g@group.calendar.google.com',
}; };
const colors: string[] = equicolor.findNextColors( const colors: string[] = unique_colors(Object.keys(calendars).length);
['#ffffff', '#000000'],
Object.keys(calendars).length
);
const calendarOptions: CalendarOptions = { const calendarOptions: CalendarOptions = {
plugins: [timeGridPlugin, dayGridPlugin, iCalendarPlugin], plugins: [timeGridPlugin, dayGridPlugin, iCalendarPlugin],

4
src/unique-colors.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare module 'unique-colors' {
function unique_colors(n: number): string[];
function unique_shuffled_colors(n: number): string[];
}