@@ -131,32 +131,49 @@ public data class HtmlDecorationTemplate(
131
131
): HtmlDecorationTemplate {
132
132
val className = createUniqueClassName(if (asHighlight) " highlight" else " underline" )
133
133
val padding = Padding (left = 1 , right = 1 )
134
+
134
135
return HtmlDecorationTemplate (
135
136
layout = Layout .BOXES ,
136
137
element = { decoration ->
137
138
val tint = (decoration.style as ? Style .Tinted )?.tint ? : defaultTint
138
139
val isActive = (decoration.style as ? Style .Activable )?.isActive ? : false
139
- var css = " "
140
- if (asHighlight || isActive) {
141
- css + = " background-color: ${tint.toCss(alpha = alpha)} !important;"
142
- }
143
- if (! asHighlight || isActive) {
144
- css + = " border-bottom: ${lineWeight} px solid ${tint.toCss()} ;"
140
+ buildString {
141
+ if (asHighlight || isActive) {
142
+ append(" background-color: ${tint.toCss(alpha = alpha)} !important;" )
143
+ }
144
+ if (! asHighlight || isActive) {
145
+ append(" --underline-color: ${tint.toCss()} ;" )
146
+ }
147
+ }.let { css ->
148
+ """ <div class="$className " style="$css "/>"""
145
149
}
146
- """
147
- <div class="$className " style="$css "/>"
148
- """
149
150
},
150
151
stylesheet = """
151
- .$className {
152
- margin-left: ${- padding.left} px;
153
- padding-right: ${padding.left + padding.right} px;
154
- margin-top: ${- padding.top} px;
155
- padding-bottom: ${padding.top + padding.bottom} px;
156
- border-radius: ${cornerRadius} px;
157
- box-sizing: border-box;
158
- }
159
- """
152
+ .$className {
153
+ margin: ${- padding.top} px ${- padding.left} px 0 0;
154
+ padding: 0 ${padding.left + padding.right} px ${padding.top + padding.bottom} px 0;
155
+ border-radius: ${cornerRadius} px;
156
+ box-sizing: border-box;
157
+ border: 0 solid var(--underline-color);
158
+ }
159
+
160
+ /* Horizontal (default) */
161
+ [data-writing-mode="horizontal-tb"].$className {
162
+ border-bottom-width: ${lineWeight} px;
163
+ }
164
+
165
+ /* Vertical right-to-left */
166
+ [data-writing-mode="vertical-rl"].$className ,
167
+ [data-writing-mode="sideways-rl"].$className {
168
+ border-left-width: ${lineWeight} px;
169
+ }
170
+
171
+ /* Vertical left-to-right */
172
+ [data-writing-mode="vertical-lr"].$className ,
173
+ [data-writing-mode="sideways-lr"].$className {
174
+ border-right-width: ${lineWeight} px;
175
+ }
176
+ """
160
177
)
161
178
}
162
179
0 commit comments