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(design-system/DT-6): allow generation of both UIKit and SwiftUI font files #3

Open
wants to merge 1 commit into
base: fueled-typography
Choose a base branch
from

Conversation

ada10086
Copy link

@ada10086 ada10086 commented Dec 5, 2023

Making some updates based on my comments in the original fueled-typography PR

The main update is to allow generation of both UIKit's Label.swift, LabelStyle.swift, LabelStyle+extension.swift and SwiftUI's TextStyle.swift, TextStyle+extension.swift.

Question:

  • Do we need a fontSystem parameter? I don't think it is necessary, since we have to specify the generated file path anyways in the yml if we want to generate certain files , we can simply check whether the file path exists, for the same reason, we could also remove the generateLabels and generateStyles params
  • Do we want to include the example folder in our repo at all? Since there's a lot inside Example to maintain every time we make updates

TODO:

  • fix tests
  • update Example dir to reflect our changes or remove it
  • potentially remove fontSystem param

Copy link

linear bot commented Dec 5, 2023

@ada10086
Copy link
Author

ada10086 commented Dec 5, 2023

P.S. Will need to update the figma-export.yml with the right params for typography

  # [optional] Parameters for exporting typography
  typography:
    # Typography name style: camelCase or snake_case
    nameStyle: camelCase
    # [optional] Absolute or relative path to swift file where to export UIKit fonts (UIFont extension).
    fontSwift: "./Libraries/DesignSystem/Sources/FigmaExport/Extensions/UIFont+extension.swift"
    # [optional] Absolute or relative path to swift file where to generate LabelStyle extensions for each style (LabelStyle extension).
    labelStyleSwift: "./Libraries/DesignSystem/Sources/FigmaExport/Extensions/LabelStyle+extension.swift"
    # Should FigmaExport generate UILabel for each text style (font)? E.g. HeaderLabel, BodyLabel, CaptionLabel
    generateLabels: true
    # Relative or absolute path to directory where to place UILabel for each text style (font) (Required if generateLabels = true)
    labelsDirectory: "./Libraries/DesignSystem/Sources/FigmaExport/UIComponents/"
   
    # [optional] Absolute or relative path to swift file where to export SwiftUI fonts (Font extension).
    swiftUIFontSwift: "./Libraries/DesignSystem/Sources/FigmaExport/Extensions/Font+extension.swift"
    # [optional] Absolute or relative path to swift file where to generate TextStyle extensions for each style (TextStyle extension).
    textStyleSwift: "./Libraries/DesignSystem/Sources/FigmaExport/Extensions/TextStyle+extension.swift"
    # Should FigmaExport generate TextStyles for each text style (font)? E.g. Header, Body, Caption
    generateTextStyles: true
    # Relative or absolute path to directory where to place TextStyles for each text style (font) (Required if generateTextStyles = true)
    textStylesDirectory: "./Libraries/DesignSystem/Sources/FigmaExport/UIComponents/"

@@ -26,7 +26,7 @@ final public class XcodeTypographyExporter: XcodeExporterBase {
public func export(textStyles: [TextStyle]) throws -> [FileContents] {
var files: [FileContents] = []

// UIKit & SwiftUI UIFont extension
// UIKit UIFont extension
Copy link
Member

Choose a reason for hiding this comment

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

Do we not need UIFont anymore when only using SwiftUI? I did mention it here for clarity since we needed it to calculate the lineSpacing.

Copy link
Author

@ada10086 ada10086 Dec 7, 2023

Choose a reason for hiding this comment

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

Oh I see your intention here, I thought we simply wanted to note what extension file we are creating. I will add additional comments here to clarify!

Copy link
Author

Choose a reason for hiding this comment

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

Also maybe the parameter fontSwift, i.e. UIFont extension, should be non-optional, since it'll be required for not only UIKit but also SwiftUI?

@@ -147,18 +147,28 @@ ios:

# [optional] Parameters for exporting typography
typography:
# [optional] Absolute or relative path to swift file where to export UIKit fonts (UIFont extension).
# Choose what font system you want to use SwiftUI or UIKit
fontSystem: UIKit
Copy link
Member

Choose a reason for hiding this comment

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

How do you allow both at the same time?

Copy link
Author

Choose a reason for hiding this comment

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

Actually I was wondering if we could just remove the fontSystem param (See my question 1 above), wondering your thoughts on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants