-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added tooltips wip * fixes * fixes * fixes * happy lint * fixed border clip * fixed pr comments --------- Co-authored-by: davide magli <[email protected]>
- Loading branch information
1 parent
b71e94f
commit c0a69b5
Showing
34 changed files
with
334 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.jetbrains.jewel | ||
|
||
import androidx.compose.foundation.TooltipArea | ||
import androidx.compose.foundation.TooltipPlacement | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.DpOffset | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.jewel.styling.TooltipStyle | ||
|
||
@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, | ||
content: @Composable () -> Unit, | ||
) { | ||
TooltipArea( | ||
tooltip = { | ||
CompositionLocalProvider( | ||
LocalContentColor provides style.colors.content, | ||
) { | ||
Box( | ||
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() | ||
} | ||
} | ||
}, | ||
modifier = modifier, | ||
delayMillis = style.metrics.showDelay.inWholeMilliseconds.toInt(), | ||
tooltipPlacement = tooltipPlacement, | ||
content = content, | ||
) | ||
} |
Oops, something went wrong.