-
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: add dimension tokens in the demo app #147
base: develop
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
8b1a027
to
cf81b6a
Compare
🟢 Netlify deploy for commit 6c8e319 succeededDeploy preview: https://6728f6f66dee420cf1aeecfd--ouds-android.netlify.app |
cf81b6a
to
5942aa2
Compare
6d3763e
to
c433916
Compare
c433916
to
69556aa
Compare
… of TokenProperty
Factorize token properties illustrations
b6626f5
to
b696f73
Compare
|
||
package com.orange.ouds.theme.tokens | ||
|
||
class OudsSizeKeyToken { |
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 could be an object.
Same comment for OudsSpaceKeyToken
.
} | ||
|
||
enum class IconWithText { | ||
HeadingExtraLargeSizeShort, |
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 is the rule to sort enum values?
If it is sorted according to the size, then the variant (ExtraLarge
, etc...) is sorted from largest to smallest, but the scale (SizeShort
, etc...) is sorted from smallest to largest.
Tall, | ||
Taller, | ||
Tallest, | ||
WithIconNone, |
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 am not 100% sure it's better, but we could also put WithIcon
and WithArrow
values into nested enum classes:
enum class PaddingInline {
None,
Shorter,
Short,
Medium,
Tall,
Taller,
Tallest;
enum class WithIcon {
None,
Shortest,
Shorter,
Short,
Medium,
Tall,
Taller,
Tallest
}
enum class WithArrow {
None,
Shortest,
Shorter,
Short,
Medium,
Tall,
Taller,
Tallest,
}
}
In that case we must define additional fromToken
methods:
@Stable
fun OudsSpaces.fromToken(token: OudsSpaceKeyToken.PaddingInline.WithIcon): Dp {
return when (token) {
OudsSpaceKeyToken.PaddingInline.WithIcon.None -> paddingInlineWithIconNone
OudsSpaceKeyToken.PaddingInline.WithIcon.Shortest -> paddingInlineWithIconShortest
OudsSpaceKeyToken.PaddingInline.WithIcon.Shorter -> paddingInlineWithIconShorter
OudsSpaceKeyToken.PaddingInline.WithIcon.Short -> paddingInlineWithIconShort
OudsSpaceKeyToken.PaddingInline.WithIcon.Medium -> paddingInlineWithIconMedium
OudsSpaceKeyToken.PaddingInline.WithIcon.Tall -> paddingInlineWithIconTall
OudsSpaceKeyToken.PaddingInline.WithIcon.Taller -> paddingInlineWithIconTaller
OudsSpaceKeyToken.PaddingInline.WithIcon.Tallest -> paddingInlineWithIconTallest
}
}
@Stable
fun OudsSpaces.fromToken(token: OudsSpaceKeyToken.PaddingInline.WithArrow): Dp {
return when (token) {
OudsSpaceKeyToken.PaddingInline.WithArrow.None -> paddingInlineWithArrowNone
OudsSpaceKeyToken.PaddingInline.WithArrow.Shortest -> paddingInlineWithArrowShortest
OudsSpaceKeyToken.PaddingInline.WithArrow.Shorter -> paddingInlineWithArrowShorter
OudsSpaceKeyToken.PaddingInline.WithArrow.Short -> paddingInlineWithArrowShort
OudsSpaceKeyToken.PaddingInline.WithArrow.Medium -> paddingInlineWithArrowMedium
OudsSpaceKeyToken.PaddingInline.WithArrow.Tall -> paddingInlineWithArrowTall
OudsSpaceKeyToken.PaddingInline.WithArrow.Taller -> paddingInlineWithArrowTaller
OudsSpaceKeyToken.PaddingInline.WithArrow.Tallest -> paddingInlineWithArrowTallest
}
}
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 also have to add .value
extensions for nested data classes
|
||
data class OudsSpacings( | ||
data class OudsSpaces( | ||
val fixedNone: Dp, |
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.
Should we add nested data classes like what is done in OudsSpaceKeyToken
?
data class OudsSpaces(
val fixed: Fixed,
// ...
) {
data class Fixed(
val none: Dp,
val smash: Dp,
val shortest: Dp,
val shorter: Dp,
val short: Dp,
val medium: Dp,
val tall: Dp,
val taller: Dp,
val tallest: Dp,
val spacious: Dp,
val huge: Dp,
val jumbo: Dp
)
}
Same comment for OudsSizes
.
@@ -11,6 +11,8 @@ Any use or displaying shall constitute an infringement under intellectual proper | |||
app/src/main/res/drawable/ic_border.xml | |||
app/src/main/res/drawable/ic_component_atom.xml | |||
app/src/main/res/drawable/ic_design_token_figma.xml | |||
app/src/main/res/drawable/ic_design_token_figma_no_padding.xml | |||
app/src/main/res/drawable/ic_dimension.xml |
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.
ic_chevron_down.xml
is missing, but maybe it is not an Orange resource?
@@ -0,0 +1,10 @@ | |||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
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.
Copyright is missing if this is an Orange resource.
Same comment for ic_chevron_down.xml
.
text = label, | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
style = OudsTypographyKeyToken.entries.firstOrNull { it.name == label }?.value.orElse { OudsTypographyKeyToken.BodyStrongLarge.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.
Body and label text styles are all using OudsTypographyKeyToken.BodyStrongLarge
:
This can be fixed by removing "Strong" when searching the associated typography token:
style = OudsTypographyKeyToken.entries.firstOrNull { it.name.replace("Strong", "") == label }?.value.orElse { LocalTextStyle.current }
We can also return LocalTextStyle.current
as a default value if the typography token cannot be found.
) { | ||
content() | ||
} |
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.
) { | |
content() | |
} | |
content = content | |
) |
is TokenProperty.BorderWidth -> BorderIllustrationBox(width = token.value as Dp) | ||
is TokenProperty.BorderRadius -> BorderIllustrationBox(shape = RoundedCornerShape(token.value as Dp)) | ||
is TokenProperty.BorderStyle -> BorderIllustrationBox(style = token.value as OudsBorderStyle) | ||
is TokenProperty.Opacity -> tokenProperty.Illustration(opacity = token.value as Float) |
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.
Illustration methods are located into two different files (TokenPropertyIllustration.kt
and TokenProperty.kt
). Could we move them all in the same file?
is TokenProperty.Elevation -> tokenProperty.Illustration(elevation = token.value as Dp) | ||
is TokenProperty.SizeIconDecorative -> tokenProperty.Illustration(size = token.value as Dp) | ||
is TokenProperty.SizeIconWithLabel -> tokenProperty.Illustration(size = token.value as Dp, token.name) | ||
is TokenProperty.SpaceColumnGap, TokenProperty.SpaceFixed, TokenProperty.SpaceScaled -> SpaceIllustrationBox( |
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.
Maybe Figma changed meanwhile, but there are several differences with our current UI:
- There is a header for each token property.
- Scaled spaces are both horizontal and vertical.
- Tokens with icon and arrow variants are separated into three sections, maybe this could easily be fixed by splitting the enum as suggested in another comment.
- Padding stack with arrow is not displayed in Figma but appears on screen and the arrow missing.
- Icons and arrows are missing in column gap with icon, column gap with arrow and column gap with 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.
As discussed together, I created a new issue for the headers: #179
No description provided.