Skip to content

Commit e4e0143

Browse files
committed
refactor(styles): Replace inline styles with BoxShadow, TextShadow, FontWeight classes, remove comments, simplify utility functions in Projects, Articles, and CodeTheme.
1 parent 13443e1 commit e4e0143

File tree

5 files changed

+81
-46
lines changed

5 files changed

+81
-46
lines changed

src/jsMain/kotlin/io/github/ayfri/CodeTheme.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.ayfri
22

33
import com.varabyte.kobweb.compose.css.FontStyle
4+
import com.varabyte.kobweb.compose.css.TextShadow
45
import com.varabyte.kobweb.compose.css.fontStyle
56
import com.varabyte.kobweb.compose.css.textShadow
67
import io.github.ayfri.utils.Cursor
@@ -52,7 +53,7 @@ object CodeTheme : StyleSheet() {
5253

5354
child(type("pre") + attrContains("class", "language-"), type("code") + attrContains("class", "language-")) style {
5455
color(textColor)
55-
textShadow(color = transparent, offsetX = 0.px, offsetY = 0.px, blurRadius = 0.px)
56+
textShadow(TextShadow.of(color = transparent, offsetX = 0.px, offsetY = 0.px, blurRadius = 0.px))
5657
}
5758

5859
scope("comment") style {

src/jsMain/kotlin/io/github/ayfri/Main.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ fun AppEntry(content: @Composable () -> Unit) {
4444

4545
@InitKobweb
4646
fun initKobweb(context: InitKobwebContext) {
47-
context.router.setErrorHandler {
48-
if (it != 404) return@setErrorHandler
47+
context.router.setErrorPage {
4948
context.router.navigateTo(
5049
"/",
5150
openExternalLinksStrategy = OpenLinkStrategy.IN_PLACE,

src/jsMain/kotlin/io/github/ayfri/components/articles/ShareSection.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlinx.coroutines.launch
1313
import org.jetbrains.compose.web.ExperimentalComposeWebApi
1414
import org.jetbrains.compose.web.css.*
1515
import org.jetbrains.compose.web.dom.*
16+
import web.clipboard.writeText
1617
import web.navigator.navigator
1718

1819
@Composable

src/jsMain/kotlin/io/github/ayfri/pages/articles/Index.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ object BlogPageStyle : StyleSheet() {
227227
stop(Color("#00D4FF"))
228228
stop(Color("#FF0080"))
229229
})
230-
property("-webkit-background-clip", "text")
231-
property("background-clip", "text")
232-
property("-webkit-text-fill-color", "transparent")
233-
property("text-shadow", "0 0 20px rgba(0, 212, 255, 0.5)")
230+
backgroundClip(BackgroundClip.Text)
231+
textShadow(TextShadow.of(color = rgba(0, 212, 255, 0.5), offsetX = 0.px, offsetY = 0.px, blurRadius = 10.px))
232+
property("-webkit-background-clip", BackgroundClip.Text)
233+
property("-webkit-text-fill-color", Color.transparent)
234234
}
235235

236236
val intro by style {
@@ -259,7 +259,7 @@ object BlogPageStyle : StyleSheet() {
259259
val searchWrapper by style {
260260
alignItems(AlignItems.Center)
261261
backgroundColor(Color("#1A1225"))
262-
border(2.px, LineStyle.Solid, Color("transparent"))
262+
border(2.px, LineStyle.Solid, Color.transparent)
263263
borderRadius(2.cssRem)
264264
color(Color("#FFFFFFB0"))
265265
display(DisplayStyle.Flex)
@@ -284,16 +284,16 @@ object BlogPageStyle : StyleSheet() {
284284

285285
@OptIn(ExperimentalComposeWebApi::class)
286286
val searchInput by style {
287-
backgroundColor(Color("transparent"))
287+
backgroundColor(Color.transparent)
288288
borderStyle(LineStyle.None)
289-
color("inherit")
289+
color(CSSColor.Inherit)
290290
padding(0.px)
291-
outline("none")
291+
outlineStyle(LineStyle.None)
292292
paddingLeft(0.75.cssRem)
293293
width(100.percent)
294294

295295
focus style {
296-
outline("none")
296+
outlineStyle(LineStyle.None)
297297
borderColor(Color("#FFFFFF80"))
298298
backgroundColor(Color("#FFFFFF15"))
299299
boxShadow(0.px, 0.px, 10.px, 0.px, Color("#FFFFFF20"))
@@ -332,7 +332,7 @@ object BlogPageStyle : StyleSheet() {
332332
border {
333333
width(1.px)
334334
style(LineStyle.Solid)
335-
color(Color("transparent"))
335+
color(Color.transparent)
336336
}
337337
property("background", """
338338
linear-gradient(#1A1225, #1A1225) padding-box,
@@ -362,7 +362,7 @@ object BlogPageStyle : StyleSheet() {
362362

363363
val tagSelected by style {
364364
backgroundColor(Color("#1A1225"))
365-
border(2.px, LineStyle.Solid, Color("transparent"))
365+
border(2.px, LineStyle.Solid, Color.transparent)
366366
property("background", """
367367
linear-gradient(#1A1225, #1A1225) padding-box,
368368
linear-gradient(45deg, #FF0080, #00D4FF) border-box
@@ -395,7 +395,7 @@ object BlogPageStyle : StyleSheet() {
395395
cursor(Cursor.Pointer)
396396

397397
focus style {
398-
outline("none")
398+
outlineStyle(LineStyle.None)
399399
borderColor(Color("#FFFFFF80"))
400400
}
401401

@@ -409,7 +409,7 @@ object BlogPageStyle : StyleSheet() {
409409
color(Color("#FFFFFF80"))
410410
fontSize(0.9.cssRem)
411411
marginBottom(1.cssRem)
412-
fontStyle("italic")
412+
fontStyle(FontStyle.Italic)
413413
}
414414

415415
val noResults by style {

0 commit comments

Comments
 (0)