diff --git a/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/ComponentShowcaseTab.kt b/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/ComponentShowcaseTab.kt index 885b3dffe..1c9d19360 100644 --- a/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/ComponentShowcaseTab.kt +++ b/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/ComponentShowcaseTab.kt @@ -56,26 +56,26 @@ import org.jetbrains.jewel.ui.component.CircularProgressIndicatorBig import org.jetbrains.jewel.ui.component.DefaultButton import org.jetbrains.jewel.ui.component.Divider import org.jetbrains.jewel.ui.component.Dropdown -import org.jetbrains.jewel.ui.component.ErrorBanner +import org.jetbrains.jewel.ui.component.ErrorDefaultBanner import org.jetbrains.jewel.ui.component.ErrorInlineBanner import org.jetbrains.jewel.ui.component.Icon import org.jetbrains.jewel.ui.component.IconActionButton import org.jetbrains.jewel.ui.component.IconButton -import org.jetbrains.jewel.ui.component.InformationBanner +import org.jetbrains.jewel.ui.component.InformationDefaultBanner import org.jetbrains.jewel.ui.component.InformationInlineBanner import org.jetbrains.jewel.ui.component.LazyTree import org.jetbrains.jewel.ui.component.Link import org.jetbrains.jewel.ui.component.OutlinedButton import org.jetbrains.jewel.ui.component.RadioButtonRow import org.jetbrains.jewel.ui.component.Slider -import org.jetbrains.jewel.ui.component.SuccessBanner +import org.jetbrains.jewel.ui.component.SuccessDefaultBanner import org.jetbrains.jewel.ui.component.SuccessInlineBanner import org.jetbrains.jewel.ui.component.Text import org.jetbrains.jewel.ui.component.TextField import org.jetbrains.jewel.ui.component.Tooltip import org.jetbrains.jewel.ui.component.Typography import org.jetbrains.jewel.ui.component.VerticallyScrollableContainer -import org.jetbrains.jewel.ui.component.WarningBanner +import org.jetbrains.jewel.ui.component.WarningDefaultBanner import org.jetbrains.jewel.ui.component.WarningInlineBanner import org.jetbrains.jewel.ui.component.separator import org.jetbrains.jewel.ui.icons.AllIconsKeys @@ -230,7 +230,7 @@ private fun RowScope.ColumnOne() { Text(text = "Clicked action: $clickLabel") when (bannerStyle) { 1 -> { - ErrorBanner("This is an error banner in Compose") + ErrorDefaultBanner("This is an error banner in Compose") ErrorInlineBanner( style = JewelTheme.inlineBannerStyle.error, text = @@ -244,7 +244,7 @@ private fun RowScope.ColumnOne() { } 0 -> { - SuccessBanner("This is a success banner in Compose") + SuccessDefaultBanner("This is a success banner in Compose") SuccessInlineBanner( style = JewelTheme.inlineBannerStyle.success, text = @@ -270,12 +270,12 @@ private fun RowScope.ColumnOne() { } 2 -> { - WarningBanner("This is a warning banner in Compose") + WarningDefaultBanner("This is a warning banner in Compose") WarningInlineBanner("This is a warning banner in Compose") } else -> { - InformationBanner("This is an information banner in Compose") + InformationDefaultBanner("This is an information banner in Compose") InformationInlineBanner("This is an information banner in Compose") } } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Banners.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Banners.kt index 8dc0fedce..8adcf0575 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Banners.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Banners.kt @@ -6,8 +6,7 @@ import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll +import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -16,113 +15,192 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import org.jetbrains.jewel.foundation.theme.JewelTheme -import org.jetbrains.jewel.ui.component.ErrorBanner +import org.jetbrains.jewel.ui.component.ErrorDefaultBanner import org.jetbrains.jewel.ui.component.ErrorInlineBanner import org.jetbrains.jewel.ui.component.GroupHeader import org.jetbrains.jewel.ui.component.Icon import org.jetbrains.jewel.ui.component.IconButton -import org.jetbrains.jewel.ui.component.InformationBanner +import org.jetbrains.jewel.ui.component.InformationDefaultBanner import org.jetbrains.jewel.ui.component.InformationInlineBanner import org.jetbrains.jewel.ui.component.Link -import org.jetbrains.jewel.ui.component.SuccessBanner +import org.jetbrains.jewel.ui.component.SuccessDefaultBanner import org.jetbrains.jewel.ui.component.SuccessInlineBanner import org.jetbrains.jewel.ui.component.Text -import org.jetbrains.jewel.ui.component.WarningBanner +import org.jetbrains.jewel.ui.component.VerticallyScrollableContainer +import org.jetbrains.jewel.ui.component.WarningDefaultBanner import org.jetbrains.jewel.ui.component.WarningInlineBanner +import org.jetbrains.jewel.ui.component.scrollbarContentSafePadding import org.jetbrains.jewel.ui.icons.AllIconsKeys import org.jetbrains.jewel.ui.theme.defaultBannerStyle import org.jetbrains.jewel.ui.theme.inlineBannerStyle +private const val LONG_IPSUM = + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor" + + " incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, " + + "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " + + "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu " + + "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa " + + "qui officia deserunt mollit anim id est laborum." + @ExperimentalLayoutApi @Composable internal fun Banners() { - var clickLabel by remember { mutableStateOf("") } - val scrollState = rememberScrollState() - Column(Modifier.fillMaxWidth().verticalScroll(scrollState), verticalArrangement = Arrangement.spacedBy(8.dp)) { + Column { + var clickLabel by remember { mutableStateOf("") } Text(text = "Clicked action: $clickLabel") Spacer(Modifier.height(8.dp)) - GroupHeader("Default banner (aka editor banners)") - - InformationBanner( - style = JewelTheme.defaultBannerStyle.information, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - ) - - SuccessBanner( - style = JewelTheme.defaultBannerStyle.success, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - ) - - WarningBanner( - style = JewelTheme.defaultBannerStyle.warning, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - ) - - ErrorBanner( - style = JewelTheme.defaultBannerStyle.error, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - ) - - Spacer(Modifier.height(0.dp)) // The column's arrangement will add 8+8 dps of spacing - - GroupHeader("Inline banner") - - InformationInlineBanner( - style = JewelTheme.inlineBannerStyle.information, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - ) - ErrorInlineBanner( - style = JewelTheme.inlineBannerStyle.error, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - actionIcons = { - IconButton(onClick = { clickLabel = "Error Inline Action Icon clicked" }) { - Icon(AllIconsKeys.General.Close, null) - } - }, - ) - InformationInlineBanner( - style = JewelTheme.inlineBannerStyle.information, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - actions = { - Link("Action A", onClick = { clickLabel = "Information Inline Action A clicked" }) - Link("Action B", onClick = { clickLabel = "Information Inline Action B clicked" }) - }, - ) - SuccessInlineBanner( - style = JewelTheme.inlineBannerStyle.success, - text = - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor" + - " incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, " + - "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " + - "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu " + - "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa " + - "qui officia deserunt mollit anim id est laborum.", - actions = { - Link("Action A", onClick = { clickLabel = "Success Inline Action A clicked" }) - Link("Action B", onClick = { clickLabel = "Success Inline Action B clicked" }) - }, - actionIcons = { - IconButton(onClick = { clickLabel = "Error Close Icon clicked" }) { - Icon(AllIconsKeys.General.Close, null) - } - IconButton(onClick = { clickLabel = "Error Gear Icon clicked" }) { - Icon(AllIconsKeys.General.Gear, null) - } - }, - ) - WarningInlineBanner( - style = JewelTheme.inlineBannerStyle.warning, - text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", - actions = { Link("Action A", onClick = { clickLabel = "Warning Inline Action A clicked" }) }, - actionIcons = { - IconButton(onClick = { clickLabel = "Error Close Icon clicked" }) { - Icon(AllIconsKeys.General.Close, null) - } - IconButton(onClick = { clickLabel = "Error Gear Icon clicked" }) { - Icon(AllIconsKeys.General.Gear, null) - } - }, - ) + VerticallyScrollableContainer { + Column( + Modifier.fillMaxWidth().padding(end = scrollbarContentSafePadding()), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + GroupHeader("Default banner (aka editor banners)") + + InformationDefaultBanner( + style = JewelTheme.defaultBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + actions = { + Link("Action A", onClick = { clickLabel = "Info default no icon Action A clicked" }) + Link("Action B", onClick = { clickLabel = "Info default no icon Action B clicked" }) + }, + ) + + InformationDefaultBanner( + style = JewelTheme.defaultBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + icon = null, + actions = { + Link("Action A", onClick = { clickLabel = "Info default no icon Action A clicked" }) + Link("Action B", onClick = { clickLabel = "Info default no icon Action B clicked" }) + }, + ) + + InformationDefaultBanner(style = JewelTheme.defaultBannerStyle.information, text = LONG_IPSUM) + + InformationDefaultBanner( + style = JewelTheme.defaultBannerStyle.information, + text = LONG_IPSUM, + icon = null, + ) + + InformationDefaultBanner( + style = JewelTheme.defaultBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + ) + + SuccessDefaultBanner( + style = JewelTheme.defaultBannerStyle.success, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + ) + + WarningDefaultBanner( + style = JewelTheme.defaultBannerStyle.warning, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + ) + + ErrorDefaultBanner( + style = JewelTheme.defaultBannerStyle.error, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + ) + + Spacer(Modifier.height(8.dp)) + + GroupHeader("Inline banner") + + InformationInlineBanner( + icon = null, + style = JewelTheme.inlineBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + ) + + InformationInlineBanner( + icon = null, + style = JewelTheme.inlineBannerStyle.information, + text = LONG_IPSUM, + actionIcons = { + IconButton(onClick = { clickLabel = "Info inline no icon Action Icon clicked" }) { + Icon(AllIconsKeys.General.Close, null) + } + }, + ) + + InformationInlineBanner( + icon = null, + style = JewelTheme.inlineBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + actions = { + Link("Action A", onClick = { clickLabel = "Info inline no icon Action A clicked" }) + Link("Action B", onClick = { clickLabel = "Info inline no icon Action B clicked" }) + }, + ) + + InformationInlineBanner( + icon = null, + style = JewelTheme.inlineBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + actionIcons = { + IconButton(onClick = { clickLabel = "Info inline no icon Action Icon clicked" }) { + Icon(AllIconsKeys.General.Close, null) + } + }, + actions = { + Link("Action A", onClick = { clickLabel = "Info inline no icon Action A clicked" }) + Link("Action B", onClick = { clickLabel = "Info inline no icon Action B clicked" }) + }, + ) + + InformationInlineBanner( + style = JewelTheme.inlineBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + ) + ErrorInlineBanner( + style = JewelTheme.inlineBannerStyle.error, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + actionIcons = { + IconButton(onClick = { clickLabel = "Error Inline Action Icon clicked" }) { + Icon(AllIconsKeys.General.Close, null) + } + }, + ) + InformationInlineBanner( + style = JewelTheme.inlineBannerStyle.information, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + actions = { + Link("Action A", onClick = { clickLabel = "Information Inline Action A clicked" }) + Link("Action B", onClick = { clickLabel = "Information Inline Action B clicked" }) + }, + ) + SuccessInlineBanner( + style = JewelTheme.inlineBannerStyle.success, + text = LONG_IPSUM, + actions = { + Link("Action A", onClick = { clickLabel = "Success Inline Action A clicked" }) + Link("Action B", onClick = { clickLabel = "Success Inline Action B clicked" }) + }, + actionIcons = { + IconButton(onClick = { clickLabel = "Error Close Icon clicked" }) { + Icon(AllIconsKeys.General.Close, null) + } + IconButton(onClick = { clickLabel = "Error Gear Icon clicked" }) { + Icon(AllIconsKeys.General.Gear, null) + } + }, + ) + WarningInlineBanner( + style = JewelTheme.inlineBannerStyle.warning, + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", + actions = { Link("Action A", onClick = { clickLabel = "Warning Inline Action A clicked" }) }, + actionIcons = { + IconButton(onClick = { clickLabel = "Error Close Icon clicked" }) { + Icon(AllIconsKeys.General.Close, null) + } + IconButton(onClick = { clickLabel = "Error Gear Icon clicked" }) { + Icon(AllIconsKeys.General.Gear, null) + } + }, + ) + } + } } } diff --git a/ui/api/ui.api b/ui/api/ui.api index a98abaff9..0c7bd5576 100644 --- a/ui/api/ui.api +++ b/ui/api/ui.api @@ -103,13 +103,6 @@ public final class org/jetbrains/jewel/ui/component/ActionButtonKt { public static final fun ActionButton (Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Landroidx/compose/ui/Modifier;ZZLorg/jetbrains/jewel/ui/component/styling/IconButtonStyle;Landroidx/compose/foundation/layout/PaddingValues;Lorg/jetbrains/jewel/ui/component/styling/TooltipStyle;Landroidx/compose/foundation/TooltipPlacement;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V } -public final class org/jetbrains/jewel/ui/component/BannerKt { - public static final fun ErrorBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V - public static final fun InformationBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V - public static final fun SuccessBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V - public static final fun WarningBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V -} - public final class org/jetbrains/jewel/ui/component/ButtonKt { public static final fun DefaultButton (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;ZLandroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/ButtonStyle;Landroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V public static final fun OutlinedButton (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;ZLandroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/ButtonStyle;Landroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V @@ -282,8 +275,8 @@ public final class org/jetbrains/jewel/ui/component/ComboBoxState$Companion { public static synthetic fun of-b6bHBqw$default (Lorg/jetbrains/jewel/ui/component/ComboBoxState$Companion;ZZZZZILjava/lang/Object;)J } -public final class org/jetbrains/jewel/ui/component/ComposableSingletons$BannerKt { - public static final field INSTANCE Lorg/jetbrains/jewel/ui/component/ComposableSingletons$BannerKt; +public final class org/jetbrains/jewel/ui/component/ComposableSingletons$DefaultBannerKt { + public static final field INSTANCE Lorg/jetbrains/jewel/ui/component/ComposableSingletons$DefaultBannerKt; public static field lambda-1 Lkotlin/jvm/functions/Function2; public static field lambda-2 Lkotlin/jvm/functions/Function2; public static field lambda-3 Lkotlin/jvm/functions/Function2; @@ -332,6 +325,13 @@ public final class org/jetbrains/jewel/ui/component/ContextSubmenu : androidx/co public final fun getSubmenu ()Lkotlin/jvm/functions/Function0; } +public final class org/jetbrains/jewel/ui/component/DefaultBannerKt { + public static final fun ErrorDefaultBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V + public static final fun InformationDefaultBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V + public static final fun SuccessDefaultBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V + public static final fun WarningDefaultBanner (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lorg/jetbrains/jewel/ui/component/styling/DefaultBannerStyle;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;II)V +} + public final class org/jetbrains/jewel/ui/component/DividerKt { public static final fun Divider-RLL6an4 (Lorg/jetbrains/jewel/ui/Orientation;Landroidx/compose/ui/Modifier;JFFLorg/jetbrains/jewel/ui/component/styling/DividerStyle;Landroidx/compose/runtime/Composer;II)V } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Banner.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/DefaultBanner.kt similarity index 74% rename from ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Banner.kt rename to ui/src/main/kotlin/org/jetbrains/jewel/ui/component/DefaultBanner.kt index 42bc155ed..7ae154d77 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Banner.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/DefaultBanner.kt @@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import org.jetbrains.jewel.foundation.theme.JewelTheme import org.jetbrains.jewel.ui.Orientation @@ -23,7 +24,7 @@ import org.jetbrains.jewel.ui.icons.AllIconsKeys import org.jetbrains.jewel.ui.theme.defaultBannerStyle @Composable -public fun InformationBanner( +public fun InformationDefaultBanner( text: String, modifier: Modifier = Modifier, icon: (@Composable () -> Unit)? = { Icon(AllIconsKeys.General.BalloonInformation, null) }, @@ -31,11 +32,18 @@ public fun InformationBanner( style: DefaultBannerStyle = JewelTheme.defaultBannerStyle.information, textStyle: TextStyle = JewelTheme.defaultTextStyle, ) { - BannerImpl(text = text, style = style, textStyle = textStyle, icon = icon, actions = actions, modifier = modifier) + DefaultBannerImpl( + text = text, + style = style, + textStyle = textStyle, + icon = icon, + actions = actions, + modifier = modifier, + ) } @Composable -public fun SuccessBanner( +public fun SuccessDefaultBanner( text: String, modifier: Modifier = Modifier, icon: (@Composable () -> Unit)? = { Icon(AllIconsKeys.Debugger.ThreadStates.Idle, null) }, @@ -43,11 +51,18 @@ public fun SuccessBanner( style: DefaultBannerStyle = JewelTheme.defaultBannerStyle.success, textStyle: TextStyle = JewelTheme.defaultTextStyle, ) { - BannerImpl(text = text, style = style, textStyle = textStyle, icon = icon, actions = actions, modifier = modifier) + DefaultBannerImpl( + text = text, + style = style, + textStyle = textStyle, + icon = icon, + actions = actions, + modifier = modifier, + ) } @Composable -public fun WarningBanner( +public fun WarningDefaultBanner( text: String, modifier: Modifier = Modifier, icon: (@Composable () -> Unit)? = { Icon(AllIconsKeys.General.BalloonWarning, null) }, @@ -55,11 +70,18 @@ public fun WarningBanner( style: DefaultBannerStyle = JewelTheme.defaultBannerStyle.warning, textStyle: TextStyle = JewelTheme.defaultTextStyle, ) { - BannerImpl(text = text, style = style, textStyle = textStyle, icon = icon, actions = actions, modifier = modifier) + DefaultBannerImpl( + text = text, + style = style, + textStyle = textStyle, + icon = icon, + actions = actions, + modifier = modifier, + ) } @Composable -public fun ErrorBanner( +public fun ErrorDefaultBanner( text: String, modifier: Modifier = Modifier, icon: (@Composable () -> Unit)? = { Icon(AllIconsKeys.General.BalloonError, null) }, @@ -67,11 +89,18 @@ public fun ErrorBanner( style: DefaultBannerStyle = JewelTheme.defaultBannerStyle.error, textStyle: TextStyle = JewelTheme.defaultTextStyle, ) { - BannerImpl(text = text, style = style, textStyle = textStyle, icon = icon, actions = actions, modifier = modifier) + DefaultBannerImpl( + text = text, + style = style, + textStyle = textStyle, + icon = icon, + actions = actions, + modifier = modifier, + ) } @Composable -private fun BannerImpl( +private fun DefaultBannerImpl( text: String, style: DefaultBannerStyle, textStyle: TextStyle, @@ -89,9 +118,18 @@ private fun BannerImpl( Box(Modifier.size(16.dp), contentAlignment = Alignment.Center) { icon() } Spacer(modifier = Modifier.width(8.dp)) } - Text(text = text, style = textStyle) - Spacer(modifier = Modifier.weight(1f)) + + Text( + text = text, + modifier = Modifier.weight(1f), + style = textStyle, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + if (actions != null) { + Spacer(Modifier.width(8.dp)) + Row( horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/InlineBanner.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/InlineBanner.kt index 7f8f80f65..ace3c27bb 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/InlineBanner.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/InlineBanner.kt @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -36,6 +35,7 @@ import org.jetbrains.jewel.foundation.theme.LocalContentColor import org.jetbrains.jewel.ui.component.styling.InlineBannerStyle import org.jetbrains.jewel.ui.icons.AllIconsKeys import org.jetbrains.jewel.ui.theme.inlineBannerStyle +import org.jetbrains.jewel.ui.util.thenIf @Composable public fun InformationInlineBanner( @@ -133,12 +133,6 @@ private fun InlineBannerImpl( modifier: Modifier, ) { val borderColor = style.colors.border - val containerPadding = - if (actionIcons == null) { - PaddingValues(12.dp) - } else { - PaddingValues(start = 12.dp, top = 8.dp, end = 8.dp, bottom = 10.dp) - } RoundedCornerBox( modifier = modifier.testTag("InlineBanner"), borderColor = borderColor, @@ -146,24 +140,36 @@ private fun InlineBannerImpl( contentColor = JewelTheme.contentColor, borderWidth = 1.dp, cornerSize = CornerSize(8.dp), - padding = containerPadding, + padding = PaddingValues(), ) { - val verticalAlignment = if (actions == null) Alignment.CenterVertically else Alignment.Top - Row(verticalAlignment = verticalAlignment) { + Row(modifier = Modifier.padding(start = 12.dp)) { if (icon != null) { - Box(modifier = Modifier.size(16.dp)) { icon() } + Box(modifier = Modifier.padding(top = 12.dp, bottom = 12.dp).size(16.dp)) { icon() } + Spacer(Modifier.width(8.dp)) } - Spacer(Modifier.width(12.dp)) - Column(modifier = Modifier.weight(1f).align(verticalAlignment)) { - Text(text = text, style = textStyle, modifier = Modifier.fillMaxWidth()) + + Column( + modifier = + Modifier.weight(1f) + .padding(top = 12.dp, bottom = 12.dp) // kftmt plz behave + .thenIf(actionIcons == null) { padding(end = 12.dp) } + ) { + Text(text = text, style = textStyle) + if (actions != null) { Spacer(Modifier.height(8.dp)) FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) { actions() } } } + if (actionIcons != null) { - Spacer(Modifier.width(12.dp)) - Row(modifier = Modifier.align(Alignment.Top), verticalAlignment = Alignment.Top) { actionIcons() } + Spacer(Modifier.width(8.dp)) + Row( + modifier = Modifier.align(Alignment.Top).padding(top = 8.dp, end = 8.dp, bottom = 8.dp), + horizontalArrangement = Arrangement.spacedBy(2.dp), + ) { + actionIcons() + } } } }