Loading files
c730ec352This file is pinned to the selected release. Download the original to open it in your design tool.
import { Data } from "../api.slint";
export component Badge inherits Rectangle {
in property <string> text;
in property <color> text-color: clickable ? Data.theme.base-text-muted : Data.theme.base-text;
in property <color> text-color-hover: Data.theme.base-text-hovered;
in property <length> font-size: 10px;
in property <int> font-weight: 400;
in property <bool> clickable: false;
in property <string> description;
out property <bool> has-hover: false;
height: txt.preferred-height + 2px;
preferred-width: txt.preferred-width + 10px;
min-width: (self.preferred-width > 50px) ? 10px : self.preferred-width;
max-width: self.preferred-width;
border-color: txt.color;
border-width: 1px;
border-radius: self.height / 2;
callback clicked;
txt := Text {
width: parent.width - 10px;
height: parent.height;
horizontal-alignment: center;
vertical-alignment: center;
color: has-hover ? text-color-hover : text-color;
font-size: font-size;
font-weight: font-weight;
overflow: elide;
text: text;
accessible-description: description;
}
if clickable: ta := TouchArea {
mouse-cursor: pointer;
changed has-hover => {
root.has-hover = self.has-hover;
}
clicked => {
root.clicked();
}
}
}