Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp committed Sep 19, 2024
1 parent 2496b31 commit 5dd22a3
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 32 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [Library] Split raws, semantics and components tokens definitions and also values, composites and type aliases
- [Showcase] Improve Fastlane alpha build notifications
- [Library] Do not store blur value in elevation semantic tokens
- [Library] Change type aliases for X and Y offsets of elevations tokens
- [Library] Split raw, semantic and components tokens definitions of values, composites and aliases
- [Library] Split raws, semantics and components tokens definitions and also values, composites and type aliases
- [Library] Update border semantic tokens values ([#106](https://github.com/Orange-OpenSource/ouds-ios/issues/106))
- [Showcase] Add fake components for demo and tokens tests
- [Library] Remove spread value for elevation tokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,37 @@ public final class ElevationCompositeRawToken: NSObject { // For @objc compatibi
public let x: ElevationRawToken
/// The Y offset for the elevation
public let y: ElevationRawToken
/// The *Figma* blur effect for the elevation, to use for `radius` computations.
public let blur: ElevationRawToken
/// The color of the shadow effect
public let color: ColorRawToken

/// The *Figma* tool uses its own implementation of shadow or elevation effect with a *blur* and a *spread* values defined in the *tokens*, inherited from web universe.
/// However *SwiftUI* for shadows effects uses only a *radius* which does not match the *Figma* *blur* and *spread* radiuses values.
/// Thus this value is computed from the *blur* value so as to try to reproduce the same effect applying the formula
///
/// ** radius = blur + / 2**
public var radius: ElevationRawToken {
blur / 2
}
public let radius: ElevationRawToken

/// Defines a composite elevation token and computes the *SwftUI radius* from the given *Figma blur* applying formula:
///
/// ** radius = blur / 2 **
///
/// - Parameters:
/// - x: The X offset for elevation
/// - y: The Y offset for elevation
/// - blur: The blur effect from *Figma*, used to compute *SwiftUI radius*
/// - color: The color to apply on the shafow
public init(x: ElevationRawToken, y: ElevationRawToken, blur: ElevationRawToken, color: ColorRawToken) {
self.x = x
self.y = y
self.blur = blur
self.color = color
radius = blur / 2
}

/// Compares the `self.x`, `self.y`, `self.blur` and `self.color` values between tokens.
/// If `object` is not an `ElevationCompositeRawToken`, or ahs one of its four proeprties with another value than `self`,
/// return `false`. Otherwise returns `true`.
public override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? ElevationCompositeRawToken else { return false }
return self.x == other.x
&& self.y == other.y
&& self.blur == other.blur
&& self.radius == other.radius
&& self.color == other.color
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ public struct TypographyCompositeRawToken: Equatable {

/// The font size to apply for the texts
public let size: TypographyFontSizeRawToken

/// The line height to apply on texts
public let lineHeight: TypographyFontLineHeightRawToken

/// The font weight to associated wit the font family
public let weight: TypographyFontWeightRawToken

// TODO: How to deal "letter spacing"?
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import Foundation

/// Extracted in a separated files to help the *Figma* JSON to Swift parser to generate files to include easily.
/// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import Foundation

/// Extracted in a separated files to help the *Figma* JSON to Swift parser to generate files to include easily.
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension ColorRawTokens {

// MARK: Primitive token - Colors - Black, white
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import Foundation

/// Extracted in a separated files to help the *Figma* JSON to Swift parser to generate files to include easily.
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension DimensionRawTokens {

public static let dimensionBase: DimensionRawToken = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import Foundation

/// Extracted in a separated files to help the *Figma* JSON to Swift parser to generate files to include easily.
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension ElevationRawTokens {

// MARK: Primitive token - Elevation - Z Index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import Foundation

/// Extracted in a separated files to help the *Figma* JSON to Swift parser to generate files to include easily.
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension GridRawTokens {

private static let dimensionBase: GridRawToken = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import Foundation

/// Extracted in a separated files to help the *Figma* JSON to Swift parser to generate files to include easily.
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension OpacityRawTokens {

// MARK: Primitive token - Opacity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import SwiftUI

/// Extracted in a separated files to help the *Figma* JSON to Swift parser to generate files to include easily.
/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily.
extension TypographyRawTokens {

// MARK: Primitive token - Typography - Font size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,6 @@ final class ElevationRawTokensTests: XCTestCase {

func assertCompositeLowerThan(_ left: ElevationCompositeRawToken, _ right: ElevationCompositeRawToken) {
XCTAssertLessThanOrEqual(left.y, right.y)
XCTAssertLessThanOrEqual(left.blur, right.blur)
XCTAssertLessThanOrEqual(left.radius, right.radius)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@

import Foundation

/// Composite semantic tokens which will wrap a combination of `SizingWidthHeightSemanticToken` depending to viewports.
/// Composite semantic tokens which will wrap a combination of `SizingWidthHeightSemanticToken` depending to viewports / size classes.
public final class SizingCompositeSemanticToken: NSObject {

/// For **extra-compact** and **compact** viewports
public let compact: SizingWidthHeightSemanticToken

/// For **regular** and **medium** viewports
public let regular: SizingWidthHeightSemanticToken

/// Initializes a new sizing composite semantic token.
/// - Parameters:
/// - compact: The `SizingWidthHeightSemanticToken` to apply if device in *compact* mode
/// - regular: The `SizingWidthHeightSemanticToken` to apply if device in *regular* mode
public init(compact: SizingWidthHeightSemanticToken, regular: SizingWidthHeightSemanticToken) {
self.compact = compact
self.regular = regular
}

/// Returns `true` if `self` and `object` has the same `compact` and `regular` values and with `object`
/// as a `SizingCompositeSemanticToken`. Otherwise returns `false`.
public override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? SizingCompositeSemanticToken else { return false }
return self.compact == other.compact && self.regular == other.regular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ public final class SpacingCompositeSemanticToken: NSObject {

/// For **extra-compact** and **compact** viewports
public let compact: DimensionRawToken

/// For **regular** and **medium** viewports
public let regular: DimensionRawToken

/// Initializes a new spacing composite semantic token.
/// - Parameters:
/// - compact: The `DimensionRawToken` to apply if device in *compact* mode
/// - regular: The `DimensionRawToken` to apply if device in *regular* mode
public init(compact: DimensionRawToken, regular: DimensionRawToken) {
self.compact = compact
self.regular = regular
}

/// Returns `true` if `self` and `object` has the same `compact` and `regular` values and with `object`
/// as a `SpacingCompositeSemanticToken`. Otherwise returns `false`.
public override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? SpacingCompositeSemanticToken else { return false }
return self.compact == other.compact && self.regular == other.regular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ public final class TypographyCompositeSemanticToken: NSObject {

/// For **extra-compact** and **compact** viewports
public let compact: TypographyCompositeRawToken

/// For **regular** and **medium** viewports
public let regular: TypographyCompositeRawToken

/// Initializes a new typography composite semantic token.
/// - Parameters:
/// - compact: The `TypographyCompositeRawToken` to apply if device in *compact* mode
/// - regular: The `TypographyCompositeRawToken` to apply if device in *regular* mode
public init(compact: TypographyCompositeRawToken, regular: TypographyCompositeRawToken) {
self.compact = compact
self.regular = regular
}

/// Returns `true` if `self` and `object` has the same `compact` and `regular` values and with `object`
/// as a `TypographyCompositeSemanticToken`. Otherwise returns `false`.
public override func isEqual(_ object: Any?) -> Bool {
guard let object = object as? TypographyCompositeSemanticToken else { return false }
return self.compact == object.compact && self.regular == object.regular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import Foundation
import SwiftUI
import OUDSTokensRaw

// MARK: - Type aliases to keep grammar clear

/// Basically a semantic color token, which can be either a functional or a decorative token, is a `String`, to keep grammar clean and clear with design system grammar.
public typealias ColorSemanticToken = ColorRawToken

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

import Foundation
import OUDSTokensRaw

/// This is a group of semantic tokens for **borders**.
/// It defines all `BorderWidthSemanticToken`, `BorderRadiusSemanticToken` and `BorderStyleSemanticToken` a theme must have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//

import Foundation
import SwiftUI
import OUDSTokensRaw

/// This is a group of semantic tokens for **colors**.
/// It defines all `ColorSemanticToken` and `ColorAliasSemanticToken` a theme must have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

import Foundation
import OUDSTokensRaw

/// This is a group of semantic tokens for **dimensions**.
/// It defines all `DimensionSemanticToken` a theme must have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

import Foundation
import OUDSTokensRaw

/// This is a group of semantic tokens for **elevations**.
/// It defines all elevation semantic tokens a theme must have. (`ElevationXSemanticToken`,`ElevationYSemanticToken`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

import Foundation
import OUDSTokensRaw

/// This is a group of semantic tokens for **grids**.
/// It defines all `GridSemanticToken` a theme must have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

import Foundation
import OUDSTokensRaw

/// This is a group of semantic tokens for **opacity.**
/// It defines all `OpacitySemanticToken` a theme must have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

import Foundation
import OUDSTokensRaw

/// This is a group of semantic tokens for **sizing**.
/// It defines all `SizingSemanticToken` a theme must have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

import Foundation
import OUDSTokensRaw

/// This is a group of semantic tokens for **spacing**.
/// It defines all `SpacingSemanticToken` a theme must have.
Expand Down

0 comments on commit 5dd22a3

Please sign in to comment.