Skip to content

Commit e8f75d6

Browse files
committed
feat: add custom classes to stickynote and admonition
- adds props to stickynote and admonition compoents to allow styling of the font size and other elements of the title and content - `custom` for the content `customTitle` for the title - add docs and examples to the examples.md - closes #13
1 parent 102d422 commit e8f75d6

5 files changed

Lines changed: 77 additions & 15 deletions

File tree

components/Admonition.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ const props = defineProps({
1818
type: String,
1919
default: '100%',
2020
},
21+
custom: {
22+
// add a custom class if you want
23+
type: String,
24+
default: '',
25+
},
26+
customTitle: {
27+
// add a custom class if you want
28+
type: String,
29+
default: '',
30+
},
2131
})
2232
2333
const colorscheme = computed(() => {
@@ -27,10 +37,10 @@ const colorscheme = computed(() => {
2737

2838
<template>
2939
<div class="markdown-alert markdown-alert-custom" :class="colorscheme">
30-
<p class="markdown-alert-title-custom">
31-
<span class="font-size-1.3rem"><Icon :icon="props.icon" /></span>&nbsp;&nbsp;{{ props.title }}
40+
<p class="markdown-alert-title-custom" :class="props.customTitle">
41+
<span :class="`[font-size-1.3rem, customTitle]`"><Icon :icon="props.icon" /></span>&nbsp;&nbsp;{{ props.title }}
3242
</p>
33-
<p><slot></slot></p>
43+
<p :class="props.custom"><slot></slot></p>
3444
</div>
3545
</template>
3646

components/StickyNote.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ const props = defineProps({
1818
type: String,
1919
default: '',
2020
},
21+
custom: {
22+
// add a custom class if you want
23+
type: String,
24+
default: '',
25+
},
26+
customTitle: {
27+
// add a custom class if you want
28+
type: String,
29+
default: 'block text-xs font-mono tracking-normal font-bold',
30+
},
2131
})
2232
2333
const colorscheme = computed(() => {
@@ -40,9 +50,9 @@ const stickyStyles = computed(() => ({
4050
<template>
4151
<div :class="stickyClasses" :style="stickyStyles">
4252
<template v-if="props.title !== ''"
43-
><strong>{{ props.title }}</strong></template
53+
><span :class="props.customTitle">{{ props.title }}</span></template
4454
>
45-
<slot></slot>
55+
<div :class="props.custom"><slot></slot></div>
4656
</div>
4757
</template>
4858

@@ -61,11 +71,4 @@ const stickyStyles = computed(() => ({
6171
color: var(--text-color);
6272
border: 0.4px solid var(--border-color);
6373
}
64-
.sticky-note strong {
65-
display: block;
66-
font-size: 0.8rem;
67-
font-family: monospace;
68-
letter-spacing: 0em;
69-
word-spacing: -0.3em;
70-
}
7174
</style>

docs/components/admonitions.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ The `Admonition` component is used to create a colored box with an icon and a ti
1616
- `color` (optional) can be any of the [color scheme](/colors) options. If not provided, the default color is `amber-light`.
1717
- `width` (optional) the width of the admonition. Default is `100%`.
1818
- `icon` (optional) the icon to display. Default is `mdi-information-variant-circle-outline`.
19+
- `custom` (optional) a custom CSS class to apply to the admonition content. Default is empty.
20+
- `customTitle` (optional) a custom CSS class to apply to the admonition title. Default is empty.
1921

2022
Example:
2123

@@ -30,6 +32,19 @@ Renders as:
3032
This is my admonition content.
3133
</Admonition>
3234

35+
You can also add custom CSS classes to style the admonition content and title:
36+
37+
```vue
38+
<Admonition title="Custom Styled" color="purple-light" custom="text-lg font-bold" customTitle="text-red-500">
39+
This content has custom styling applied.
40+
</Admonition>
41+
```
42+
43+
Renders as:
44+
<Admonition title="Custom Styled" color='purple-light' custom="text-lg font-bold" customTitle="text-red-500">
45+
This content has custom styling applied.
46+
</Admonition>
47+
3348
If you want to position it somewhere arbitrary on the slide add v-drag to the admonition and also set the width to something fixed (e.g., `300px`):
3449

3550
```md

docs/components/stickynote.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ The `StickyNote` component is used to create a colored box with an title and con
1414
- `color` (optional) can be any of the [color scheme](/colors) options. If not provided, the default color is `amber-light`.
1515
- `width` (optional) the width of the admonition. Default is `180px`.
1616
- `textAlign` (optional) the text alignment of the content. Default is `left`.
17+
- `custom` (optional) a custom CSS class to apply to the sticky note content. Default is empty.
18+
- `customTitle` (optional) a custom CSS class to apply to the sticky note title. Default is `block text-xs font-mono tracking-normal font-bold`.
1719

1820
Example:
1921

@@ -30,6 +32,25 @@ Renders as:
3032
Hello, I'm a **sticky note**.
3133
</StickyNote>
3234

35+
You can also add custom CSS classes to style the sticky note content and title:
36+
37+
```vue
38+
<StickyNote
39+
color="teal-light"
40+
width="200px"
41+
title="Custom Styled"
42+
custom="text-lg font-bold text-center"
43+
customTitle="text-red-500 text-lg"
44+
>
45+
This content has custom styling applied.
46+
</StickyNote>
47+
```
48+
49+
Renders as:
50+
<StickyNote color="teal-light" width="200px" title="Custom Styled" custom="text-lg font-bold text-center" customTitle="text-red-500 text-lg">
51+
This content has custom styling applied.
52+
</StickyNote>
53+
3354
If you want to position it somewhere arbitrary on the slide add v-drag to the admonition and also set the width to something fixed (e.g., `300px`):
3455

3556
```md

example.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ This is a tip
11601160
This is a tip
11611161
</AdmonitionType>
11621162

1163-
<AdmonitionType type='caution' >
1163+
<AdmonitionType type='caution' custom="text-lg" customTitle="font-size-6">
11641164
This is warning text
11651165
</AdmonitionType>
11661166

@@ -1204,16 +1204,29 @@ title: Sticky Notes
12041204
Hello, I'm a **sticky note**.
12051205
</StickyNote>
12061206

1207-
<StickyNote color="sky-light" textAlign="left" width="180px" title="This is my title" v-drag="[375,306,180,180,-15]">
1207+
<StickyNote color="sky-light" textAlign="left" width="180px" title="This is my title" v-drag="[304,295,180,180,-15]">
12081208

12091209
Hello, I'm also a **sticky note** but am blue sky title.
12101210
</StickyNote>
12111211

1212-
<StickyNote color="pink-light" textAlign="left" width="180px" v-drag="[667,299,185,171,8]">
1212+
<StickyNote color="pink-light" textAlign="left" width="180px" v-drag="[549,292,185,171,8]">
12131213

12141214
Hello, I'm also a **sticky note** but I lack a title.
12151215
</StickyNote>
12161216

1217+
1218+
<StickyNote color="pink-light" textAlign="left" width="180px" v-drag="[549,292,185,171,8]">
1219+
1220+
Hello, I'm also a **sticky note** but I lack a title.
1221+
</StickyNote>
1222+
1223+
<StickyNote color="emerald-light" textAlign="left" width="180px" title="This is my
1224+
title" customTitle="font-size-6" custom="font-size-2"
1225+
v-drag="[749,292,185,171,-8]">
1226+
1227+
Hello, I'm also a **sticky note** but I'm customized with a title and a custom class.
1228+
</StickyNote>
1229+
12171230
# Sticky Notes
12181231

12191232
- Sticky notes are moveable elements you can use for notes.

0 commit comments

Comments
 (0)