this would be a great out-of-the-vaadin-box feature,
but for now I’m asking help for setting it up in Vaadin 12.0.7.
my code which is showing the image (which should get the badge);
//declaring the image
...
mohmSearchImage = new Image();
mohmSearchImage.addClassName("mohm-company-button");
...
//adding the eventlistener so the image works like a button
...
mohmSearchImage.getElement().addEventListener(CLICK, (DomEventListener) event -> searchView.showTiles(SearchType.MOHM_COMPANY));
...
It took a while, but I found a way. I wrapped the img inside a DIV, like so:
Image img = new Image("https://vaadin.com/images/vaadin-logo.svg", "ad");
img.setWidth("200px");
Div d = new Div(img);
d.addClassName("tagged");
add(d);
Then, some CSS that I put inside shared-styles.html:
I didn’t succeed yet,
I’ve a question about the css:
I added the css you posted to my shared-styles.html
but I’m not sure if this is the right way:
(this is the complete content of the shared-stules.html)
<custom-style>
<!-- This is where your App's styling should go. You can use .css files too. -->
<style>
.main-layout {
padding: 20px;
}
</style>
</custom-style>
<dom-module id="sdf" theme-for="vaadin-vertical-layout">
<template>
<style>
::slotted(div.tagged) {
position:relative;
}
::slotted(div.tagged)::before {
content: attr(notifications);
background: pink;
border-radius: 3px;
position:absolute;
top:0;
right: 0;
}
</style>
</template>
</dom-module>
I do think the css is picked up by the browser,
as I can see in this screenshot, but I’m wondering why I can’t see the badge.
do I have to integrate the div in a vertical-layout? I don’t understand the id=“sdf”?
![screenshot]
(http://i65.tinypic.com/2db1ipz.png)