1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-02 03:28:28 -04:00

theme: add WCAG data

This commit is contained in:
bbedward
2026-07-20 15:59:31 -04:00
parent 70ceee139b
commit d185135dd7
6 changed files with 153 additions and 12 deletions
@@ -500,6 +500,36 @@ FloatingWindow {
font.weight: Font.Medium
}
}
Rectangle {
id: wcagBadge
// Rated for the mode being viewed, since a theme
// often passes in one mode and not the other.
readonly property var modeReport: Theme.isLightMode ? modelData.wcag?.light : modelData.wcag?.dark
readonly property string level: modeReport?.level ?? ""
readonly property string bodyLevel: modeReport?.body?.level ?? ""
readonly property bool fullPass: level === "AA" || level === "AAA"
readonly property bool bodyPass: bodyLevel === "AA" || bodyLevel === "AAA"
height: 18
width: wcagText.implicitWidth + Theme.spacingS
radius: 9
color: Theme.withAlpha(fullPass ? Theme.info : Theme.surfaceVariantText, 0.15)
border.color: Theme.withAlpha(fullPass ? Theme.info : Theme.surfaceVariantText, 0.4)
border.width: 1
visible: fullPass || bodyPass
anchors.verticalCenter: parent.verticalCenter
StyledText {
id: wcagText
anchors.centerIn: parent
text: wcagBadge.fullPass ? "WCAG " + wcagBadge.level : I18n.tr("WCAG %1 body", "contrast badge when only body text passes").arg(wcagBadge.bodyLevel)
font.pixelSize: Theme.fontSizeSmall
color: wcagBadge.fullPass ? Theme.info : Theme.surfaceVariantText
font.weight: Font.Medium
}
}
}
StyledText {