Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ internal fun createBridgeComponentStyling(theme: ThemeDefinition): ComponentStyl
linkStyle = readLinkStyle(),
menuStyle = menuStyle,
outlinedButtonStyle = readOutlinedButtonStyle(),
defaultSlimButtonStyle = readDefaultSlimButtonStyle(),
outlinedSlimButtonStyle = readOutlinedSlimButtonStyle(),
outlinedSplitButtonStyle = readOutlinedSplitButtonStyle(),
popupContainerStyle = readPopupContainerStyle(),
radioButtonStyle = readRadioButtonStyle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,29 @@ internal fun readOutlinedButtonStyle(): ButtonStyle {
)
}

internal fun readDefaultSlimButtonStyle(): ButtonStyle {
val defaultButtonStyle = readDefaultButtonStyle()
return createSlimButtonStyle(colors = defaultButtonStyle.colors)
}

internal fun readOutlinedSlimButtonStyle(): ButtonStyle {
val outlinedButtonStyle = readOutlinedButtonStyle()
return createSlimButtonStyle(colors = outlinedButtonStyle.colors)
}

private fun buttonCornerSize(): CornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp.safeValue() / 2)

private fun createSlimButtonStyle(colors: ButtonColors): ButtonStyle {
return ButtonStyle(
colors = colors,
metrics =
ButtonMetrics(
cornerSize = buttonCornerSize(),
padding = PaddingValues(horizontal = 8.dp, vertical = 2.dp),
minSize = DpSize(60.dp, 24.dp),
borderWidth = borderWidth,
focusOutlineExpand = 1.5.dp,
),
focusOutlineAlignment = Stroke.Alignment.Center,
)
}
34 changes: 24 additions & 10 deletions platform/jewel/int-ui/int-ui-standalone/api-dump.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,28 @@ public fun ButtonMetrics.Companion.outlined(
borderWidth: Dp = 1.dp,
focusOutlineExpand: Dp = Dp.Unspecified,
): ButtonMetrics = ButtonMetrics(cornerSize, padding, minSize, borderWidth, focusOutlineExpand)

public fun ButtonMetrics.Companion.slim(
cornerSize: CornerSize = CornerSize(4.dp),
padding: PaddingValues = PaddingValues(horizontal = 8.dp, vertical = 2.dp),
minSize: DpSize = DpSize(60.dp, 24.dp),
borderWidth: Dp = 1.dp,
focusOutlineExpand: Dp = 1.5.dp,
): ButtonMetrics = ButtonMetrics(cornerSize, padding, minSize, borderWidth, focusOutlineExpand)

public val ButtonStyle.Companion.Slim: IntUiSlimButtonStyleFactory
get() = IntUiSlimButtonStyleFactory

public object IntUiSlimButtonStyleFactory {
public fun light(
colors: ButtonColors = ButtonColors.Default.light(),
metrics: ButtonMetrics = ButtonMetrics.slim(),
focusOutlineAlignment: Stroke.Alignment = Stroke.Alignment.Center,
): ButtonStyle = ButtonStyle(colors, metrics, focusOutlineAlignment)

public fun dark(
colors: ButtonColors = ButtonColors.Default.dark(),
metrics: ButtonMetrics = ButtonMetrics.slim(),
focusOutlineAlignment: Stroke.Alignment = Stroke.Alignment.Center,
): ButtonStyle = ButtonStyle(colors, metrics, focusOutlineAlignment)
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.foundation.util.JewelLogger
import org.jetbrains.jewel.ui.component.ActionButton
import org.jetbrains.jewel.ui.component.DefaultButton
import org.jetbrains.jewel.ui.component.DefaultSlimButton
import org.jetbrains.jewel.ui.component.DefaultSplitButton
import org.jetbrains.jewel.ui.component.GroupHeader
import org.jetbrains.jewel.ui.component.Icon
Expand All @@ -36,6 +37,7 @@ import org.jetbrains.jewel.ui.component.IconButton
import org.jetbrains.jewel.ui.component.InfoText
import org.jetbrains.jewel.ui.component.MenuScope
import org.jetbrains.jewel.ui.component.OutlinedButton
import org.jetbrains.jewel.ui.component.OutlinedSlimButton
import org.jetbrains.jewel.ui.component.OutlinedSplitButton
import org.jetbrains.jewel.ui.component.SelectableIconActionButton
import org.jetbrains.jewel.ui.component.SelectableIconButton
Expand Down Expand Up @@ -91,6 +93,23 @@ private fun NormalButtons() {

DefaultButton(onClick = {}, enabled = false) { SingleLineText("Default disabled") }
}

GroupHeader("Slim buttons")

FlowRow(
Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
itemVerticalAlignment = Alignment.CenterVertically,
) {
DefaultSlimButton(onClick = {}) { SingleLineText("Slim Default") }

DefaultSlimButton(onClick = {}, enabled = false) { SingleLineText("Slim Disabled") }

OutlinedSlimButton(onClick = {}) { SingleLineText("Outlined Slim") }

OutlinedSlimButton(onClick = {}, enabled = false) { SingleLineText("Outlined Slim Disabled") }
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.jetbrains.jewel.ui.component.styling.LocalDefaultBannerStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultComboBoxStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultDropdownStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultSlimButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultSplitButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalDividerStyle
Expand All @@ -41,6 +42,7 @@ import org.jetbrains.jewel.ui.component.styling.LocalLazyTreeStyle
import org.jetbrains.jewel.ui.component.styling.LocalLinkStyle
import org.jetbrains.jewel.ui.component.styling.LocalMenuStyle
import org.jetbrains.jewel.ui.component.styling.LocalOutlinedButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalOutlinedSlimButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalOutlinedSplitButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalPopupContainerStyle
import org.jetbrains.jewel.ui.component.styling.LocalRadioButtonStyle
Expand Down Expand Up @@ -99,6 +101,8 @@ public class DefaultComponentStyling(
public val linkStyle: LinkStyle,
public val menuStyle: MenuStyle,
public val outlinedButtonStyle: ButtonStyle,
public val defaultSlimButtonStyle: ButtonStyle,
public val outlinedSlimButtonStyle: ButtonStyle,
public val popupContainerStyle: PopupContainerStyle,
public val outlinedSplitButtonStyle: SplitButtonStyle,
public val radioButtonStyle: RadioButtonStyle,
Expand Down Expand Up @@ -137,6 +141,8 @@ public class DefaultComponentStyling(
linkStyle: LinkStyle,
menuStyle: MenuStyle,
outlinedButtonStyle: ButtonStyle,
defaultSlimButtonStyle: ButtonStyle,
outlinedSlimButtonStyle: ButtonStyle,
popupContainerStyle: PopupContainerStyle,
outlinedSplitButtonStyle: SplitButtonStyle,
radioButtonStyle: RadioButtonStyle,
Expand Down Expand Up @@ -171,6 +177,8 @@ public class DefaultComponentStyling(
linkStyle,
menuStyle,
outlinedButtonStyle,
defaultSlimButtonStyle,
outlinedSlimButtonStyle,
popupContainerStyle,
outlinedSplitButtonStyle,
radioButtonStyle,
Expand Down Expand Up @@ -209,6 +217,8 @@ public class DefaultComponentStyling(
linkStyle: LinkStyle,
menuStyle: MenuStyle,
outlinedButtonStyle: ButtonStyle,
defaultSlimButtonStyle: ButtonStyle,
outlinedSlimButtonStyle: ButtonStyle,
popupContainerStyle: PopupContainerStyle,
outlinedSplitButtonStyle: SplitButtonStyle,
radioButtonStyle: RadioButtonStyle,
Expand Down Expand Up @@ -243,6 +253,8 @@ public class DefaultComponentStyling(
linkStyle,
menuStyle,
outlinedButtonStyle,
defaultSlimButtonStyle,
outlinedSlimButtonStyle,
popupContainerStyle,
outlinedSplitButtonStyle,
radioButtonStyle,
Expand Down Expand Up @@ -285,6 +297,8 @@ public class DefaultComponentStyling(
LocalLinkStyle provides linkStyle,
LocalMenuStyle provides menuStyle,
LocalOutlinedButtonStyle provides outlinedButtonStyle,
LocalDefaultSlimButtonStyle provides defaultSlimButtonStyle,
LocalOutlinedSlimButtonStyle provides outlinedSlimButtonStyle,
LocalPopupContainerStyle provides popupContainerStyle,
LocalOutlinedSplitButtonStyle provides outlinedSplitButtonStyle,
LocalRadioButtonStyle provides radioButtonStyle,
Expand Down Expand Up @@ -328,6 +342,8 @@ public class DefaultComponentStyling(
if (linkStyle != other.linkStyle) return false
if (menuStyle != other.menuStyle) return false
if (outlinedButtonStyle != other.outlinedButtonStyle) return false
if (defaultSlimButtonStyle != other.defaultSlimButtonStyle) return false
if (outlinedSlimButtonStyle != other.outlinedSlimButtonStyle) return false
if (popupContainerStyle != other.popupContainerStyle) return false
if (outlinedSplitButtonStyle != other.outlinedSplitButtonStyle) return false
if (radioButtonStyle != other.radioButtonStyle) return false
Expand Down Expand Up @@ -368,6 +384,8 @@ public class DefaultComponentStyling(
result = 31 * result + linkStyle.hashCode()
result = 31 * result + menuStyle.hashCode()
result = 31 * result + outlinedButtonStyle.hashCode()
result = 31 * result + defaultSlimButtonStyle.hashCode()
result = 31 * result + outlinedSlimButtonStyle.hashCode()
result = 31 * result + popupContainerStyle.hashCode()
result = 31 * result + outlinedSplitButtonStyle.hashCode()
result = 31 * result + radioButtonStyle.hashCode()
Expand Down Expand Up @@ -408,6 +426,8 @@ public class DefaultComponentStyling(
"linkStyle=$linkStyle, " +
"menuStyle=$menuStyle, " +
"outlinedButtonStyle=$outlinedButtonStyle, " +
"defaultSlimButtonStyle=$defaultSlimButtonStyle, " +
"outlinedSlimButtonStyle=$outlinedSlimButtonStyle, " +
"popupContainerStyle=$popupContainerStyle, " +
"outlinedSplitButtonStyle=$outlinedSplitButtonStyle, " +
"radioButtonStyle=$radioButtonStyle, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ import org.jetbrains.jewel.ui.focusOutline
import org.jetbrains.jewel.ui.icons.AllIconsKeys
import org.jetbrains.jewel.ui.painter.hints.Stroke as PainterHintStroke
import org.jetbrains.jewel.ui.theme.defaultButtonStyle
import org.jetbrains.jewel.ui.theme.defaultSlimButtonStyle
import org.jetbrains.jewel.ui.theme.defaultSplitButtonStyle
import org.jetbrains.jewel.ui.theme.menuStyle
import org.jetbrains.jewel.ui.theme.outlinedButtonStyle
import org.jetbrains.jewel.ui.theme.outlinedSlimButtonStyle
import org.jetbrains.jewel.ui.theme.outlinedSplitButtonStyle

/**
Expand Down Expand Up @@ -167,6 +169,101 @@ public fun OutlinedButton(
)
}

/**
* A compact button with reduced padding and height, ideal for toolbars and space-constrained UIs.
*
* Mimics the appearance of toolbar buttons with `ActionToolbar.smallVariant = true`. Uses the default button visual
* treatment with compact metrics (24dp height vs 28dp for standard buttons).
*
* **Guidelines:** [on IJP SDK webhelp](https://plugins.jetbrains.com/docs/intellij/button.html)
*
* **Usage example:**
* [`Buttons.kt`](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Buttons.kt)
*
* **Swing equivalent:** [`JButton`](https://docs.oracle.com/javase/tutorial/uiswing/components/button.html) with
* reduced insets
*
* @param onClick Will be called when the user clicks the button
* @param modifier Modifier to be applied to the button
* @param enabled Controls the enabled state of the button. When false, the button will not be clickable
* @param interactionSource An optional [MutableInteractionSource] for observing and emitting [Interaction]s for this
* button. Use this to observe state changes or customize interaction handling
* @param style The visual styling configuration for the button. Defaults to slim button style with default colors
* @param textStyle The typography style to be applied to the button's text content
* @param content The content to be displayed inside the button
* @see javax.swing.JButton
*/
@Composable
public fun DefaultSlimButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
style: ButtonStyle = JewelTheme.defaultSlimButtonStyle,
textStyle: TextStyle = JewelTheme.defaultTextStyle,
content: @Composable () -> Unit,
) {
ButtonImpl(
onClick = onClick,
modifier = modifier,
enabled = enabled,
forceFocused = false,
onStateChange = {},
interactionSource = interactionSource,
style = style,
textStyle = textStyle,
content = content,
)
}

/**
* A compact button with outlined visual style, reduced padding and height, ideal for toolbars and space-constrained
* UIs.
*
* Similar to [DefaultSlimButton] but with an outlined visual treatment. Mimics the appearance of toolbar buttons with
* `ActionToolbar.smallVariant = true`, using compact metrics (24dp height vs 28dp for standard buttons).
*
* **Guidelines:** [on IJP SDK webhelp](https://plugins.jetbrains.com/docs/intellij/button.html)
*
* **Usage example:**
* [`Buttons.kt`](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Buttons.kt)
*
* **Swing equivalent:** [`JButton`](https://docs.oracle.com/javase/tutorial/uiswing/components/button.html) with
* reduced insets
*
* @param onClick Will be called when the user clicks the button
* @param modifier Modifier to be applied to the button
* @param enabled Controls the enabled state of the button. When false, the button will not be clickable
* @param interactionSource An optional [MutableInteractionSource] for observing and emitting [Interaction]s for this
* button. Use this to observe state changes or customize interaction handling
* @param style The visual styling configuration for the button. Defaults to slim button style with outlined colors
* @param textStyle The typography style to be applied to the button's text content
* @param content The content to be displayed inside the button
* @see javax.swing.JButton
*/
@Composable
public fun OutlinedSlimButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
style: ButtonStyle = JewelTheme.outlinedSlimButtonStyle,
textStyle: TextStyle = JewelTheme.defaultTextStyle,
content: @Composable () -> Unit,
) {
ButtonImpl(
onClick = onClick,
modifier = modifier,
enabled = enabled,
forceFocused = false,
onStateChange = {},
interactionSource = interactionSource,
style = style,
textStyle = textStyle,
content = content,
)
}

/**
* A split button combining a primary action with a dropdown menu, using an outlined visual style.
*
Expand Down Expand Up @@ -758,6 +855,7 @@ private fun SplitButtonImpl(
content = secondaryContentMenu,
)
}

secondaryContent != null -> {
PopupContainer(
modifier = splitButtonPopupModifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,11 @@ public val LocalDefaultButtonStyle: ProvidableCompositionLocal<ButtonStyle> = st
public val LocalOutlinedButtonStyle: ProvidableCompositionLocal<ButtonStyle> = staticCompositionLocalOf {
error("No outlined ButtonStyle provided. Have you forgotten the theme?")
}

public val LocalDefaultSlimButtonStyle: ProvidableCompositionLocal<ButtonStyle> = staticCompositionLocalOf {
error("No default slim ButtonStyle provided. Have you forgotten the theme?")
}

public val LocalOutlinedSlimButtonStyle: ProvidableCompositionLocal<ButtonStyle> = staticCompositionLocalOf {
error("No outlined slim ButtonStyle provided. Have you forgotten the theme?")
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.jetbrains.jewel.ui.component.styling.LocalDefaultBannerStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultComboBoxStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultDropdownStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultSlimButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultSplitButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalDividerStyle
Expand All @@ -50,6 +51,7 @@ import org.jetbrains.jewel.ui.component.styling.LocalLazyTreeStyle
import org.jetbrains.jewel.ui.component.styling.LocalLinkStyle
import org.jetbrains.jewel.ui.component.styling.LocalMenuStyle
import org.jetbrains.jewel.ui.component.styling.LocalOutlinedButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalOutlinedSlimButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalOutlinedSplitButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalPopupContainerStyle
import org.jetbrains.jewel.ui.component.styling.LocalRadioButtonStyle
Expand Down Expand Up @@ -101,6 +103,12 @@ public val JewelTheme.Companion.defaultButtonStyle: ButtonStyle
public val JewelTheme.Companion.outlinedButtonStyle: ButtonStyle
@Composable @ReadOnlyComposable get() = LocalOutlinedButtonStyle.current

public val JewelTheme.Companion.defaultSlimButtonStyle: ButtonStyle
@Composable @ReadOnlyComposable get() = LocalDefaultSlimButtonStyle.current

public val JewelTheme.Companion.outlinedSlimButtonStyle: ButtonStyle
@Composable @ReadOnlyComposable get() = LocalOutlinedSlimButtonStyle.current

public val JewelTheme.Companion.defaultSplitButtonStyle: SplitButtonStyle
@Composable @ReadOnlyComposable get() = LocalDefaultSplitButtonStyle.current

Expand Down
Loading