Skip to content

Commit 5778d22

Browse files
committed
feat: sticky notes can be dev-mode only for personal notes
Closes #4
1 parent 77b210d commit 5778d22

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

components/StickyNote.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ const props = defineProps({
2828
type: String,
2929
default: 'block text-xs font-mono tracking-normal font-bold',
3030
},
31+
devOnly: {
32+
// only show in dev mode (useful for notes that shouldn't appear in exports)
33+
type: Boolean,
34+
default: false,
35+
},
36+
})
37+
38+
const isVisible = computed(() => {
39+
if (!props.devOnly) return true
40+
return import.meta.env.DEV
3141
})
3242
3343
const colorscheme = computed(() => {
@@ -48,7 +58,7 @@ const stickyStyles = computed(() => ({
4858
</script>
4959

5060
<template>
51-
<div :class="stickyClasses" :style="stickyStyles">
61+
<div v-if="isVisible" :class="stickyClasses" :style="stickyStyles">
5262
<template v-if="props.title !== ''"
5363
><span :class="props.customTitle">{{ props.title }}</span></template
5464
>

docs/components/stickynote.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The `StickyNote` component is used to create a colored box with an title and con
1616
- `textAlign` (optional) the text alignment of the content. Default is `left`.
1717
- `custom` (optional) a custom CSS class to apply to the sticky note content. Default is empty.
1818
- `customTitle` (optional) a custom CSS class to apply to the sticky note title. Default is `block text-xs font-mono tracking-normal font-bold`.
19+
- `devOnly` (optional) when set to `true`, the sticky note will only be visible in development mode and will be hidden in production builds and exports. This is useful for personal notes or reminders that shouldn't appear in the final presentation. Default is `false`.
1920

2021
Example:
2122

@@ -71,3 +72,18 @@ Another color:
7172

7273
Hello, I'm a **sticky note**.
7374
</StickyNote>
75+
76+
## Dev-Only Notes
77+
78+
Use the `devOnly` prop to create sticky notes that only appear during development. These are perfect for speaker notes, reminders, or TODOs that you don't want in your exported presentation:
79+
80+
```vue
81+
<StickyNote color="amber-light" width="180px" title="Note to self" devOnly>
82+
Remember to add more examples here before the talk!
83+
</StickyNote>
84+
```
85+
86+
When `devOnly` is set to `true`:
87+
88+
- The sticky note is visible when running `slidev dev`
89+
- The sticky note is **hidden** when running `slidev build` or `slidev export`

example.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,30 @@ Hello, I'm also a **sticky note** but I'm customized with a title and a custom c
12381238
</StickyNote>
12391239
```
12401240

1241+
---
1242+
layout: default
1243+
title: Dev-Only Sticky Notes
1244+
---
1245+
1246+
# Dev-Only Sticky Notes
1247+
1248+
<StickyNote color="rose-light" textAlign="left" width="200px" title="Dev Note" devOnly v-drag="[650,150,200,200]">
1249+
1250+
This note only appears in **dev mode**! It won't show in exports or production builds.
1251+
</StickyNote>
1252+
1253+
Use the `devOnly` prop to create sticky notes that only appear during development. These are perfect for speaker notes, reminders, or TODOs that you don't want in your final presentation.
1254+
1255+
```vue
1256+
<StickyNote color="rose-light" title="Dev Note" devOnly>
1257+
This note only appears in dev mode!
1258+
</StickyNote>
1259+
```
1260+
1261+
When `devOnly` is set to `true`:
1262+
- Visible when running `slidev dev`
1263+
- Hidden when running `slidev build` or `slidev export`
1264+
12411265
---
12421266
layout: default
12431267
title: Kawaii 1

0 commit comments

Comments
 (0)