-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: create button component #213
base: develop
Are you sure you want to change the base?
Conversation
🟢 Netlify deploy for commit 9d05f30 succeededDeploy preview: https://674f49026fa30610e675e0f4--ouds-android.netlify.app |
b799b30
to
774e610
Compare
774e610
to
50f35dd
Compare
50f35dd
to
ce2ee68
Compare
ce2ee68
to
49c3c06
Compare
49c3c06
to
34d91ff
Compare
34d91ff
to
988953a
Compare
988953a
to
9678d7b
Compare
@OptIn(ExperimentalMaterial3Api::class) | ||
private fun OudsButton( | ||
nullableIcon: OudsButton.Icon?, | ||
nullableText: 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.
As seen together, replace nullableIcon
and nullableText
respectively by icon
and text
and remove previewState
default value to avoid similar signatures issue.
.widthIn(min = buttonTokens.sizeMinWidth.dp) | ||
.heightIn(min = buttonTokens.sizeMinHeight.dp, max = maxHeight) | ||
.border(hierarchy = hierarchy, state = state, shape = shape), | ||
enabled = state != OudsButton.State.Disabled && state != OudsButton.State.Loading && state != OudsButton.State.Skeleton, |
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.
What do you think about writing this like that:
state !in listOf(OudsButton.State.Disabled, OudsButton.State.Loading, OudsButton.State.Skeleton)
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 also added remember
to avoid instanciating the list on each recomposition.
OudsButton.State.Loading, | ||
OudsButton.State.Focused -> OudsColorKeyToken.Content.OnAction.Negative | ||
OudsButton.State.Disabled -> OudsColorKeyToken.Content.OnAction.Disabled | ||
OudsButton.State.Skeleton -> OudsColorKeyToken.Gradient.Skeleton.StartEnd |
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.
We always use OudsColorKeyToken.Gradient.Skeleton.StartEnd
for Skeleton state, maybe we can factorize it as a skeleton color for OudsButton?
OudsButton.State.Pressed -> colorContentDefaultPressed | ||
OudsButton.State.Loading -> colorContentDefaultLoading | ||
OudsButton.State.Disabled -> colorContentDefaultDisabled | ||
OudsButton.State.Skeleton -> OudsColorKeyToken.Gradient.Skeleton.StartEnd |
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.
By changing the text color of the button when it is in skeleton state, Talkback will probably read the text. Is this what we want in term of a11y?
*/ | ||
@Composable | ||
fun OudsButton( | ||
icon: OudsButton.Icon, |
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.
We maybe need a contentDescription
parameter for this kind of button (icon only) to handle a11y or something else.
import androidx.compose.ui.graphics.Color | ||
|
||
@Composable | ||
internal fun Color.enabled(enabled: Boolean) = if (enabled) this else copy(alpha = 0.38f) |
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 I'm not wrong, this alpha value is not defined anywhere in tokens.
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 value comes from Material. You are right, we should remove it.
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
|
||
internal object OudsIconDefaults { |
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.
Here we have OudsIconDefaults
in a separate file, same thing for OudsIconButtonDefaults
but this is not the case for OudsButtonDefault
. What do you think about creating an OudsButtonDefaults
for consistency?
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.
Good point, this is not consistent. What about moving the defaults into the original file? This is was is done in Material.
OudsButton.State.Pressed -> OudsColorKeyToken.Action.Negative.Pressed | ||
OudsButton.State.Loading -> OudsColorKeyToken.Action.Negative.Loading | ||
OudsButton.State.Disabled -> OudsColorKeyToken.Action.Disabled | ||
OudsButton.State.Skeleton -> OudsColorKeyToken.Gradient.Skeleton.StartEnd |
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.
It seems that semantic tokens are not up-to-date because the negative button in dark mode is not similar to the one on Figma. I took a look and OudsColorKeyToken.Action.Negative.Enabled
value is similar in light and dark (scarlet600).
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.
Yes, hopefully this will be fixed by next Tokenator update.
color = borderColor, | ||
shape = shape, | ||
insetWidth = OudsBorderKeyToken.Width.Focus.Inset.value, | ||
insetColor = OudsColorKeyToken.Border.Focus.Inset.value |
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.
The result in Hierarchy.Default
and State.Hovered
is not correct, a border is missing.
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 can't fix it right now because a token is missing, this token will probably be added in next Tokenator update.
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.
Well in fact this is a button token, so I can add it manually.
* @param width The width of the border inset in dp. Use [Dp.Hairline] for a hairline border inset. | ||
* @param color The color to paint the border inset 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.
* @param width The width of the border inset in dp. Use [Dp.Hairline] for a hairline border inset. | |
* @param color The color to paint the border inset with. | |
* @param insetWidth The width of the border inset in dp. Use [Dp.Hairline] for a hairline border inset. | |
* @param insetColor The color to paint the border inset with. |
…rogress indicators
9678d7b
to
4d21ddd
Compare
…nds at the same time
…onDefaults into OudsIcon.kt
Note: Please transform
- [ ]
into- (NA)
in the description when things are not applicableRelated issues
Description
Motivation & Context
Types of change
Previews
Checklist
Contribution
Accessibility
Design
Development
Documentation
Checklist (for Core Team only)