Skip to content

Commit

Permalink
refactor: add factor base in raw tokens, code cleanup (#132) (#133)
Browse files Browse the repository at this point in the history
Ddd back factor base in raw tokens to be aligned with parser output, code cleanup

Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp authored Sep 25, 2024
1 parent 7624a2c commit 37891af
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 175 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Library] Rename `SizingCompositeSemanticToken` to `MultipleSizingTokens` to keep "composite" word for *Figma* design system
- [Library] Rename `ColorCompositeSemanticToken` to `MultipleColorTokens` to keep "composite" word for *Figma* design system
- [Library] Elevation colors have been merged into "multiple" objects colors to have less variables and manage color schemes
- [Library] Rename `ColorCompositeSemanticToken` to `MultipleColorSemanticToken` to keep "composite" word for *Figma* design system
- [Library] Elevation colors have been merged into composite colors to have less variables and manage color schemes
- [Library] Rename `SpacingCompositeSemanticToken` to `MultipleSpacingTokens` to keep "composite" word for *Figma* design system
- [Library] Rename `SizingCompositeSemanticToken` to `MultipleSizingTokens` to keep "composite" word for *Figma* design system
- [Library] Rename `ColorCompositeSemanticToken` to `MultipleColorTokens` to keep "composite" word for *Figma* design system
- [Library] Elevation colors have been merged into "multiple" objects colors to have less variables and manage color schemes
- [Library] Update color semantic tokens to better manage light and dark modes values
- [Library] Update elevation colors focus light and dark
- [Library] Rename space padding inline component tokens by removing "component" word
Expand All @@ -38,7 +44,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

- [Library] Remove some base multiplier factor from raw tokens
- [Library] Remove raw tokens `elevationZIndex` ([#119](https://github.com/Orange-OpenSource/ouds-ios/issues/119))

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extension OUDSTheme: FormsTextInputComponentTokens {

@objc open var ftiTitleFontWeight: TypographyFontWeightSemanticToken { fontWeightHeading }
@objc open var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelLarge }

@objc open var ftiTitleColor: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalLightGray80, dark: ColorRawTokens.colorFunctionalDarkGray640) }

@objc open var ftiSubtitleFontWeight: TypographyFontWeightSemanticToken { fontWeightDisplay }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ final class TestInverseThemeElevationColors: XCTestCase {
}

func testElevationColorsEquality() throws {
XCTAssertEqual(inverseTheme.elevationColorNone.light, inverseTheme.elevationColorNone.dark)
XCTAssertEqual(inverseTheme.elevationColorRaised.light, inverseTheme.elevationColorRaised.dark)
XCTAssertEqual(inverseTheme.elevationColorDrag.light, inverseTheme.elevationColorDrag.dark)
XCTAssertEqual(inverseTheme.elevationColorOverlayDefault.light, inverseTheme.elevationColorOverlayDefault.dark)
XCTAssertEqual(inverseTheme.elevationColorOverlayEmphasized.light, inverseTheme.elevationColorOverlayEmphasized.dark)
XCTAssertEqual(inverseTheme.elevationColorStickyDefault.light, inverseTheme.elevationColorStickyDefault.dark)
XCTAssertEqual(inverseTheme.elevationColorStickyEmphasized.light, inverseTheme.elevationColorStickyEmphasized.dark)
XCTAssertEqual(inverseTheme.elevationColorStickyNavigationScrolled.light, inverseTheme.elevationColorStickyNavigationScrolled.dark)
XCTAssertEqual(inverseTheme.elevationColorFocus.light, inverseTheme.elevationColorFocus.dark)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,33 @@
/// Extracted in this separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension BorderRawTokens {

/// Double type because used below for computations with Double values, output of the parser
public static let borderBase: Double = 4

// MARK: Primitive token - Border - Width

public static let borderWidth0: BorderWidthRawToken = 4 * 0
public static let borderWidth25: BorderWidthRawToken = 4 * 0.25
public static let borderWidth50: BorderWidthRawToken = 4 * 0.5
public static let borderWidth75: BorderWidthRawToken = 4 * 0.75
public static let borderWidth100: BorderWidthRawToken = 4 * 1
public static let borderWidth150: BorderWidthRawToken = 4 * 1.5
public static let borderWidth200: BorderWidthRawToken = 4 * 2
public static let borderWidth0: BorderWidthRawToken = borderBase * 0
public static let borderWidth25: BorderWidthRawToken = borderBase * 0.25
public static let borderWidth50: BorderWidthRawToken = borderBase * 0.5
public static let borderWidth75: BorderWidthRawToken = borderBase * 0.75
public static let borderWidth100: BorderWidthRawToken = borderBase * 1
public static let borderWidth150: BorderWidthRawToken = borderBase * 1.5
public static let borderWidth200: BorderWidthRawToken = borderBase * 2

// MARK: Primitive token - Border - Radius

public static let borderRadius0: BorderRadiusRawToken = 4 * 0
public static let borderRadius25: BorderRadiusRawToken = 4 * 0.25
public static let borderRadius50: BorderRadiusRawToken = 4 * 0.5
public static let borderRadius75: BorderRadiusRawToken = 4 * 0.75
public static let borderRadius100: BorderRadiusRawToken = 4 * 1
public static let borderRadius150: BorderRadiusRawToken = 4 * 1.5
public static let borderRadius200: BorderRadiusRawToken = 4 * 2
public static let borderRadius300: BorderRadiusRawToken = 4 * 3
public static let borderRadius400: BorderRadiusRawToken = 4 * 4
public static let borderRadius500: BorderRadiusRawToken = 4 * 5
public static let borderRadius600: BorderRadiusRawToken = 4 * 6
public static let borderRadius800: BorderRadiusRawToken = 4 * 8
public static let borderRadius0: BorderRadiusRawToken = borderBase * 0
public static let borderRadius25: BorderRadiusRawToken = borderBase * 0.25
public static let borderRadius50: BorderRadiusRawToken = borderBase * 0.5
public static let borderRadius75: BorderRadiusRawToken = borderBase * 0.75
public static let borderRadius100: BorderRadiusRawToken = borderBase * 1
public static let borderRadius150: BorderRadiusRawToken = borderBase * 1.5
public static let borderRadius200: BorderRadiusRawToken = borderBase * 2
public static let borderRadius300: BorderRadiusRawToken = borderBase * 3
public static let borderRadius400: BorderRadiusRawToken = borderBase * 4
public static let borderRadius500: BorderRadiusRawToken = borderBase * 5
public static let borderRadius600: BorderRadiusRawToken = borderBase * 6
public static let borderRadius800: BorderRadiusRawToken = borderBase * 8

// MARK: Primitive token - Border - Style

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,42 @@
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension DimensionRawTokens {

/// Double type because used below for computations with Double values, output of the parser
public static let dimensionBase: Double = 4

// MARK: Primitive token - Dimension

public static let dimension0: DimensionRawToken = 4 * 0
public static let dimension25: DimensionRawToken = 4 * 0.5
public static let dimension50: DimensionRawToken = 4 * 1
public static let dimension75: DimensionRawToken = 4 * 1.5
public static let dimension100: DimensionRawToken = 4 * 2
public static let dimension150: DimensionRawToken = 4 * 3
public static let dimension200: DimensionRawToken = 4 * 4
public static let dimension250: DimensionRawToken = 4 * 5
public static let dimension300: DimensionRawToken = 4 * 6
public static let dimension350: DimensionRawToken = 4 * 7
public static let dimension400: DimensionRawToken = 4 * 8
public static let dimension450: DimensionRawToken = 4 * 9
public static let dimension500: DimensionRawToken = 4 * 10
public static let dimension550: DimensionRawToken = 4 * 11
public static let dimension600: DimensionRawToken = 4 * 12
public static let dimension650: DimensionRawToken = 4 * 13
public static let dimension700: DimensionRawToken = 4 * 14
public static let dimension750: DimensionRawToken = 4 * 15
public static let dimension800: DimensionRawToken = 4 * 16
public static let dimension900: DimensionRawToken = 4 * 18
public static let dimension1000: DimensionRawToken = 4 * 20
public static let dimension1200: DimensionRawToken = 4 * 24
public static let dimension1400: DimensionRawToken = 4 * 28
public static let dimension1600: DimensionRawToken = 4 * 32
public static let dimension1800: DimensionRawToken = 4 * 36
public static let dimension2000: DimensionRawToken = 4 * 40
public static let dimension3000: DimensionRawToken = 4 * 80
public static let dimension4000: DimensionRawToken = 4 * 120
public static let dimension5000: DimensionRawToken = 4 * 140
public static let dimension6000: DimensionRawToken = 4 * 160
public static let dimension7000: DimensionRawToken = 4 * 180
public static let dimension9000: DimensionRawToken = 4 * 220
public static let dimension11000: DimensionRawToken = 4 * 260
public static let dimension0: DimensionRawToken = dimensionBase * 0
public static let dimension25: DimensionRawToken = dimensionBase * 0.5
public static let dimension50: DimensionRawToken = dimensionBase * 1
public static let dimension75: DimensionRawToken = dimensionBase * 1.5
public static let dimension100: DimensionRawToken = dimensionBase * 2
public static let dimension150: DimensionRawToken = dimensionBase * 3
public static let dimension200: DimensionRawToken = dimensionBase * 4
public static let dimension250: DimensionRawToken = dimensionBase * 5
public static let dimension300: DimensionRawToken = dimensionBase * 6
public static let dimension350: DimensionRawToken = dimensionBase * 7
public static let dimension400: DimensionRawToken = dimensionBase * 8
public static let dimension450: DimensionRawToken = dimensionBase * 9
public static let dimension500: DimensionRawToken = dimensionBase * 10
public static let dimension550: DimensionRawToken = dimensionBase * 11
public static let dimension600: DimensionRawToken = dimensionBase * 12
public static let dimension650: DimensionRawToken = dimensionBase * 13
public static let dimension700: DimensionRawToken = dimensionBase * 14
public static let dimension750: DimensionRawToken = dimensionBase * 15
public static let dimension800: DimensionRawToken = dimensionBase * 16
public static let dimension900: DimensionRawToken = dimensionBase * 18
public static let dimension1000: DimensionRawToken = dimensionBase * 20
public static let dimension1200: DimensionRawToken = dimensionBase * 24
public static let dimension1400: DimensionRawToken = dimensionBase * 28
public static let dimension1600: DimensionRawToken = dimensionBase * 32
public static let dimension1800: DimensionRawToken = dimensionBase * 36
public static let dimension2000: DimensionRawToken = dimensionBase * 40
public static let dimension3000: DimensionRawToken = dimensionBase * 80
public static let dimension4000: DimensionRawToken = dimensionBase * 120
public static let dimension5000: DimensionRawToken = dimensionBase * 140
public static let dimension6000: DimensionRawToken = dimensionBase * 160
public static let dimension7000: DimensionRawToken = dimensionBase * 180
public static let dimension9000: DimensionRawToken = dimensionBase * 220
public static let dimension11000: DimensionRawToken = dimensionBase * 260
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension GridRawTokens {

/// Double type because used below for computations with Double values, output of the parser
public static let dimensionBase: Double = 4

// MARK: Primitive token - Grid - Design width

public static let gridWidth100: GridRawToken = 320
Expand Down Expand Up @@ -59,27 +62,27 @@ extension GridRawTokens {

// MARK: Primitive token - Grid - Margin

public static let gridMargin100: GridRawToken = 4 * 4
public static let gridMargin300: GridRawToken = 4 * 6
public static let gridMargin400: GridRawToken = 4 * 7
public static let gridMargin500: GridRawToken = 4 * 8
public static let gridMargin600: GridRawToken = 4 * 9
public static let gridMargin700: GridRawToken = 4 * 10
public static let gridMargin900: GridRawToken = 4 * 12
public static let gridMargin1000: GridRawToken = 4 * 13
public static let gridMargin1100: GridRawToken = 4 * 14
public static let gridMargin1700: GridRawToken = 4 * 20
public static let gridMargin2500: GridRawToken = 4 * 28
public static let gridMargin100: GridRawToken = dimensionBase * 4
public static let gridMargin300: GridRawToken = dimensionBase * 6
public static let gridMargin400: GridRawToken = dimensionBase * 7
public static let gridMargin500: GridRawToken = dimensionBase * 8
public static let gridMargin600: GridRawToken = dimensionBase * 9
public static let gridMargin700: GridRawToken = dimensionBase * 10
public static let gridMargin900: GridRawToken = dimensionBase * 12
public static let gridMargin1000: GridRawToken = dimensionBase * 13
public static let gridMargin1100: GridRawToken = dimensionBase * 14
public static let gridMargin1700: GridRawToken = dimensionBase * 20
public static let gridMargin2500: GridRawToken = dimensionBase * 28

// MARK: Primitive token - Grid - Column gap

public static let gridColumnGap10: GridRawToken = 4 * 0.25
public static let gridColumnGap100: GridRawToken = 4 * 2
public static let gridColumnGap200: GridRawToken = 4 * 4
public static let gridColumnGap300: GridRawToken = 4 * 5
public static let gridColumnGap400: GridRawToken = 4 * 6
public static let gridColumnGap600: GridRawToken = 4 * 8
public static let gridColumnGap700: GridRawToken = 4 * 10
public static let gridColumnGap10: GridRawToken = dimensionBase * 0.25
public static let gridColumnGap100: GridRawToken = dimensionBase * 2
public static let gridColumnGap200: GridRawToken = dimensionBase * 4
public static let gridColumnGap300: GridRawToken = dimensionBase * 5
public static let gridColumnGap400: GridRawToken = dimensionBase * 6
public static let gridColumnGap600: GridRawToken = dimensionBase * 8
public static let gridColumnGap700: GridRawToken = dimensionBase * 10

// MARK: Primitive token - Grid - Column count

Expand Down
Loading

0 comments on commit 37891af

Please sign in to comment.