Skip to content

Commit

Permalink
[TextLink#522#524] Merge to main
Browse files Browse the repository at this point in the history
[TextLink#522#524] Merge to main
  • Loading branch information
robergro authored Jan 19, 2024
2 parents 824d4c8 + ebfb04d commit 60a1a49
Show file tree
Hide file tree
Showing 48 changed files with 4,190 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ enum ChipScenarioSnapshotTests: String, CaseIterable {
}

// MARK: - Private Extensions
private extension ImageEither {
static func mock(isSwiftUIComponent: Bool) -> Self {
return isSwiftUIComponent ? .right(Image.mock) : .left(UIImage.mock)
}
}

private extension ViewEither {
static func mock(_ isSwiftUIComponent: Bool) -> Self {
Expand All @@ -218,14 +213,6 @@ private extension ViewEither {
}
}

private extension Image {
static let mock = Image(systemName: "person.2.circle.fill")
}

private extension UIImage {
static var mock = UIImage(systemName: "person.2.circle.fill") ?? UIImage()
}

private func all<U, V>(_ lhs: [U], _ rhs: [V]) -> [(U, V)] {
lhs.flatMap { left in
rhs.map { right in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,3 @@ enum TagScenarioSnapshotTests: String, CaseIterable {
]
}
}

// MARK: - Private Extensions

private extension ImageEither {

static func mock(isSwiftUIComponent: Bool) -> Self {
return isSwiftUIComponent ? .right(Image.mock) : .left(UIImage.mock)
}
}

private extension Image {
static let mock = Image(systemName: "person.2.circle.fill")
}

private extension UIImage {
static var mock = UIImage(systemName: "person.2.circle.fill") ?? UIImage()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// TextLinkAccessibilityIdentifier.swift
// SparkCore
//
// Created by robin.lemaire on 05/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

/// The accessibility identifiers for the textLink.
public enum TextLinkAccessibilityIdentifier {

// MARK: - Properties

/// The view accessibility identifier.
public static let view = "spark-textLink"
/// The default content stackView accessibility identifier.
static let contentStackView = "spark-textLink-content-stackView"
/// The text accessibility identifier.
public static let text = "spark-textLink-text"
/// The icon view accessibility identifier.
public static let imageContentStackView = "spark-textLink-image-content-stackView"
/// The image accessibility identifier.
public static let image = "spark-textLink-image"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// TextLinkAlignment.swift
// SparkCore
//
// Created by robin.lemaire on 08/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

/// The alignment of the switch.
public enum TextLinkAlignment: CaseIterable {
/// Image on the leading edge of the textlink.
/// Text on the trailing edge of the textlink.
/// Not interpreted if textlink contains only text.
case leadingImage
/// Image on the trailing edge of the textlink.
/// Text on the leading edge of the textlink
/// Not interpreted if textlink contains only text.
case trailingImage

// MARK: - Properties

var isTrailingImage: Bool {
return self == .trailingImage
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// TextLinkAlignmentTests.swift
// SparkCoreUnitTests
//
// Created by robin.lemaire on 08/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

import XCTest
@testable import SparkCore

final class TextLinkAlignmentTests: XCTestCase {

// MARK: - Tests

func test_isTrailingImage_for_all_cases() {
// GIVEN
let items: [(givenAlignment: TextLinkAlignment, expectedIsTrailingImage: Bool)] = [
(givenAlignment: .leadingImage, expectedIsTrailingImage: false),
(givenAlignment: .trailingImage, expectedIsTrailingImage: true)
]

for item in items {
// WHEN
let isTrailingImage = item.givenAlignment.isTrailingImage

// THEN
XCTAssertEqual(
isTrailingImage,
item.expectedIsTrailingImage,
"Wrong isTrailingImage for .\(item.givenAlignment) cases"
)
}
}
}
20 changes: 20 additions & 0 deletions core/Sources/Components/TextLink/Enum/Public/TextLinkIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// TextLinkIntent.swift
// SparkCore
//
// Created by robin.lemaire on 05/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

/// The intent of the text link.
public enum TextLinkIntent: CaseIterable {
case accent
case alert
case basic
case danger
case info
case main
case neutral
case success
case support
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// TextLinkTypography.swift
// SparkCore
//
// Created by robin.lemaire on 06/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

/// The typography of the text link.
public enum TextLinkTypography: CaseIterable {
/// Use the **display1** typography
case display1
/// Use the **display2** typography
case display2
/// Use the **display3** typography
case display3

/// Use the **headline1** typography
case headline1
/// Use the **headline2** typography
case headline2

/// Use the **subhead** typography
case subhead

/// Use the **body1** and **body1Highlight** typographies
case body1
/// Use the **body2** and **body2Highlight** typographies
case body2

/// Use the **caption** and **captionHighlight** typographies
case caption

/// Use the **small** and **smallHighlight** typographies
case small

/// Use the **callout** typography
case callout
}
19 changes: 19 additions & 0 deletions core/Sources/Components/TextLink/Enum/Public/TextLinkVariant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// TextLinkVariant.swift
// SparkCore
//
// Created by robin.lemaire on 05/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

import UIKit

/// A text link variant is used to distinguish between different design and appearance options.
public enum TextLinkVariant: CaseIterable {
/// A text link with an underline.
case underline

/// A text link without any variant (underline).
/// *Not recommended, please use it carefully.*
case none
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// TextLinkImageSize.swift
// SparkCore
//
// Created by robin.lemaire on 14/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

import Foundation

struct TextLinkImageSize: Equatable {

// MARK: - Properties

let size: CGFloat
let padding: CGFloat
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// TextLinkImageSizeMock+ExtensionTests.swift
// SparkCore
//
// Created by robin.lemaire on 18/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

@testable import SparkCore
import Foundation

extension TextLinkImageSize {

// MARK: - Methods

static func mocked(
size: CGFloat = 10,
padding: CGFloat = 11
) -> Self {
return .init(
size: size,
padding: padding
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// TextLinkTypographies.swift
// SparkCore
//
// Created by robin.lemaire on 06/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

struct TextLinkTypographies: Equatable {

// MARK: - Properties

let normal: any TypographyFontToken
let highlight: any TypographyFontToken

// MARK: - Equatable

static func == (lhs: TextLinkTypographies, rhs: TextLinkTypographies) -> Bool {
return lhs.normal.font == rhs.normal.font &&
lhs.normal.uiFont == rhs.normal.uiFont &&
lhs.highlight.font == rhs.highlight.font &&
lhs.highlight.uiFont == rhs.highlight.uiFont
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// TextLinkTypographiesMock+ExtensionTests.swift
// SparkCoreUnitTests
//
// Created by robin.lemaire on 14/12/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

@testable import SparkCore

extension TextLinkTypographies {

// MARK: - Methods

static func mocked() -> Self {
let normalTypographyFontTokenMock = TypographyFontTokenGeneratedMock.mocked(
uiFont: .systemFont(ofSize: 12),
font: .title
)
let highlightTypographyFontTokenMock = TypographyFontTokenGeneratedMock.mocked(
uiFont: .boldSystemFont(ofSize: 12),
font: .title2
)

return .init(
normal: normalTypographyFontTokenMock,
highlight: highlightTypographyFontTokenMock
)
}
}
Loading

0 comments on commit 60a1a49

Please sign in to comment.