-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[JEWEL-1069] Implement slim button #3360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
018413d to
8ec611c
Compare
faogustavo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the ad text. Just make sure to follow the deprecation cycle (keeping a method with the old signature to prevent breaking changes) and make sure you update the API Dumps
| menuStyle: MenuStyle = MenuStyle.dark(), | ||
| outlinedButtonStyle: ButtonStyle = ButtonStyle.Outlined.dark(), | ||
| defaultSlimButtonStyle: ButtonStyle = ButtonStyle.Slim.dark(), | ||
| outlinedSlimButtonStyle: ButtonStyle = ButtonStyle.Slim.dark(colors = ButtonColors.Outlined.dark()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecation cycle :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
8ec611c to
c5eae77
Compare
| private fun buttonCornerSize(): CornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp.safeValue() / 2) | ||
|
|
||
| private fun createSlimButtonStyle(colors: ButtonColors): ButtonStyle { | ||
| return ButtonStyle( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: please use expression style
| focusOutlineExpand: Dp = 1.5.dp, | ||
| ): ButtonMetrics = ButtonMetrics(cornerSize, padding, minSize, borderWidth, focusOutlineExpand) | ||
|
|
||
| public val ButtonStyle.Companion.Slim: IntUiSlimButtonStyleFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to have the Slim factory — which is a good idea — we need to have an API that looks the same as the non-slim variants. This means you need something like:
public val ButtonStyle.Companion.Slim: IntUiSlimButtonStyleFactory
public object IntUiSlimButtonStyleFactory {
val Outlined = IntUiSlimOutlinedButtonStyleFactory
val Default = IntUiSlimDefaultButtonStyleFactory
}
public object IntUiSlimOutlinedButtonStyleFactory {
public fun light(...): ButtonStyle = ...
public fun dark(...): ButtonStyle = ...
}
public object IntUiSlimDefaultButtonStyleFactory {
public fun light(...): ButtonStyle = ...
public fun dark(...): ButtonStyle = ...
}| * **Swing equivalent:** [`JButton`](https://docs.oracle.com/javase/tutorial/uiswing/components/button.html) with | ||
| * reduced insets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"with reduced insets" is wrong — it is a JButton for which DarculaButtonUi.isSmallVariant(button) returns true. That is, it has b.getClientProperty("ActionToolbar.smallVariant") == true
| * **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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto as above
Summary
This PR introduces a new button variant called
SlimButton, which has bothdefaultandoutlinedstyles and it's intended to be used in toolbars and space-constrained UIs. As part of the public API, there are bothDefaultSlimButtonandOutlinedSlimButton, following the pattern for other button variants.A slim button section was added to the sample app, showcasing how it looks like.
Release notes
New features
SlimButton, which has bothDefaultSlimButtonandOutlinedSlimButtonstylesNote
Adds a compact button variant for space-constrained UIs.
DefaultSlimButtonandOutlinedSlimButtoncomponents with reduced padding/height (24dp) and toolbar-friendly metricsButtonMetrics.slimandButtonStyle.Slimfactories in Int UI stylingdefaultSlimButtonStyle/outlinedSlimButtonStyleviaJewelTheme, composition locals, andDefaultComponentStyling; integrates into IntUi themes and Swing bridge readersWritten by Cursor Bugbot for commit 018413d. This will update automatically on new commits. Configure here.