Skip to content

Commit 0855ea2

Browse files
authored
Merge pull request #19 from jamesWalker55/component-icons
Add support for using components as icons
2 parents 2eea2cb + aa1c8e1 commit 0855ea2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ my_menu = [
1515
text: String, // Text displayed on the button, if any
1616
html: String, // Raw HTML to display, if any
1717
title: String, // Text to display in the button tooltip, if any
18-
icon: String, // Name of Material icon to display, if any (see https://material.io/resources/icons/)
18+
icon: String || Object, // Name of Material icon to display, if any (see https://material.io/resources/icons/), or an icon component (e.g. https://github.com/antfu/unplugin-icons)
1919
emoji: String, // Name of Emoji to display, if any (from this list: https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json)
2020
hotkey: String, // Hotkey combination shortcut for the button, if any (use this format: https://github.com/jaywcjlove/hotkeys#supported-keys)
2121
active: Boolean, // Set to true if the button is toggled
@@ -39,7 +39,7 @@ my_menu = [
3939
// === item properties ===
4040
text: String, // Text displayed on the menu item, if any
4141
html: String, // Raw HTML to display, if any
42-
icon: String, // Name of Material icon to display, if any (see https://material.io/resources/icons/)
42+
icon: String || Object, // Name of Material icon to display, if any (see https://material.io/resources/icons/), or an icon component (e.g. https://github.com/antfu/unplugin-icons)
4343
emoji: String, // Name of Emoji to display, if any (from this list: https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json)
4444
hotkey: String, // Hotkey combination shortcut for the menu, if any (use this format: https://github.com/jaywcjlove/hotkeys#supported-keys)
4545
disabled: Boolean, // Set to true if the menu is disabled (it will prevent click event)

src/Bar/BarButtonGeneric.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
@mousedown="(e) => e.preventDefault()"
44
@click="(e) => (item.click && !item.disabled) ? item.click(e) : e.stopPropagation()">
55

6-
<span v-if="item.icon" class="material-icons icon">{{ item.icon }}</span>
6+
<template v-if="item.icon">
7+
<component v-if="typeof item.icon == 'object'" class="icon" :is="item.icon"></component>
8+
<span v-else class="material-icons icon">{{ item.icon }}</span>
9+
</template>
710
<span v-if="item.emoji" class="emoji">{{ get_emoji(item.emoji) }}</span>
811
<span v-if="item.text" class="label">{{ item.text }}</span>
912
<span v-if="item.html" class="label" v-html="item.html"></span>

src/Bar/BarMenuItem.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
:title="item.title"
77
:style="{ height: item.height+'px' }">
88

9-
<span v-if="item.icon" class="material-icons icon">{{ item.icon }}</span>
9+
<template v-if="item.icon">
10+
<component v-if="typeof item.icon == 'object'" class="icon" :is="item.icon"></component>
11+
<span v-else class="material-icons icon">{{ item.icon }}</span>
12+
</template>
1013
<span v-if="item.emoji" class="emoji">{{ get_emoji(item.emoji) }}</span>
1114
<span v-if="item.text" class="label">{{ item.text }}</span>
1215
<span v-if="item.html" class="label" v-html="item.html"></span>

0 commit comments

Comments
 (0)