forked from NYUCCL/talk_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slide-top.vue
202 lines (183 loc) · 6.06 KB
/
slide-top.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!-- an example header for pages -->
<script setup>
import NYUlogo from './components/nyulogo.vue'
import { onMounted, ref, watch } from 'vue'
import { useSlideContext } from '@slidev/client'
const { $slidev, $frontmatter } = useSlideContext()
//const frontmatter = ref('')
const default_tr_color = 'color-neutral-500'
const default_tl_color = 'fill-black'
const default_tl_color2 = 'fill-white'
const brand_tr_color = ref(default_tr_color)
const brand_tl_color = ref(default_tl_color)
const brand_tl_color2 = ref(default_tl_color2)
function process_top_left_colors(color, force = false) {
if (color) {
if (color == 'black') {
brand_tl_color.value = `fill-gray-100`
brand_tl_color2.value = `fill-gray-900`
} else if (color == 'navy') {
brand_tl_color.value = `fill-gray-300`
brand_tl_color2.value = `fill-navy-900`
} else if (color == 'white') {
brand_tl_color.value = default_tl_color
brand_tl_color2.value = default_tl_color2
} else if (color == 'dark') {
brand_tl_color.value = `fill-gray-100`
brand_tl_color2.value = `fill-gray-900`
} else if (color == 'light') {
brand_tl_color.value = default_tl_color
brand_tl_color2.value = default_tl_color2
} else if (color.includes('-light')) {
const parts = color.split('-')
if (force) {
brand_tl_color.value = `fill-${parts[0]}-100`
brand_tl_color2.value = `fill-${parts[0]}-500`
} else {
brand_tl_color.value = `fill-${parts[0]}-500`
brand_tl_color2.value = `fill-${parts[0]}-100`
}
} else {
if (force) {
brand_tl_color.value = `fill-${color}-500`
brand_tl_color2.value = `fill-${color}-100`
} else {
brand_tl_color.value = `fill-${color}-100`
brand_tl_color2.value = `fill-${color}-500`
}
}
}
}
function process_top_right_colors(color, force = false) {
if (color) {
if (color == 'black') {
brand_tr_color.value = `text-gray-100`
} else if (color == 'navy') {
brand_tr_color.value = `text-gray-300`
} else if (color == 'white') {
brand_tr_color.value = default_tr_color
} else if (color == 'dark') {
brand_tr_color.value = `text-gray-100`
} else if (color == 'light') {
brand_tr_color.value = default_tr_color
} else if (color.includes('-light')) {
const parts = color.split('-')
if (force) {
brand_tr_color.value = `text-${parts[0]}-100`
} else {
brand_tr_color.value = `text-${parts[0]}-500`
}
} else {
if (force) {
brand_tr_color.value = `text-${color}-500`
} else {
brand_tr_color.value = `text-${color}-100`
}
}
}
}
function checkvars() {
//$frontmatter = $slidev.nav.slides[$slidev.nav.currentPage - 1].meta.slide.frontmatter
//console.log($frontmatter)
// process left
// set default
if ($frontmatter.brand_tl === undefined) {
$frontmatter.brand_tl = 'auto_false'
}
brand_tl_color.value = default_tl_color
brand_tl_color2.value = default_tl_color2
// if a color provided go with that
if ($frontmatter.brand_tl_color) {
process_top_left_colors($frontmatter.brand_tl_color, true)
} else if ($frontmatter.color) {
// depending on slide type
if ($frontmatter.layout == 'side-title') {
if ($frontmatter.side && $frontmatter.side == 'left') {
process_top_left_colors($frontmatter.color)
}
}
if ($frontmatter.layout == 'cover' || $frontmatter.layout == 'section') {
process_top_left_colors($frontmatter.color)
}
} else if ($frontmatter.layout == 'end') {
process_top_left_colors('black')
}
// otherwise check slide type
// otherwise go with default
// set default
if ($frontmatter.brand_tr === undefined) {
$frontmatter.brand_tr = 'auto_true'
}
brand_tr_color.value = default_tr_color
// if a color provided go with that
if ($frontmatter.brand_tr_color) {
const pattern = /^[A-Za-z]+-[A-Za-z]+-\d+$/
if (pattern.test($frontmatter.brand_tr_color)) {
brand_tr_color.value = $frontmatter.brand_tr_color
} else {
process_top_right_colors($frontmatter.brand_tr_color, true)
}
} else if ($frontmatter.color) {
// depending on slide type
if ($frontmatter.layout == 'side-title') {
if ($frontmatter.side && $frontmatter.side == 'right') {
process_top_right_colors($frontmatter.color)
}
}
if ($frontmatter.layout == 'cover' || $frontmatter.layout == 'section') {
process_top_right_colors($frontmatter.color)
}
} else if ($frontmatter.layout == 'end') {
process_top_right_colors('black')
}
}
//watch($slidev.nav, () => checkvars())
onMounted(() => checkvars())
</script>
<template>
<div
v-if="
($frontmatter.layout == 'cover' && $frontmatter.brand_tl !== false) ||
($frontmatter.layout == 'section' && $frontmatter.brand_tl !== false) ||
($frontmatter.layout == 'intro' && $frontmatter.brand_tl !== false) ||
($frontmatter.layout == 'end' && $frontmatter.brand_tl !== false) ||
$frontmatter.brand_tl == true ||
$frontmatter.brand_tl == 'auto_true'
"
class="absolute top-4 left-11 p-3 pr-5 border.b-1 font-size-2 font-mono color-gray-500 width-full text-right"
>
<NYUlogo :color="brand_tl_color" :color2="brand_tl_color2" />
</div>
<div
v-if="
$frontmatter.brand_tr == true ||
($frontmatter.brand_tr == 'auto_true' &&
$frontmatter.layout != 'image' &&
$frontmatter.layout != 'image-right' &&
$frontmatter.layout != 'iframe-right' &&
$frontmatter.layout != 'iframe' &&
$frontmatter.layout != 'top-title' &&
$frontmatter.layout != 'top-title-two-cols')
"
class="absolute top-3 right-2 p-3 pr-3 border.b-1 z-10 font-size-3 font-mono width-full text-right"
:class="brand_tr_color"
>
<a href="https://guydavidson.me"> <uim-cube /> guydavidson.me </a>
</div>
</template>
<style scoped>
img {
height: 2.3rem;
opacity: 0.9;
}
html.dark {
/* dark mode css here */
img {
filter: invert(1);
opacity: 1;
}
.sidebar {
background-color: #5b5b5b;
}
}
</style>