-
Notifications
You must be signed in to change notification settings - Fork 160
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
[Compound] Implement components (Button) #1021
[Compound] Implement components (Button) #1021
Conversation
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #1021 +/- ##
===========================================
+ Coverage 56.90% 57.06% +0.15%
===========================================
Files 994 991 -3
Lines 25291 25271 -20
Branches 5121 5103 -18
===========================================
+ Hits 14393 14421 +28
+ Misses 8624 8604 -20
+ Partials 2274 2246 -28
☔ View full report in Codecov by Sentry. |
5e488bb
to
86d592f
Compare
86d592f
to
531c6ff
Compare
I decided to create a single |
I'd very much like it, sounds very idiomatic. |
1254214
to
0797d98
Compare
f71de7c
to
5e89ed3
Compare
@julioromano sorry for the back and forth, it should be ready for review now |
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.
Some comments to refine the API
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview | ||
import io.element.android.libraries.designsystem.preview.PreviewGroup | ||
import io.element.android.libraries.theme.ElementTheme | ||
|
||
// Designs: https://www.figma.com/file/G1xy0HDZKJf5TCRFmKb5d5/Compound-Android-Components?type=design&mode=design&t=U03tOFZz5FSLVUMa-1 | ||
|
||
@Composable | ||
fun Button( |
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.
Perhaps this can become a private composable that the 3 public one use?
I've seen this pattern in use throughout the compose codebase if I'm not mistaken.
Maybe named "InnerButton" or "ButtonContent"
|
||
@Composable | ||
fun Button( | ||
title: String, |
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.
I'd call this "text" because title seems to assume a style or that there will be other text elements (e.g. a description or subtitle).
contentPadding: PaddingValues = ElementButtonDefaults.ContentPadding, | ||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, | ||
content: @Composable RowScope.() -> Unit | ||
buttonSize: ButtonSize = ButtonSize.Large, |
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.
Prepending these params with "button" seem redundant given the context.
I'd simply go with "size" and "style".
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, | ||
content: @Composable RowScope.() -> Unit | ||
buttonSize: ButtonSize = ButtonSize.Large, | ||
buttonStyle: ButtonStyle = ButtonStyle.Filled, |
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.
This should be removed from the public API surface in favor of using OutlinedButton and TextButton
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.
Proactive LGTM. Please have a look at the comments though.
- Make `ButtonStyle` private. - Rename `title` to `text`. - Rename `buttonStyle` and `buttonSize` to just `style` and `size`.
Kudos, SonarCloud Quality Gate passed! |
Changes
Button
composable, usingButtonStyle
andButtonSize
to customise its size and style (filled, outlined, text).ButtonWithProgress
with this implementation too.Note: there will be some changes in screenshots, especially about TextButtons with different sizes and paddings. I asked @janogarcia about this and it's expected.
Closes element-hq/compound#199