Skip to content

Commit

Permalink
fixed pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
edivad1999 committed Oct 4, 2023
1 parent 1244c91 commit 759a6ce
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
19 changes: 11 additions & 8 deletions core/src/main/kotlin/org/jetbrains/jewel/Tooltip.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,31 @@ import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.styling.TooltipStyle

@Composable
fun Tooltip(
@Composable fun Tooltip(
tooltip: @Composable () -> Unit,
modifier: Modifier = Modifier,
tooltipPlacement: TooltipPlacement = TooltipPlacement.ComponentRect(
alignment = Alignment.CenterEnd,
anchor = Alignment.BottomEnd,
offset = DpOffset(4.dp, 4.dp),
),
style: TooltipStyle = IntelliJTheme.tooltipStyle,
tooltip: @Composable () -> Unit,
content: @Composable () -> Unit,
) {
TooltipArea(
tooltip = {
CompositionLocalProvider(
LocalContentColor provides style.colors.contentColor,
LocalContentColor provides style.colors.content,
) {
Box(
modifier = Modifier
.background(style.colors.backgroundColor, RoundedCornerShape(8.dp))
.border(1.dp, style.colors.borderColor, shape = RoundedCornerShape(8.dp))
.padding(style.metrics.paddingValues),
modifier = Modifier.background(
color = style.colors.background,
shape = RoundedCornerShape(style.metrics.cornerSize),
).border(
width = style.metrics.borderWidth,
color = style.colors.border,
shape = RoundedCornerShape(style.metrics.cornerSize),
).padding(style.metrics.contentPadding),
) {
tooltip()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.jetbrains.jewel.styling

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.runtime.Stable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import kotlin.time.Duration

@Stable
Expand All @@ -16,16 +18,18 @@ interface TooltipStyle {
@Stable
interface TooltipColors {

val backgroundColor: Color
val contentColor: Color
val borderColor: Color
val background: Color
val content: Color
val border: Color
}

@Stable
interface TooltipMetrics {

val paddingValues: PaddingValues
val contentPadding: PaddingValues
val showDelay: Duration
val cornerSize: CornerSize
val borderWidth: Dp
}

val LocalTooltipStyle = staticCompositionLocalOf<TooltipStyle> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,9 @@ private fun readTooltipStyle(
return IntUiTooltipStyle(
metrics = IntUiTooltipMetrics(),
colors = IntUiTooltipColors(
contentColor = retrieveColorOrUnspecified(content),
backgroundColor = retrieveColorOrUnspecified(background),
borderColor = retrieveColorOrUnspecified("Tooltip.borderColor"),
content = retrieveColorOrUnspecified(content),
background = retrieveColorOrUnspecified(background),
border = retrieveColorOrUnspecified("Tooltip.borderColor"),
),
)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.jetbrains.jewel.intui.standalone.styling

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.IntelliJTheme
import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme
Expand Down Expand Up @@ -44,9 +46,9 @@ data class IntUiTooltipStyle(

@Stable
data class IntUiTooltipColors(
override val contentColor: Color,
override val backgroundColor: Color,
override val borderColor: Color,
override val content: Color,
override val background: Color,
override val border: Color,
) : TooltipColors {

companion object {
Expand All @@ -69,6 +71,8 @@ data class IntUiTooltipColors(

@Stable
data class IntUiTooltipMetrics(
override val paddingValues: PaddingValues = PaddingValues(vertical = 8.dp, horizontal = 8.dp),
override val contentPadding: PaddingValues = PaddingValues(vertical = 8.dp, horizontal = 8.dp),
override val showDelay: Duration = 0.milliseconds,
override val cornerSize: CornerSize = CornerSize(8.dp),
override val borderWidth: Dp = 1.dp,
) : TooltipMetrics

0 comments on commit 759a6ce

Please sign in to comment.