Skip to content

Commit d472259

Browse files
committed
feat(web): improve experimental label
1 parent de38037 commit d472259

File tree

1 file changed

+22
-9
lines changed
  • application/src/webMain/kotlin/com/neoutils/neoregex

1 file changed

+22
-9
lines changed

application/src/webMain/kotlin/com/neoutils/neoregex/WebApp.kt

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ import androidx.compose.runtime.Composable
2929
import androidx.compose.runtime.LaunchedEffect
3030
import androidx.compose.ui.Alignment
3131
import androidx.compose.ui.Modifier
32+
import androidx.compose.ui.geometry.Offset
3233
import androidx.compose.ui.graphics.Color
3334
import androidx.compose.ui.graphics.graphicsLayer
35+
import androidx.compose.ui.platform.LocalDensity
3436
import androidx.compose.ui.text.font.FontWeight
3537
import androidx.compose.ui.text.style.TextAlign
38+
import androidx.compose.ui.unit.DpSize
3639
import androidx.compose.ui.unit.dp
3740
import androidx.compose.ui.unit.sp
3841
import com.neoutils.neoregex.core.common.extension.toCss
@@ -59,14 +62,30 @@ fun WebApp() = WithKoin {
5962

6063
@Composable
6164
fun Experimental(
65+
size: DpSize = DpSize(250.dp, 250.dp),
6266
content: @Composable () -> Unit
6367
) = Box {
68+
6469
content()
6570

71+
val density = LocalDensity.current
72+
73+
val translation = density.run {
74+
Offset(
75+
x = (size.width / 3.5f).toPx(),
76+
y = (size.height / 3.5f).toPx().unaryMinus()
77+
)
78+
}
79+
6680
Box(
6781
modifier = Modifier
68-
.size(200.dp)
82+
.size(size)
6983
.align(Alignment.TopEnd)
84+
.graphicsLayer(
85+
translationX = translation.x,
86+
translationY = translation.y,
87+
rotationZ = 45f
88+
)
7089
) {
7190
Text(
7291
text = "experimental",
@@ -76,15 +95,9 @@ fun Experimental(
7695
modifier = Modifier
7796
.fillMaxWidth()
7897
.align(Alignment.Center)
79-
.graphicsLayer(
80-
rotationZ = 45f,
81-
translationX = 50f,
82-
translationY = -50f
83-
)
8498
.background(Color.Yellow)
85-
.padding(
86-
vertical = 8.dp
87-
),
99+
.padding(vertical = 8.dp),
88100
)
89101
}
90102
}
103+

0 commit comments

Comments
 (0)