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

feat: add dimension tokens in the demo app #147

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from

Conversation

paulinea
Copy link
Member

No description provided.

@paulinea paulinea linked an issue Oct 21, 2024 that may be closed by this pull request
@paulinea

This comment was marked as resolved.

Copy link

github-actions bot commented Oct 21, 2024


package com.orange.ouds.theme.tokens

class OudsSizeKeyToken {
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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
    }
}

Copy link
Member Author

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,
Copy link
Member

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
Copy link
Member

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"
Copy link
Member

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 }
Copy link
Member

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:

Screenshot_20241030_112448

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.

Comment on lines 56 to 58
) {
content()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) {
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)
Copy link
Member

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(
Copy link
Member

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.
Capture d’écran 2024-10-30 à 12 00 45

Copy link
Member Author

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

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.

Add dimension tokens in the demo app
2 participants