Skip to content
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

Merged
merged 16 commits into from
Aug 8, 2023

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Aug 2, 2023

Changes

  • Implemented Button designs from Figma.
  • Unified all 3 button types in a single Button composable, using ButtonStyle and ButtonSize to customise its size and style (filled, outlined, text).
  • Merged ButtonWithProgress with this implementation too.
  • Replaced all button usages in all components.

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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/73F3Wg

@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Patch coverage: 76.75% and project coverage change: +0.15% 🎉

Comparison is base (c535795) 56.90% compared to head (e0aa9c1) 57.06%.
Report is 4 commits behind head on develop.

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     
Files Changed Coverage Δ
...android/features/invitelist/impl/InviteListView.kt 58.02% <ø> (-0.52%) ⬇️
...ogin/impl/dialogs/SlidingSyncNotSupportedDialog.kt 0.00% <ø> (ø)
...ent/android/features/messages/impl/MessagesView.kt 59.16% <ø> (-0.22%) ⬇️
...impl/attachments/preview/AttachmentsPreviewView.kt 58.66% <0.00%> (+0.77%) ⬆️
...ignsystem/atomic/molecules/ButtonColumnMolecule.kt 53.84% <ø> (ø)
...designsystem/atomic/molecules/ButtonRowMolecule.kt 45.45% <ø> (ø)
...ignsystem/components/dialogs/ConfirmationDialog.kt 62.90% <ø> (+1.36%) ⬆️
...android/libraries/designsystem/ruler/WithRulers.kt 65.21% <ø> (ø)
...eatures/createroom/impl/addpeople/AddPeopleView.kt 43.18% <33.33%> (-1.72%) ⬇️
...nfirmaccountprovider/ConfirmAccountProviderView.kt 36.00% <33.33%> (+0.86%) ⬆️
... and 20 more

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp jmartinesp force-pushed the chore/jme/compound-platform-components-button branch from 5e488bb to 86d592f Compare August 8, 2023 05:51
@jmartinesp jmartinesp force-pushed the chore/jme/compound-platform-components-button branch from 86d592f to 531c6ff Compare August 8, 2023 05:59
@jmartinesp
Copy link
Member Author

jmartinesp commented Aug 8, 2023

I decided to create a single Button component with different ButtonStyles, but if you think some FilledButton/OutlineButton/TextButton helper functions would be useful let me know and I'll add them.

@jmartinesp jmartinesp marked this pull request as ready for review August 8, 2023 06:46
@jmartinesp jmartinesp requested a review from a team as a code owner August 8, 2023 06:47
@jmartinesp jmartinesp requested review from bmarty, a team and julioromano and removed request for a team and bmarty August 8, 2023 06:47
@julioromano
Copy link

I decided to create a single Button component with different ButtonStyles, but if you think some FilledButton/OutlineButton/TextButton helper functions would be useful and I'll add them.

I'd very much like it, sounds very idiomatic.
Since the types are very similar to material's we could still mimic their names:
Button (filled)
OutlinedButton (not filled)
TextButton (no fill, no border)

@jmartinesp jmartinesp force-pushed the chore/jme/compound-platform-components-button branch from 1254214 to 0797d98 Compare August 8, 2023 09:36
@jmartinesp jmartinesp force-pushed the chore/jme/compound-platform-components-button branch from f71de7c to 5e89ed3 Compare August 8, 2023 10:06
@jmartinesp
Copy link
Member Author

@julioromano sorry for the back and forth, it should be ready for review now

Copy link

@julioromano julioromano left a 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(

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,

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,

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,

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

Copy link

@julioromano julioromano left a 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`.
@sonarcloud
Copy link

sonarcloud bot commented Aug 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@jmartinesp jmartinesp added this pull request to the merge queue Aug 8, 2023
Merged via the queue into develop with commit 23982dd Aug 8, 2023
@jmartinesp jmartinesp deleted the chore/jme/compound-platform-components-button branch August 8, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Button on Android
2 participants