What I’m trying to do:
I am trying to mimic the sample work done here:
How to create a simple CSS badge system - Stack Overflow
What I’ve tried and what’s not working:
I added the css to my theme.css , but I am not sure what the next step would be.
The objective would be to wrap a label component’s element with the “span” tag in the link provided above.
CSS:
[badge]:after {
background: red;
border-radius: 30px;
color: #fff;
content: attr(badge);
font-size: 11px;
margin-top: -10px;
min-width: 20px;
padding: 2px;
position: absolute;
text-align: center;
}
[badge^="-"]:after,
[badge="0"]:after,
[badge=""]:after {
display: none;
}
Demo Usage:
<span badge="">Empty string</span>
<br>
<br>
<span badge="-1">-1</span>
<br>
<br>
<span badge="0">0</span>
<br>
<br>
<span badge="1">1</span>
Not sure where to go after that … Thanks for reading !
What I have tried so far:
python
def update_badge_number(self,num):
for element in anvil.js.window.document.querySelectorAll("span[badge]"):
print(element)
element.textContent = "8"
element.setAttribute('badge',"8")