Skip to content

Commit b81d7b2

Browse files
committed
Add support for menu separator with optional label #37
1 parent 11b0c80 commit b81d7b2

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/main/java/com/flowingcode/addons/applayout/AppDrawer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public AppDrawer(Component headerComponent) {
6969
r[0].remove();
7070
});
7171

72+
getElement().getStyle().set("--fc-separator-background-color", "var(--app-drawer-content-container_-_background-color)");
7273
}
7374

7475
public void setSwipeOpen(boolean swipeOpen) {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!doctype html>
2+
3+
<link rel="import" href="../vaadin-themable-mixin/vaadin-themable-mixin.html">
4+
<link rel="import" href="../paper-item/paper-icon-item.html">
5+
6+
<!--
7+
Styles:
8+
--fc-separator-background-color
9+
--fc-separator-border-color
10+
--fc-separator-text-padding
11+
-->
12+
<dom-module id="fc-separator">
13+
<!--
14+
Based on https://stackoverflow.com/a/28434792/1297272
15+
(C) 2015 CC-BY-SA https://stackoverflow.com/users/677418/sleek-geek
16+
-->
17+
<template>
18+
<style>
19+
:host {
20+
display: flex;
21+
justify-content: center;
22+
}
23+
:host div {
24+
width: 100%;
25+
text-align: center;
26+
position: relative;
27+
background-color: var(--fc-separator-background-color, white);
28+
}
29+
30+
:host div:after {
31+
content: '';
32+
width: 100%;
33+
border-bottom: solid 1px var(--fc-separator-border-color, black);
34+
position: absolute;
35+
left: 0;
36+
top: 50%;
37+
z-index: 1;
38+
}
39+
40+
:host span {
41+
background-color: var(--fc-separator-background-color, white);
42+
width: auto;
43+
display: inline-block;
44+
z-index: 3;
45+
padding: 0 var(--fc-separator-text-padding, 8px) 0 var(--fc-separator-text-padding, 8px);
46+
position: relative;
47+
}
48+
</style>
49+
<div>
50+
<span><slot></slot></span>
51+
</div>
52+
</template>
53+
54+
<script>
55+
class MenuSeparator extends Vaadin.ThemableMixin(Polymer.Element) {
56+
static get is() { return 'fc-separator'; }
57+
}
58+
59+
customElements.define(MenuSeparator.is, MenuSeparator);
60+
</script>
61+
</dom-module>

src/main/resources/META-INF/resources/frontend/styles/applayout-styles.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
--app-drawer-scrim-background: rgba(0, 0, 100, 0.8);
3939
z-index: 1000;
4040
}
41+
42+
app-drawer fc-separator {
43+
margin: 0 8px;
44+
}
4145

4246
app-drawer paper-listbox {
4347
overflow-y: auto;

0 commit comments

Comments
 (0)