1+ <script setup lang="ts">
2+ import { ref , onMounted } from ' vue'
3+
4+ const THEMES = [
5+ { name: ' No CSS' , url: ' ' },
6+ { name: ' Chimera' , url: ' https://unpkg.com/chimeracss/build/chimera.css' },
7+ { name: ' Chimera Dark' , url: ' https://unpkg.com/chimeracss/build/chimera-dark.css' },
8+ { name: ' Chimera Golden' , url: ' https://unpkg.com/chimeracss/build/chimera-golden.css' },
9+ { name: ' Chimera Autumn' , url: ' https://unpkg.com/chimeracss/build/chimera-autumn.css' },
10+ { name: ' Chimera Blues' , url: ' https://unpkg.com/chimeracss/build/chimera-blues.css' },
11+ { name: ' Chimera Plain' , url: ' https://unpkg.com/chimeracss/build/chimera-plain.css' },
12+ { name: ' Chimera Nightsky' , url: ' https://unpkg.com/chimeracss/build/chimera-nightsky.css' }
13+ ]
14+
15+ const currentTheme = ref (THEMES [1 ].url )
16+
17+ onMounted (() => {
18+ // Preload all theme stylesheets
19+ THEMES .forEach (theme => {
20+ if (theme .url ) {
21+ const link = document .createElement (' link' )
22+ link .rel = ' preload'
23+ link .as = ' style'
24+ link .href = theme .url
25+ document .head .appendChild (link )
26+ }
27+ })
28+
29+ // Set initial theme
30+ const stylesheet = document .getElementById (' stylesheet' ) as HTMLLinkElement
31+ if (stylesheet ) {
32+ stylesheet .href = currentTheme .value
33+ }
34+ })
35+
36+ function changeTheme(themeUrl : string ) {
37+ const stylesheet = document .getElementById (' stylesheet' ) as HTMLLinkElement
38+ if (stylesheet ) {
39+ stylesheet .href = themeUrl
40+ currentTheme .value = themeUrl
41+ }
42+ }
43+ </script >
44+
45+ <template >
46+ <div >
47+ <h2 >Change Theme</h2 >
48+ <p >
49+ Click on one of the links below to change the theme of this page.
50+ The only thing that will change is the stylesheet, so you can see how the different themes look.
51+ It is also possible to create your own theme, and use it on this page, or on your own website.
52+ <a href =" https://github.com/MarkusJohansen/ChimeraCSS/blob/main/GUIDE.md" >Here</a > is a guide on
53+ how chimera works as well as how to create your own themes.
54+ </p >
55+ <ul >
56+ <li v-for =" theme in THEMES" :key =" theme.name" >
57+ <a
58+ href =" #"
59+ @click.prevent =" changeTheme(theme.url)"
60+ :style =" { fontWeight: theme.url === currentTheme ? 'bold' : 'normal' }"
61+ >
62+ {{ theme.name }}
63+ </a >
64+ </li >
65+ </ul >
66+ <hr />
67+ </div >
68+ </template >
0 commit comments