Skip to content

Commit

Permalink
add inline banner
Browse files Browse the repository at this point in the history
reference JetBrains/jewel#711

Signed-off-by: Ivan Morgillo <[email protected]>

closes #2906

GitOrigin-RevId: 3a3f026241884c7ec8a79fc225ea49da1f05d0bc
  • Loading branch information
hamen authored and intellij-monorepo-bot committed Jan 15, 2025
1 parent bf6a378 commit 20454d0
Show file tree
Hide file tree
Showing 16 changed files with 925 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ internal fun createBridgeComponentStyling(theme: ThemeDefinition): ComponentStyl
groupHeaderStyle = readGroupHeaderStyle(),
horizontalProgressBarStyle = readHorizontalProgressBarStyle(),
iconButtonStyle = readIconButtonStyle(),
inlineBannerStyle = readInlineBannerStyle(),
lazyTreeStyle = readLazyTreeStyle(),
linkStyle = readLinkStyle(),
menuStyle = menuStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.jetbrains.jewel.ui.component.styling.BannerColors
import org.jetbrains.jewel.ui.component.styling.BannerMetrics
import org.jetbrains.jewel.ui.component.styling.DefaultBannerStyle
import org.jetbrains.jewel.ui.component.styling.DefaultBannerStyles
import org.jetbrains.jewel.ui.component.styling.InlineBannerStyle
import org.jetbrains.jewel.ui.component.styling.InlineBannerStyles

internal fun readDefaultBannerStyle(): DefaultBannerStyles =
DefaultBannerStyles(
Expand Down Expand Up @@ -48,3 +50,43 @@ internal fun readDefaultBannerStyle(): DefaultBannerStyles =
metrics = BannerMetrics(borderWidth = DarculaUIUtil.LW.dp),
),
)

internal fun readInlineBannerStyle(): InlineBannerStyles =
InlineBannerStyles(
information =
InlineBannerStyle(
colors =
BannerColors(
background = JBUI.CurrentTheme.Banner.INFO_BACKGROUND.toComposeColor(),
border = JBUI.CurrentTheme.Banner.INFO_BORDER_COLOR.toComposeColor(),
),
metrics = BannerMetrics(borderWidth = DarculaUIUtil.LW.dp),
),
success =
InlineBannerStyle(
colors =
BannerColors(
background = JBUI.CurrentTheme.Banner.SUCCESS_BACKGROUND.toComposeColor(),
border = JBUI.CurrentTheme.Banner.SUCCESS_BORDER_COLOR.toComposeColor(),
),
metrics = BannerMetrics(borderWidth = DarculaUIUtil.LW.dp),
),
warning =
InlineBannerStyle(
colors =
BannerColors(
background = JBUI.CurrentTheme.Banner.WARNING_BACKGROUND.toComposeColor(),
border = JBUI.CurrentTheme.Banner.WARNING_BORDER_COLOR.toComposeColor(),
),
metrics = BannerMetrics(borderWidth = DarculaUIUtil.LW.dp),
),
error =
InlineBannerStyle(
colors =
BannerColors(
background = JBUI.CurrentTheme.Banner.ERROR_BACKGROUND.toComposeColor(),
border = JBUI.CurrentTheme.Banner.ERROR_BORDER_COLOR.toComposeColor(),
),
metrics = BannerMetrics(borderWidth = DarculaUIUtil.LW.dp),
),
)
82 changes: 56 additions & 26 deletions platform/jewel/int-ui/int-ui-standalone/api-dump-unreviewed.txt

Large diffs are not rendered by default.

108 changes: 74 additions & 34 deletions platform/jewel/int-ui/int-ui-standalone/api/int-ui-standalone.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import org.jetbrains.jewel.ui.component.styling.BannerColors
import org.jetbrains.jewel.ui.component.styling.BannerMetrics
import org.jetbrains.jewel.ui.component.styling.DefaultBannerStyle
import org.jetbrains.jewel.ui.component.styling.DefaultBannerStyles
import org.jetbrains.jewel.ui.component.styling.InlineBannerStyle
import org.jetbrains.jewel.ui.component.styling.InlineBannerStyles

public val DefaultBannerStyles.Companion.Default: IntUiDefaultBannerStylesFactory
get() = IntUiDefaultBannerStylesFactory
Expand All @@ -34,8 +36,6 @@ public object IntUiDefaultBannerStylesFactory {
DefaultBannerStyles(information = information, success = success, warning = warning, error = error)
}

public fun BannerMetrics.Companion.default(borderWidth: Dp = 1.dp): BannerMetrics = BannerMetrics(borderWidth)

// region Information Banner
public val DefaultBannerStyle.Companion.Information: IntUiDefaultInformationBannerStyleFactory
get() = IntUiDefaultInformationBannerStyleFactory
Expand All @@ -54,10 +54,10 @@ public object IntUiDefaultInformationBannerStyleFactory {
): DefaultBannerStyle = DefaultBannerStyle(colors = colors, metrics = metrics)
}

public val BannerColors.Companion.Information: IntUiDefaultInformationBannerColorFactory
get() = IntUiDefaultInformationBannerColorFactory
public val BannerColors.Companion.Information: IntUiInformationBannerColorFactory
get() = IntUiInformationBannerColorFactory

public object IntUiDefaultInformationBannerColorFactory {
public object IntUiInformationBannerColorFactory {
@Composable
public fun light(
background: Color = IntUiLightTheme.colors.blue(13),
Expand Down Expand Up @@ -91,10 +91,7 @@ public object IntUiDefaultSuccessBannerStyleFactory {
): DefaultBannerStyle = DefaultBannerStyle(colors = colors, metrics = metrics)
}

public val BannerColors.Companion.Success: IntUiDefaultSuccessBannerColorFactory
get() = IntUiDefaultSuccessBannerColorFactory

public object IntUiDefaultSuccessBannerColorFactory {
public object IntUiSuccessBannerColorFactory {
@Composable
public fun light(
background: Color = IntUiLightTheme.colors.green(11),
Expand Down Expand Up @@ -128,10 +125,10 @@ public object IntUiDefaultWarningBannerStyleFactory {
): DefaultBannerStyle = DefaultBannerStyle(colors = colors, metrics = metrics)
}

public val BannerColors.Companion.Warning: IntUiDefaultWarningBannerColorFactory
get() = IntUiDefaultWarningBannerColorFactory
public val BannerColors.Companion.Warning: IntUiWarningBannerColorFactory
get() = IntUiWarningBannerColorFactory

public object IntUiDefaultWarningBannerColorFactory {
public object IntUiWarningBannerColorFactory {
@Composable
public fun light(
background: Color = IntUiLightTheme.colors.yellow(10),
Expand Down Expand Up @@ -165,10 +162,10 @@ public object IntUiDefaultErrorBannerStyleFactory {
): DefaultBannerStyle = DefaultBannerStyle(colors = colors, metrics = metrics)
}

public val BannerColors.Companion.Error: IntUiDefaultErrorBannerColorFactory
get() = IntUiDefaultErrorBannerColorFactory
public val BannerColors.Companion.Error: IntUiErrorBannerColorFactory
get() = IntUiErrorBannerColorFactory

public object IntUiDefaultErrorBannerColorFactory {
public object IntUiErrorBannerColorFactory {
@Composable
public fun light(
background: Color = IntUiLightTheme.colors.red(12),
Expand All @@ -181,4 +178,112 @@ public object IntUiDefaultErrorBannerColorFactory {
border: Color = IntUiDarkTheme.colors.red(3),
): BannerColors = BannerColors(background = background, border = border)
}

// endregion

public val InlineBannerStyles.Companion.Default: IntUiInlineBannerStylesFactory
get() = IntUiInlineBannerStylesFactory

public object IntUiInlineBannerStylesFactory {
@Composable
public fun light(
information: InlineBannerStyle = InlineBannerStyle.Information.light(),
success: InlineBannerStyle = InlineBannerStyle.Success.light(),
warning: InlineBannerStyle = InlineBannerStyle.Warning.light(),
error: InlineBannerStyle = InlineBannerStyle.Error.light(),
): InlineBannerStyles =
InlineBannerStyles(information = information, success = success, warning = warning, error = error)

@Composable
public fun dark(
information: InlineBannerStyle = InlineBannerStyle.Information.dark(),
success: InlineBannerStyle = InlineBannerStyle.Success.dark(),
warning: InlineBannerStyle = InlineBannerStyle.Warning.dark(),
error: InlineBannerStyle = InlineBannerStyle.Error.dark(),
): InlineBannerStyles =
InlineBannerStyles(information = information, success = success, warning = warning, error = error)
}

public fun BannerMetrics.Companion.default(borderWidth: Dp = 1.dp): BannerMetrics = BannerMetrics(borderWidth)

// region Inline Information Banner
public val InlineBannerStyle.Companion.Information: IntUiInlineInformationBannerStyleFactory
get() = IntUiInlineInformationBannerStyleFactory

public object IntUiInlineInformationBannerStyleFactory {
@Composable
public fun light(
colors: BannerColors = BannerColors.Information.light(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)

@Composable
public fun dark(
colors: BannerColors = BannerColors.Information.dark(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)
}

// endregion

// region Inline Success Banner
public val InlineBannerStyle.Companion.Success: IntUiInlineSuccessBannerStyleFactory
get() = IntUiInlineSuccessBannerStyleFactory

public object IntUiInlineSuccessBannerStyleFactory {
@Composable
public fun light(
colors: BannerColors = BannerColors.Success.light(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)

@Composable
public fun dark(
colors: BannerColors = BannerColors.Success.dark(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)
}

public val BannerColors.Companion.Success: IntUiSuccessBannerColorFactory
get() = IntUiSuccessBannerColorFactory

// endregion

// region Inline Warning Banner
public val InlineBannerStyle.Companion.Warning: IntUiInlineWarningBannerStyleFactory
get() = IntUiInlineWarningBannerStyleFactory

public object IntUiInlineWarningBannerStyleFactory {
@Composable
public fun light(
colors: BannerColors = BannerColors.Warning.light(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)

@Composable
public fun dark(
colors: BannerColors = BannerColors.Warning.dark(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)
}

// endregion

// region Inline Error Banner
public val InlineBannerStyle.Companion.Error: IntUiInlineErrorBannerStyleFactory
get() = IntUiInlineErrorBannerStyleFactory

public object IntUiInlineErrorBannerStyleFactory {
@Composable
public fun light(
colors: BannerColors = BannerColors.Error.light(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)

@Composable
public fun dark(
colors: BannerColors = BannerColors.Error.dark(),
metrics: BannerMetrics = BannerMetrics.default(),
): InlineBannerStyle = InlineBannerStyle(colors = colors, metrics = metrics)
}
// endregion
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.jetbrains.jewel.ui.component.styling.DropdownStyle
import org.jetbrains.jewel.ui.component.styling.GroupHeaderStyle
import org.jetbrains.jewel.ui.component.styling.HorizontalProgressBarStyle
import org.jetbrains.jewel.ui.component.styling.IconButtonStyle
import org.jetbrains.jewel.ui.component.styling.InlineBannerStyles
import org.jetbrains.jewel.ui.component.styling.LazyTreeStyle
import org.jetbrains.jewel.ui.component.styling.LinkStyle
import org.jetbrains.jewel.ui.component.styling.MenuStyle
Expand Down Expand Up @@ -121,6 +122,7 @@ public fun ComponentStyling.dark(
groupHeaderStyle: GroupHeaderStyle = GroupHeaderStyle.dark(),
horizontalProgressBarStyle: HorizontalProgressBarStyle = HorizontalProgressBarStyle.dark(),
iconButtonStyle: IconButtonStyle = IconButtonStyle.dark(),
inlineBannerStyle: InlineBannerStyles = InlineBannerStyles.Default.dark(),
lazyTreeStyle: LazyTreeStyle = LazyTreeStyle.dark(),
linkStyle: LinkStyle = LinkStyle.dark(),
menuStyle: MenuStyle = MenuStyle.dark(),
Expand Down Expand Up @@ -153,6 +155,7 @@ public fun ComponentStyling.dark(
groupHeaderStyle = groupHeaderStyle,
horizontalProgressBarStyle = horizontalProgressBarStyle,
iconButtonStyle = iconButtonStyle,
inlineBannerStyle = inlineBannerStyle,
lazyTreeStyle = lazyTreeStyle,
linkStyle = linkStyle,
menuStyle = menuStyle,
Expand Down Expand Up @@ -187,6 +190,7 @@ public fun ComponentStyling.light(
groupHeaderStyle: GroupHeaderStyle = GroupHeaderStyle.light(),
horizontalProgressBarStyle: HorizontalProgressBarStyle = HorizontalProgressBarStyle.light(),
iconButtonStyle: IconButtonStyle = IconButtonStyle.light(),
inlineBannerStyle: InlineBannerStyles = InlineBannerStyles.Default.light(),
lazyTreeStyle: LazyTreeStyle = LazyTreeStyle.light(),
linkStyle: LinkStyle = LinkStyle.light(),
menuStyle: MenuStyle = MenuStyle.light(),
Expand Down Expand Up @@ -219,6 +223,7 @@ public fun ComponentStyling.light(
groupHeaderStyle = groupHeaderStyle,
horizontalProgressBarStyle = horizontalProgressBarStyle,
iconButtonStyle = iconButtonStyle,
inlineBannerStyle = inlineBannerStyle,
lazyTreeStyle = lazyTreeStyle,
linkStyle = linkStyle,
menuStyle = menuStyle,
Expand Down
Loading

0 comments on commit 20454d0

Please sign in to comment.