slidev-theme-kotlin 0.0.8 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +68 -12
- package/components/DrawnAnnotation.vue +1669 -0
- package/components/Kodee.vue +56 -24
- package/components/KodeeWrapper.vue +52 -8
- package/components/README.md +263 -0
- package/layouts/cover.vue +0 -5
- package/layouts/default.vue +0 -5
- package/layouts/intro.vue +0 -5
- package/package.json +23 -8
- package/slide-bottom.vue +30 -0
- package/styles/layout.css +16 -0
- package/.github/workflows/pages.yml +0 -54
- package/example.md +0 -221
- /package/{public → assets}/kodee-drinking.svg +0 -0
- /package/{public → assets}/kodee-greeting.svg +0 -0
- /package/{public → assets}/kodee-heart.svg +0 -0
- /package/{public → assets}/kodee-in-love.svg +0 -0
- /package/{public → assets}/kodee-jumping.svg +0 -0
- /package/{public → assets}/kodee-sitting.svg +0 -0
- /package/{public → assets}/kodee-tiny.svg +0 -0
- /package/{public → assets}/kodee-wave.svg +0 -0
- /package/{public → assets}/kodee-welcome.svg +0 -0
- /package/{public → assets}/kodee-wink.svg +0 -0
- /package/{public → assets}/kodee-winter.svg +0 -0
package/components/Kodee.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {computed} from 'vue'
|
|
2
|
+
import { computed } from 'vue'
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
5
|
variant?: string
|
|
@@ -19,29 +19,32 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
19
19
|
scale: undefined,
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
// Bundle mascot assets with the theme instead of relying on Slidev to copy a
|
|
23
|
+
// dependency's public directory into the consuming presentation.
|
|
24
|
+
const kodeeAssets = import.meta.glob('../assets/kodee-*.svg', {
|
|
25
|
+
eager: true,
|
|
26
|
+
import: 'default',
|
|
27
|
+
query: '?url',
|
|
28
|
+
}) as Record<string, string>
|
|
27
29
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const variantName = computed(() =>
|
|
31
|
+
props.variant.startsWith('kodee-') ? props.variant : `kodee-${props.variant}`,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const kodeeImage = computed(() => kodeeAssets[`../assets/${variantName.value}.svg`])
|
|
32
35
|
|
|
33
36
|
// Compute size classes and dimensions
|
|
34
37
|
const sizeConfig = computed(() => {
|
|
35
38
|
switch (props.size) {
|
|
36
39
|
case 'large':
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
40
|
+
return variantName.value === 'kodee-wave'
|
|
41
|
+
? {width: '500px', height: '500px'}
|
|
42
|
+
: {width: '600px', height: '600px'}
|
|
43
|
+
case 'medium':
|
|
44
|
+
return { width: '320px', height: '320px' }
|
|
42
45
|
case 'small':
|
|
43
46
|
default:
|
|
44
|
-
return {width: '200px', height: '200px'}
|
|
47
|
+
return { width: '200px', height: '200px' }
|
|
45
48
|
}
|
|
46
49
|
})
|
|
47
50
|
|
|
@@ -53,17 +56,46 @@ const positionStyles = computed(() => {
|
|
|
53
56
|
height: sizeConfig.value.height,
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
const
|
|
57
|
-
console.log(`[DEBUG] Kodee image: encountered ${src}`)
|
|
59
|
+
const variant = variantName.value
|
|
58
60
|
|
|
59
61
|
styles.right = '0px'
|
|
60
62
|
if (props.position === 'corner') {
|
|
61
|
-
if (
|
|
63
|
+
if (variant === 'kodee-greeting') {
|
|
62
64
|
styles.bottom = '-42px'
|
|
63
|
-
|
|
65
|
+
styles.right = '-15px'
|
|
66
|
+
} else if (variant === 'kodee-wink') {
|
|
64
67
|
styles.bottom = '-35px'
|
|
65
|
-
|
|
68
|
+
styles.right = '-20px'
|
|
69
|
+
} else if (variant === 'kodee-wave') {
|
|
66
70
|
styles.bottom = '-15px'
|
|
71
|
+
styles.right = '-15px'
|
|
72
|
+
} else if (variant === 'kodee-heart') {
|
|
73
|
+
// This artwork extends 10px farther below its viewBox center than the
|
|
74
|
+
// greeting variant that establishes the default corner baseline.
|
|
75
|
+
styles.bottom = '-32px'
|
|
76
|
+
styles.right = '-30px'
|
|
77
|
+
} else if (variant === 'kodee-jumping') {
|
|
78
|
+
styles.bottom = '-34px'
|
|
79
|
+
styles.right = '-15px'
|
|
80
|
+
} else if (variant === 'kodee-sitting') {
|
|
81
|
+
styles.bottom = '-35px'
|
|
82
|
+
styles.right = '-5px'
|
|
83
|
+
} else if (variant === 'kodee-drinking') {
|
|
84
|
+
styles.bottom = '-36px'
|
|
85
|
+
styles.right = '-31px'
|
|
86
|
+
} else if (variant === 'kodee-in-love') {
|
|
87
|
+
styles.bottom = '-31px'
|
|
88
|
+
styles.right = '-15px'
|
|
89
|
+
} else if (variant === 'kodee-welcome') {
|
|
90
|
+
styles.bottom = '-37px'
|
|
91
|
+
styles.right = '-15px'
|
|
92
|
+
} else if (variant === 'kodee-winter') {
|
|
93
|
+
styles.bottom = '-27px'
|
|
94
|
+
styles.right = '-15px'
|
|
95
|
+
} else if (variant === 'kodee-tiny') {
|
|
96
|
+
styles.height = '100px'
|
|
97
|
+
styles.width = '100px'
|
|
98
|
+
styles.bottom = '-8px'
|
|
67
99
|
} else {
|
|
68
100
|
styles.bottom = '-42px'
|
|
69
101
|
}
|
|
@@ -72,11 +104,11 @@ const positionStyles = computed(() => {
|
|
|
72
104
|
styles.right = '-5%'
|
|
73
105
|
styles.transform = 'translateY(-40%)'
|
|
74
106
|
|
|
75
|
-
if (
|
|
107
|
+
if (variant === 'kodee-greeting') {
|
|
76
108
|
styles.top = '13%'
|
|
77
|
-
} else if (
|
|
109
|
+
} else if (variant === 'kodee-wink') {
|
|
78
110
|
styles.top = '10%'
|
|
79
|
-
} else if (
|
|
111
|
+
} else if (variant === 'kodee-wave') {
|
|
80
112
|
styles.top = '16%'
|
|
81
113
|
styles.right = '3%'
|
|
82
114
|
} else {
|
|
@@ -3,22 +3,66 @@ import { computed } from 'vue'
|
|
|
3
3
|
import { useSlideContext } from '@slidev/client'
|
|
4
4
|
import Kodee from './Kodee.vue'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface KodeeConfig {
|
|
7
|
+
variant?: string
|
|
8
|
+
size?: 'small' | 'medium' | 'large'
|
|
9
|
+
position?: 'corner' | 'featured' | 'custom'
|
|
10
|
+
x?: number
|
|
11
|
+
y?: number
|
|
12
|
+
scale?: number
|
|
13
|
+
}
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
interface Props {
|
|
16
|
+
defaultVariant?: string
|
|
17
|
+
defaultSize?: KodeeConfig['size']
|
|
18
|
+
defaultPosition?: KodeeConfig['position']
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
22
|
+
defaultVariant: 'greeting',
|
|
23
|
+
defaultSize: 'small',
|
|
24
|
+
defaultPosition: 'corner',
|
|
11
25
|
})
|
|
12
26
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
const { $frontmatter, $slidev } = useSlideContext()
|
|
28
|
+
|
|
29
|
+
const defaults = computed<KodeeConfig>(() => ({
|
|
30
|
+
variant: props.defaultVariant,
|
|
31
|
+
size: props.defaultSize,
|
|
32
|
+
position: props.defaultPosition,
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
const kodeeConfig = computed<KodeeConfig | null>(() => {
|
|
36
|
+
// A slide-level value wins. Otherwise use the deck-wide theme setting.
|
|
37
|
+
const configured = $frontmatter?.kodee ?? $slidev.configs.themeConfig?.kodee
|
|
38
|
+
|
|
39
|
+
if (configured === undefined || configured === null || configured === false)
|
|
40
|
+
return null
|
|
41
|
+
|
|
42
|
+
if (configured === true)
|
|
43
|
+
return defaults.value
|
|
44
|
+
|
|
45
|
+
if (typeof configured === 'string') {
|
|
46
|
+
return {
|
|
47
|
+
...defaults.value,
|
|
48
|
+
variant: configured,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof configured === 'object') {
|
|
53
|
+
return {
|
|
54
|
+
...defaults.value,
|
|
55
|
+
...configured,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return null
|
|
16
60
|
})
|
|
17
61
|
</script>
|
|
18
62
|
|
|
19
63
|
<template>
|
|
20
64
|
<Kodee
|
|
21
|
-
v-if="
|
|
65
|
+
v-if="kodeeConfig"
|
|
22
66
|
:variant="kodeeConfig.variant"
|
|
23
67
|
:size="kodeeConfig.size"
|
|
24
68
|
:position="kodeeConfig.position"
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# `DrawnAnnotation`
|
|
2
|
+
|
|
3
|
+
One generic, hand-drawn annotation. It marks something on the slide — an
|
|
4
|
+
element, or an exact piece of text inside a code block — and, if you want,
|
|
5
|
+
connects that mark to another element or to a text label.
|
|
6
|
+
|
|
7
|
+
````html
|
|
8
|
+
<DrawnAnnotation type="circle" text="fun main" label="every program starts here" :at="1">
|
|
9
|
+
|
|
10
|
+
```kotlin
|
|
11
|
+
fun main() {
|
|
12
|
+
println("My first Kotlin program!")
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
</DrawnAnnotation>
|
|
17
|
+
````
|
|
18
|
+
|
|
19
|
+
Everything is measured in the slide's own coordinate system, so annotations
|
|
20
|
+
keep their proportions in the presenter view, in exports, and at any window
|
|
21
|
+
size. Nothing is ever drawn on a guess: an annotation that cannot find what it
|
|
22
|
+
should mark stays off the slide and [says why on the console](#when-nothing-appears).
|
|
23
|
+
|
|
24
|
+
## What to mark
|
|
25
|
+
|
|
26
|
+
| prop | default | meaning |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `type` | `underline` | short form of `source-type`; kept for existing annotations |
|
|
29
|
+
| `source-type` | `type` | source shape: `underline`, `circle`, `box`, `strike-through`, or `none` |
|
|
30
|
+
| `selector` | `[data-annotate]` | element inside the slot to mark |
|
|
31
|
+
| `text` | – | exact text inside the slot to mark instead of an element |
|
|
32
|
+
| `occurrence` | `1` | which occurrence of `text`, 1-based |
|
|
33
|
+
| `multiline` | – | mark every visual line of the match; on by default for `underline` and `strike-through` |
|
|
34
|
+
| `padding` | `4` | space between the marked box and the stroke, in slide pixels |
|
|
35
|
+
|
|
36
|
+
`text` is the way to reach a token inside a code block, where there is no
|
|
37
|
+
element to point a selector at. It works in plain Shiki blocks and in
|
|
38
|
+
`magic-move` blocks alike, and the mark follows the token while Magic Move
|
|
39
|
+
animates it. When the text is not part of the current Magic Move step, the
|
|
40
|
+
annotation stays hidden.
|
|
41
|
+
|
|
42
|
+
## What to point at
|
|
43
|
+
|
|
44
|
+
| prop | default | meaning |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `label` | – | text to write next to the mark |
|
|
47
|
+
| `target` | – | selector of another element to connect the mark to |
|
|
48
|
+
| `target-x`, `target-y` | `50`, `50` | point inside the target, as a percentage of its box |
|
|
49
|
+
| `target-radius` | `3` | size of the mark at that point, as a percentage of the target's width |
|
|
50
|
+
| `target-type` | `circle` | target shape, independently set to `underline`, `circle`, `box`, `strike-through`, or `none` |
|
|
51
|
+
| `target-mark` | `true` | show the default target circle when `target-type` is omitted |
|
|
52
|
+
| `connect` | `true` | draw the leader line between the mark and its destination |
|
|
53
|
+
| `arrow` | `false` | arrow head at the end of the leader line |
|
|
54
|
+
| `curve` | `0.12` | curvature of the leader line, as a fraction of its length |
|
|
55
|
+
|
|
56
|
+
Percentages keep annotations on screenshots independent of the rendered size.
|
|
57
|
+
Giving both a `target` and a `label` connects the mark to the target and writes
|
|
58
|
+
the label next to it.
|
|
59
|
+
|
|
60
|
+
## Where the label goes
|
|
61
|
+
|
|
62
|
+
A label is placed out of the slide's normal flow. Its position is searched at
|
|
63
|
+
runtime so it does not cover anything else on the slide, preferring downwards
|
|
64
|
+
for marks in the upper half and upwards for marks in the lower half.
|
|
65
|
+
|
|
66
|
+
| prop | default | meaning |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `placement` | `auto` | preferred side: `up`, `down`, `left` or `right`; `auto` picks by vertical position |
|
|
69
|
+
| `label-x`, `label-y` | – | label centre as a percentage of the slide; disables the search |
|
|
70
|
+
| `label-width` | – | maximum width in slide pixels before the label wraps; by default a label stays on one line and only wraps when that line cannot fit or stay clear of content |
|
|
71
|
+
| `gap` | `28` | smallest distance between the mark and the label, in slide pixels |
|
|
72
|
+
| `clearance` | `16` | space the label keeps from everything else on the slide |
|
|
73
|
+
| `avoid-selector` | – | extra elements the label must not cover |
|
|
74
|
+
|
|
75
|
+
## When it is drawn
|
|
76
|
+
|
|
77
|
+
| prop | default | meaning |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `at` | next click | click that draws the mark and its leader line; takes part in Slidev's click ordering like `v-click` |
|
|
80
|
+
| `label-at` | `at` | click that writes the label |
|
|
81
|
+
| `until` | – | click that takes the annotation away again; exclusive, like the end of a `v-click` range |
|
|
82
|
+
| `on` | – | `at` and `until` in one, for an annotation that belongs to a single click |
|
|
83
|
+
| `sequential` | `true` | nested annotations sharing a click draw one after the other |
|
|
84
|
+
| `insert` | `false` | give the annotation [a click of its own](#inside-a-magic-move-block) inside a Magic Move block |
|
|
85
|
+
| `wait` | `true` | hold the drawing back until the annotated element has stopped moving |
|
|
86
|
+
| `track` | `true` | keep the annotation glued to elements that move |
|
|
87
|
+
|
|
88
|
+
### Source, line, target, then label
|
|
89
|
+
|
|
90
|
+
A connector is drawn in three distinct stages: the source mark finishes first,
|
|
91
|
+
then the leader line reaches its destination, then the target mark is drawn.
|
|
92
|
+
The source and target shapes can be selected independently with `source-type`
|
|
93
|
+
and `target-type`. A same-click label waits for those strokes; `label-at` can
|
|
94
|
+
give the label a later click instead, in which case it starts writing as soon
|
|
95
|
+
as that click is reached.
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<DrawnAnnotation
|
|
99
|
+
source-type="circle"
|
|
100
|
+
selector="[data-a]"
|
|
101
|
+
target="[data-b]"
|
|
102
|
+
target-type="none"
|
|
103
|
+
arrow
|
|
104
|
+
:at="1"
|
|
105
|
+
label="B follows from A"
|
|
106
|
+
:label-at="2"
|
|
107
|
+
>
|
|
108
|
+
<div class="card">Element <b data-a>A</b> is annotated first</div>
|
|
109
|
+
<div class="card">And the line is drawn to element <b data-b>B</b></div>
|
|
110
|
+
</DrawnAnnotation>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Click 1 circles **A** and draws the line to **B**, click 2 writes the label, and
|
|
114
|
+
`target-type="none"` leaves **B** itself unannotated.
|
|
115
|
+
|
|
116
|
+
### Two marks on one click
|
|
117
|
+
|
|
118
|
+
Two annotations nested on the *same* click are drawn one after the other: the
|
|
119
|
+
inner one starts once the one around it has finished, so "point at it, then
|
|
120
|
+
circle it" is a single reveal rather than two clicks. Set `:sequential="false"`
|
|
121
|
+
on the inner one to have both drawn at the same time.
|
|
122
|
+
|
|
123
|
+
### Taking it away again
|
|
124
|
+
|
|
125
|
+
`until` takes the whole annotation away again, so it only belongs to the steps
|
|
126
|
+
it describes. It is exclusive, like the end of a `v-click` range: `:at="1"
|
|
127
|
+
:until="2"` keeps the annotation on screen for click 1 alone. This matters
|
|
128
|
+
inside a Magic Move block whose later steps no longer contain the annotated
|
|
129
|
+
text — the mark is drawn on the step that has it, and is gone before the step
|
|
130
|
+
that does not.
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<DrawnAnnotation type="underline" text="val greeting" label="read-only" :at="1" :until="2">
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Almost every annotation belongs to its own click alone, so `on` says that in
|
|
137
|
+
one prop: `:on="1"` is `:at="1" :until="2"`.
|
|
138
|
+
|
|
139
|
+
```html
|
|
140
|
+
<DrawnAnnotation type="underline" text="val greeting" label="read-only" :on="1">
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Click `0` is the slide's initial state, before the first click, so `:on="0"`
|
|
144
|
+
shows an annotation immediately and removes it on click 1.
|
|
145
|
+
|
|
146
|
+
The end counts from the label's click when `label-at` puts the label after the
|
|
147
|
+
mark, so a label is never taken away before it has been read. Give `at` and
|
|
148
|
+
`until` separately whenever the annotation should stay on screen for more than
|
|
149
|
+
one click; `on` next to an explicit `at` or `until` wins, and is reported as a
|
|
150
|
+
mistake.
|
|
151
|
+
|
|
152
|
+
## Inside a Magic Move block
|
|
153
|
+
|
|
154
|
+
By default an annotation shares its click with whatever else that click does,
|
|
155
|
+
so on a Magic Move block it is drawn on the very step that morphs into place.
|
|
156
|
+
`insert` gives it a step of its own instead: the block keeps its own clicks,
|
|
157
|
+
but every step from `at` onwards is pushed one click later, so the annotation
|
|
158
|
+
gets a click where the code stands still.
|
|
159
|
+
|
|
160
|
+
```html
|
|
161
|
+
<DrawnAnnotation type="underline" text="val greeting" label="read-only" insert :on="2">
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
With three code steps that reads: click 1 morphs to the second step, click 2
|
|
165
|
+
underlines `val greeting` on it, click 3 takes the annotation away and morphs
|
|
166
|
+
to the third step.
|
|
167
|
+
|
|
168
|
+
Annotations keep counting in the slide's own clicks — the number in the URL —
|
|
169
|
+
even inside such a block, so a second annotation nested in it annotates the
|
|
170
|
+
third step with `:at="3"`. In return, an annotation inside an `insert` block
|
|
171
|
+
has to be given plain numbers: `+1` and the rest of Slidev's automatic ordering
|
|
172
|
+
are not available there.
|
|
173
|
+
|
|
174
|
+
`wait` (on by default) holds the drawing back until the annotated element has
|
|
175
|
+
stopped moving, so a mark is never drawn across a Magic Move step or a slide
|
|
176
|
+
transition that is still travelling. It watches both the measured geometry and
|
|
177
|
+
the animations running in the slot, because Magic Move fades new tokens in
|
|
178
|
+
where they already belong — they never move, but the code is visibly still
|
|
179
|
+
arriving. It only delays the entrance: an annotation that is already on screen
|
|
180
|
+
stays on screen through the next step. Set `:wait="false"` to draw as soon as
|
|
181
|
+
the click arrives.
|
|
182
|
+
|
|
183
|
+
## How it looks
|
|
184
|
+
|
|
185
|
+
| prop | default | meaning |
|
|
186
|
+
| --- | --- | --- |
|
|
187
|
+
| `options` | – | [rough.js options](https://github.com/rough-stuff/rough/wiki#options), passed straight to the library that draws every stroke |
|
|
188
|
+
| `iterations` | `2` | how many times each shape is drawn over itself — the sketchy redraw |
|
|
189
|
+
| `color` | `--drawn-annotation-color` | stroke and label colour, any CSS colour; the variable falls back to the text colour |
|
|
190
|
+
| `stroke-width` | `2` | stroke width, in slide pixels |
|
|
191
|
+
| `duration` | `800` | how long drawing one stage takes, in milliseconds |
|
|
192
|
+
|
|
193
|
+
Out of the box a mark looks exactly like Slidev's own `v-mark`: the defaults
|
|
194
|
+
are Rough Notation's — a 2px stroke, roughness 1.5, every shape drawn twice,
|
|
195
|
+
800 ms drawn stroke by stroke — and `options` overrides the rough.js
|
|
196
|
+
layer of that recipe: `:options="{ roughness: 2.6 }"` makes the strokes
|
|
197
|
+
wobblier, `:options="{ roughness: 0, bowing: 0 }"` (with `:iterations="1"`)
|
|
198
|
+
turns them into clean geometric lines. Colour and stroke width are the
|
|
199
|
+
exception — they are set through `color` and `stroke-width`, as in Rough
|
|
200
|
+
Notation itself, because they are applied in CSS, which is what animates the
|
|
201
|
+
drawing. The one departure: Rough Notation rolls a random seed, but here the
|
|
202
|
+
randomness is always seeded from the annotation's own props, so a mark keeps
|
|
203
|
+
its shape while it follows a Magic Move transition; pass `seed` in `options`
|
|
204
|
+
to pick one by hand.
|
|
205
|
+
|
|
206
|
+
The default colour is the `--drawn-annotation-color` CSS variable, which this
|
|
207
|
+
deck points at the theme purple in `style.css`. The variable is read where it
|
|
208
|
+
is used, so any scope can redefine it — a single slide's class as well as
|
|
209
|
+
`:root` — and where nobody defines it the strokes follow the surrounding
|
|
210
|
+
text, which is Rough Notation's own default. An explicit `color` prop beats
|
|
211
|
+
all of this. When the token points at another variable, give it a hard
|
|
212
|
+
fallback (`var(--fundamentals-purple, #7954f6)`): a token that resolves
|
|
213
|
+
invalid makes the strokes vanish instead of falling back.
|
|
214
|
+
|
|
215
|
+
The label's typography is themeable the same way, from `:root` or any
|
|
216
|
+
narrower scope:
|
|
217
|
+
|
|
218
|
+
| CSS variable | default | meaning |
|
|
219
|
+
| --- | --- | --- |
|
|
220
|
+
| `--drawn-annotation-color` | text colour | stroke and label colour |
|
|
221
|
+
| `--drawn-annotation-label-font` | `'JetBrains Sans'`, slide sans font | label font family |
|
|
222
|
+
| `--drawn-annotation-label-size` | `28px` | label font size, in slide pixels |
|
|
223
|
+
| `--drawn-annotation-label-weight` | `800` | label font weight |
|
|
224
|
+
|
|
225
|
+
## Dropping it into a theme
|
|
226
|
+
|
|
227
|
+
The component is self-contained: it talks to Slidev only through the public
|
|
228
|
+
`@slidev/client` context, and `vue` and `@vueuse/core` already ship with
|
|
229
|
+
Slidev. To move it into a theme:
|
|
230
|
+
|
|
231
|
+
1. copy `DrawnAnnotation.vue` into the theme's `components/` directory, where
|
|
232
|
+
Slidev auto-registers it for every deck that uses the theme;
|
|
233
|
+
2. add `roughjs` to the theme's `dependencies` — it draws every stroke;
|
|
234
|
+
3. define `--drawn-annotation-color` (and, if wanted, the label variables
|
|
235
|
+
above) in the theme's styles to pick the theme-wide default look.
|
|
236
|
+
|
|
237
|
+
Nothing in the component reads deck-specific state: every colour, font and
|
|
238
|
+
duration flows in through props or the CSS variables above. The label's
|
|
239
|
+
automatic placement knows about the Kotlin theme's `.card` callouts and its
|
|
240
|
+
`.kodee-character` mascot, keeps clear of code blocks, tables, quotes and
|
|
241
|
+
images on any slide, and `avoid-selector` opts in anything else.
|
|
242
|
+
|
|
243
|
+
## When nothing appears
|
|
244
|
+
|
|
245
|
+
An annotation that cannot be drawn stays off the slide and says why on the
|
|
246
|
+
browser console, once, prefixed `[DrawnAnnotation]`. The warnings wait until
|
|
247
|
+
the annotation's click has been reached and the slide has stopped moving, so a
|
|
248
|
+
Magic Move step that legitimately does not contain the text never causes one.
|
|
249
|
+
|
|
250
|
+
- **Text … was not found in the slot** — `text` has to match the rendered text
|
|
251
|
+
exactly, spaces included. Inside a Magic Move block it also has to be part of
|
|
252
|
+
the step the annotation is drawn on.
|
|
253
|
+
- **Text … matches only N times** — `occurrence` asks for a later match than
|
|
254
|
+
the slide has; lower it, or make the text long enough to be unique.
|
|
255
|
+
- **Selector … matched nothing inside the slot** — put the attribute (by
|
|
256
|
+
default `data-annotate`) on the element to mark, or use `text` for code.
|
|
257
|
+
- **Target … matched nothing on the slide** — the `target` selector found no
|
|
258
|
+
element to connect to.
|
|
259
|
+
- **… must be a plain click number** — with `insert`, and on annotations
|
|
260
|
+
nested inside one, the annotation resolves clicks itself, so Slidev's `+1`
|
|
261
|
+
ordering is not available.
|
|
262
|
+
- **`on` is `at` and `until` in one** — drop the separate `at` / `until` when
|
|
263
|
+
`on` is given; they are ignored.
|
package/layouts/cover.vue
CHANGED
package/layouts/default.vue
CHANGED
package/layouts/intro.vue
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slidev-theme-kotlin",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"slidev-theme",
|
|
@@ -9,17 +9,32 @@
|
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=18.0.0"
|
|
11
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"assets",
|
|
14
|
+
"components",
|
|
15
|
+
"layouts",
|
|
16
|
+
"public",
|
|
17
|
+
"setup",
|
|
18
|
+
"styles",
|
|
19
|
+
"slide-bottom.vue",
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
12
24
|
"scripts": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
25
|
+
"lint": "node scripts/lint-slides.mjs slides.md",
|
|
26
|
+
"build": "npm run lint && slidev build slides.md",
|
|
27
|
+
"dev": "slidev slides.md --open",
|
|
28
|
+
"export": "slidev export slides.md",
|
|
29
|
+
"screenshot": "slidev export slides.md --format png"
|
|
17
30
|
},
|
|
18
31
|
"dependencies": {
|
|
19
|
-
"@slidev/types": "^52.2.5"
|
|
32
|
+
"@slidev/types": "^52.2.5",
|
|
33
|
+
"roughjs": "^4.6.6"
|
|
20
34
|
},
|
|
21
35
|
"devDependencies": {
|
|
22
|
-
"@slidev/cli": "^52.2.5"
|
|
36
|
+
"@slidev/cli": "^52.2.5",
|
|
37
|
+
"@slidev/parser": "^52.2.5"
|
|
23
38
|
},
|
|
24
39
|
"slidev": {
|
|
25
40
|
"colorSchema": "both",
|
|
@@ -30,4 +45,4 @@
|
|
|
30
45
|
}
|
|
31
46
|
}
|
|
32
47
|
}
|
|
33
|
-
}
|
|
48
|
+
}
|
package/slide-bottom.vue
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useSlideContext } from '@slidev/client'
|
|
4
|
+
import KodeeWrapper from './components/KodeeWrapper.vue'
|
|
5
|
+
|
|
6
|
+
const { $frontmatter, $page } = useSlideContext()
|
|
7
|
+
|
|
8
|
+
// The first slide defaults to the `cover` layout without declaring it in
|
|
9
|
+
// frontmatter, so mirror Slidev's own layout resolution.
|
|
10
|
+
const layout = computed(() => $frontmatter.layout ?? ($page.value === 1 ? 'cover' : 'default'))
|
|
11
|
+
|
|
12
|
+
const featured = computed(() => ['cover', 'intro'].includes(layout.value))
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div class="kodee-layer" aria-hidden="true">
|
|
17
|
+
<KodeeWrapper
|
|
18
|
+
:default-size="featured ? 'large' : 'small'"
|
|
19
|
+
:default-position="featured ? 'featured' : 'corner'"
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<style scoped>
|
|
25
|
+
.kodee-layer {
|
|
26
|
+
position: absolute;
|
|
27
|
+
inset: 0;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
package/styles/layout.css
CHANGED
|
@@ -43,3 +43,19 @@
|
|
|
43
43
|
@apply mt-10;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
/* DrawnAnnotation defaults. Override these in a deck or slide to match a
|
|
48
|
+
specific visual treatment. */
|
|
49
|
+
:root {
|
|
50
|
+
--drawn-annotation-color: var(--slidev-theme-primary, #7954f6);
|
|
51
|
+
--drawn-annotation-label-font: var(--slidev-font-sans), sans-serif;
|
|
52
|
+
--drawn-annotation-label-size: 28px;
|
|
53
|
+
--drawn-annotation-label-weight: 800;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Let a click-ranged annotation finish its exit fade before the content it
|
|
57
|
+
replaces begins its own click transition. */
|
|
58
|
+
.slidev-layout:has(.drawn-annotation.is-fading-out)
|
|
59
|
+
.slidev-vclick-target.slidev-vclick-current:not(.slidev-vclick-anim-none) {
|
|
60
|
+
transition-delay: 280ms;
|
|
61
|
+
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
name: Deploy pages
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: read
|
|
10
|
-
pages: write
|
|
11
|
-
id-token: write
|
|
12
|
-
|
|
13
|
-
concurrency:
|
|
14
|
-
group: pages
|
|
15
|
-
cancel-in-progress: false
|
|
16
|
-
|
|
17
|
-
jobs:
|
|
18
|
-
build:
|
|
19
|
-
runs-on: ubuntu-latest
|
|
20
|
-
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v4
|
|
23
|
-
|
|
24
|
-
- uses: actions/setup-node@v4
|
|
25
|
-
with:
|
|
26
|
-
node-version: 'lts/*'
|
|
27
|
-
|
|
28
|
-
- name: Setup @antfu/ni
|
|
29
|
-
run: npm i -g @antfu/ni
|
|
30
|
-
|
|
31
|
-
- name: Install dependencies
|
|
32
|
-
run: nci
|
|
33
|
-
|
|
34
|
-
- name: Build
|
|
35
|
-
run: nr build --base /${{github.event.repository.name}}/
|
|
36
|
-
|
|
37
|
-
- name: Setup Pages
|
|
38
|
-
uses: actions/configure-pages@v4
|
|
39
|
-
|
|
40
|
-
- uses: actions/upload-pages-artifact@v3
|
|
41
|
-
with:
|
|
42
|
-
path: dist
|
|
43
|
-
|
|
44
|
-
deploy:
|
|
45
|
-
environment:
|
|
46
|
-
name: github-pages
|
|
47
|
-
url: ${{ steps.deployment.outputs.page_url }}
|
|
48
|
-
needs: build
|
|
49
|
-
runs-on: ubuntu-latest
|
|
50
|
-
name: Deploy
|
|
51
|
-
steps:
|
|
52
|
-
- name: Deploy to GitHub Pages
|
|
53
|
-
id: deployment
|
|
54
|
-
uses: actions/deploy-pages@v4
|