RedMadRobot / figma-export

Command line utility to export colors, typography, icons and images from Figma to Xcode / Android Studio project
MIT License
726 stars 114 forks source link

Support exporting from a single figma file #66

Closed JonLz closed 3 years ago

JonLz commented 3 years ago

Thank you for the great library. This is a tool I am exploring using however my design team has a requirement to only maintain the color styles for both the light and dark color palette in a single figma file. I see that right now you only support a separate file for light and dark styles. Is this something you would entertain? I would be happy to help build out the feature if so.

I took an initial pass at it, and was able to prototype it out by modifying the ColorsLoader. If we add an export option, update the documentation, and configure the loader to be able to make this modification it should work. What do you think?

func load() throws -> (light: [Color], dark: [Color]?) {
        let colors = try loadColors(fileId: params.lightFileId)
        let darkSuffix = "_dark"
        let lightColors = colors
            .filter { !$0.name.hasSuffix(darkSuffix)}
        let darkColors = colors
            .filter { $0.name.hasSuffix(darkSuffix) }
            .map { color -> Color in
                var newColor = color
                newColor.name = String(color.name.dropLast(darkSuffix.count))
                return newColor
            }
        return (lightColors, darkColors)
    }
subdan commented 3 years ago

This is a great feature. I’ll be glad to accept your pull request.

What about dark illustrations? Do you want to store light and dark illustrations in a single Figma file with a "_dark" prefix?

JonLz commented 3 years ago

I will start with colors. We aren't planning to use the illustrations feature yet. My initial thought is it's probably more common to want to store colors in the same file, and less so for illustrations. If we hear more folks want it, it would be straightforward to implement it.

subdan commented 3 years ago

Thanks for the PR! I will check it withing 2 days.