-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TextLink#522#524] Merge to main
- Loading branch information
Showing
48 changed files
with
4,190 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...Sources/Components/TextLink/AccessibilityIdentifier/TextLinkAccessibilityIdentifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
25 changes: 25 additions & 0 deletions
25
core/Sources/Components/TextLink/Enum/Public/Alignment/TextLinkAlignment.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
core/Sources/Components/TextLink/Enum/Public/Alignment/TextLinkAlignmentTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
core/Sources/Components/TextLink/Enum/Public/TextLinkIntent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
39 changes: 39 additions & 0 deletions
39
core/Sources/Components/TextLink/Enum/Public/TextLinkTypography.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
core/Sources/Components/TextLink/Enum/Public/TextLinkVariant.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
17 changes: 17 additions & 0 deletions
17
core/Sources/Components/TextLink/Properties/Internal/ImageSize/TextLinkImageSize.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
25 changes: 25 additions & 0 deletions
25
...ponents/TextLink/Properties/Internal/ImageSize/TextLinkImageSizeMock+ExtensionTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
core/Sources/Components/TextLink/Properties/Internal/Typographies/TextLinkTypographies.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../TextLink/Properties/Internal/Typographies/TextLinkTypographiesMock+ExtensionsTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
Oops, something went wrong.