Skip to content

Commit 49349a6

Browse files
committed
adding theme support advanced
updated readme updated social media logos
1 parent b667b29 commit 49349a6

File tree

10 files changed

+112
-26
lines changed

10 files changed

+112
-26
lines changed

README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/prabhuignoto/float-menu)
66
[![Depfu](https://badges.depfu.com/badges/3597df88718d346a7b41f08e31fe1331/overview.svg)](https://depfu.com/github/prabhuignoto/float-menu?project_id=15010)
77

8-
![logo](./readme-assets/logo.png)
9-
10-
>Customizable Floating Menu for Vue 3
8+
![logo](./readme-assets/social-media-logo-small.png)
119

1210
![app-home](./readme-assets/app-home.png)
1311

@@ -104,6 +102,7 @@ export default {
104102
| menu-data | Object | Array data to generate the nested menu's. |
105103
| on-selected | Function | Hook that is called on selection. |
106104
| flip-on-edges | Boolean | Flips the Menu content automatically, when there is no space to display nested menus. |
105+
| theme | Object | prop to customize the color schemes. refer [theme](#theme) for usage. |
107106
108107
### Dimension
109108
@@ -160,6 +159,7 @@ prop to set the `height` and `width` of the menu.
160159
:menu-dimension="{height: 400, width: 300}"
161160
position="bottom right"
162161
menu-orientation="bottom"
162+
>
163163
<BoxIcon />
164164
</float-menu>
165165
```
@@ -206,7 +206,8 @@ const menuData = [
206206
:menu-dimension="{height: 400, width: 300}"
207207
:menu-data="menuData"
208208
position="bottom right"
209-
menu-orientation="bottom">
209+
menu-orientation="bottom"
210+
>
210211
<BoxIcon />
211212
</float-menu>
212213
```
@@ -224,7 +225,8 @@ hook for the menu item selection event.
224225
:menu-dimension="{height: 400, width: 300}"
225226
:menu-data="{items: [{name: 'File'}, {name: 'Open'}]}"
226227
on-select="handleSelection"
227-
menu-orientation="bottom">
228+
menu-orientation="bottom"
229+
>
228230
<BoxIcon />
229231
</float-menu>
230232
```
@@ -239,7 +241,8 @@ setting this prop `flips` the menu content on the right edges of the screen. Thi
239241
position="bottom right"
240242
flip-on-edges
241243
on-select="handleSelection"
242-
menu-orientation="bottom">
244+
menu-orientation="bottom"
245+
>
243246
<BoxIcon />
244247
</float-menu>
245248
```
@@ -254,24 +257,47 @@ To customize the Menu Icon, simply pass any content in between the `float-menu`
254257
<float-menu
255258
:dimension=50
256259
:menu-data="menuData"
257-
menu-orientation="bottom">
260+
menu-orientation="bottom"
261+
>
258262
<BoxIcon />
259263
</float-menu>
260264
```
261265
262-
and here we render a custom text inside the Menu handle
266+
and here we render a text `Click` inside the Menu handle
263267
264268
```sh
265269
<float-menu
266270
:dimension=50
267271
:menu-data="menuData"
268-
menu-orientation="bottom">
269-
Click Me
272+
menu-orientation="bottom"
273+
>
274+
Click
270275
</float-menu>
271276
```
272277
273278
![example2](./readme-assets/example2.png)
274279
280+
### Theme
281+
282+
Customize the color schemes with the `theme` prop.
283+
284+
```sh
285+
<float-menu
286+
:dimension=50
287+
:theme="{
288+
primary: '#00539C',
289+
textColor: '#000',
290+
menuBgColor: '#fff',
291+
textSelectedColor: '#fff',
292+
}"
293+
menu-orientation="bottom"
294+
>
295+
Click
296+
</float-menu>
297+
```
298+
299+
![theme](./readme-assets/theme.png)
300+
275301
## Build Setup
276302
277303
``` bash
26.3 KB
Loading
103 KB
Loading
Lines changed: 20 additions & 0 deletions
Loading

readme-assets/theme.png

13.5 KB
Loading

src/components/Menu.scss

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
$black: #000;
2-
$blue: #0080ff;
32
$white: #fff;
43
$light-gray: #e5e5e5;
54
$shadow: rgba(0, 0, 0, 0.2) 2px 2px 10px 2px;
@@ -14,8 +13,7 @@ $shadow: rgba(0, 0, 0, 0.2) 2px 2px 10px 2px;
1413

1514
.sub-menu-wrapper {
1615
animation: show 0.2s ease-in;
17-
background: $white;
18-
border-radius: 0.25rem;
16+
border-radius: 0.5rem;
1917
box-shadow: $shadow;
2018
left: 102%;
2119
min-width: 150px;
@@ -44,31 +42,37 @@ $shadow: rgba(0, 0, 0, 0.2) 2px 2px 10px 2px;
4442

4543
.menu-list-item {
4644
align-items: center;
47-
color: $black;
45+
color: var(--menu-text-color);
4846
cursor: pointer;
4947
display: flex;
5048
font-size: 0.9rem;
5149
height: 2.5rem;
5250
justify-content: flex-start;
5351
position: relative;
5452
width: 100%;
53+
background: var(--menu-background);
5554

5655
&:not(:last-child) {
5756
border-bottom: 1px solid $light-gray;
5857
}
5958

6059
&:first-child {
61-
border-top-left-radius: 0.25rem;
62-
border-top-right-radius: 0.25rem;
60+
border-top-left-radius: 6px;
61+
border-top-right-radius: 6px;
62+
}
63+
64+
&:last-child {
65+
border-bottom-left-radius: 6px;
66+
border-bottom-right-radius: 6px;
6367
}
6468

6569
&.selected {
6670
background: var(--background);
67-
color: $white;
71+
color: var(--text-selected-color);
6872
}
6973

7074
&:hover:not(.selected) {
71-
background: $light-gray;
75+
background: rgba(0, 0, 0, 0.1);
7276
color: $black;
7377
}
7478

src/components/Menu.vue

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<template>
2-
<div class="menu-wrapper">
3-
<ul class="menu-list">
2+
<div
3+
class="menu-wrapper"
4+
>
5+
<ul
6+
class="menu-list"
7+
:style="getTheme"
8+
>
49
<li
510
v-for="item of menuItems"
611
:key="item.id"
@@ -13,18 +18,20 @@
1318
<span class="name">{{ item.name }}</span>
1419
<span
1520
v-if="item.subMenu"
16-
class="chev-icon"
21+
class="chev-icon"
1722
>
1823
<ChevRightIcon />
1924
</span>
2025
<span
2126
v-if="item.subMenu && item.showSubMenu"
2227
class="sub-menu-wrapper"
28+
:style="getTheme"
2329
>
2430
<component
2531
:is="SubMenuComponent"
2632
:data="item.subMenu.items"
2733
:on-selection="onSelection"
34+
:theme="theme"
2835
/>
2936
</span>
3037
</li>
@@ -74,9 +81,19 @@ export default defineComponent({
7481
default: null,
7582
},
7683
theme: {
77-
type: Object as PropType<{ primary: string }>,
84+
type: Object as PropType<{
85+
primary: string;
86+
textColor: string;
87+
menuBgColor: string;
88+
textSelectedColor: string;
89+
}>,
7890
required: false,
79-
default: { primary: "#0080ff" },
91+
default: {
92+
primary: "#0080ff",
93+
textColor: "#000",
94+
menuBgColor: "#fff",
95+
textSelectedColor: "#fff",
96+
},
8097
},
8198
},
8299
setup(props) {
@@ -115,6 +132,9 @@ export default defineComponent({
115132
116133
const getTheme = computed(() => ({
117134
"--background": props.theme.primary,
135+
"--menu-background": props.theme.menuBgColor,
136+
"--menu-text-color": props.theme.textColor,
137+
"--text-selected-color": props.theme.textSelectedColor,
118138
}));
119139
120140
return {

src/components/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $cubic: cubic-bezier(0.25, 0.46, 0.45, 0.94);
4141

4242
.menu-container {
4343
align-items: flex-start;
44-
border-radius: 0.45rem;
44+
border-radius: 6px;
4545
box-shadow: rgba(0, 0, 0, 0.2) 2px 2px 10px 2px;
4646
display: flex;
4747
justify-content: flex-start;

src/components/index.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,19 @@ export default defineComponent({
106106
default: false,
107107
},
108108
theme: {
109-
type: Object as PropType<{ primary: string }>,
109+
type: Object as PropType<{
110+
primary: string;
111+
textColor: string;
112+
menuBgColor: string;
113+
textSelectedColor: string;
114+
}>,
110115
required: false,
111-
default: { primary: "#0080ff" },
116+
default: {
117+
primary: "#0080ff",
118+
textColor: "#000",
119+
menuBgColor: "#fff",
120+
textSelectedColor: "#fff",
121+
},
112122
},
113123
},
114124
setup(props, { slots }) {

src/demo/Demo.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
:menu-data="items"
77
:on-selected="handleSelection"
88
:flip-on-edges="true"
9+
:theme="{
10+
primary: '#00539C',
11+
textColor: '#000',
12+
menuBgColor: '#fff',
13+
textSelectedColor: '#fff',
14+
}"
915
menu-orientation="bottom"
1016
>
1117
<BoxIcon />

0 commit comments

Comments
 (0)