Giter VIP home page Giter VIP logo

colorgen's Introduction

ColorPaletteGenerator

ColorPaletteGenerator is a tool that takes a human-readable input file describing a color palette, and generates the associated code / assets that an Xcode project can use.

This is the successor to the RMRColorTools project that was written in Objective-C and has some legacy aspects to it that just aren't necessary. It is intended to be used in exactly the same way, but be available via the Swift Package Manager.

In the input file, you can declare:

  • A hex color value and provide it a label
  • 2 hex color values for one label, if you need different colors for 'dark mode' on iOS
  • Aliases to previously declared colors, so you can define a color and give it an abstract name, but use an alias for a specific purpose (i.e. navigationBarTitle)
  • "Private" colors, who can be used to generate aliases. For example, you name them abstract names, but create aliases that are functional (i.e. label, cellTitle, etc.). It can ensure that developers aren't randomly picking colors for the interface, but are using colors named for specific purposes.

The Input File will ultimately generate:

  • An .xcassets Assets Catalog with the colors (so to be available to Interface Builder)
  • A namespaced struct that contains all the color definitions as Constants that will reference these Colors in the asset catalog.
  • You can specify whether this namespaced struct has a public ACL or is internal (default).

Input File Format

// MyAppColors.palette
//
// Lines beginning with // are ignored by the parser, so you can add comments for your team members.
//
// Or you can make comments be generated into the output file by adding them after the color name (see below)


// Define an opaque color in RRGGBB Hex Format. e.g. #FFEE24.   (# character is required!)
#RRGGBB ColorName Add some comments that should be generated into the output file.

// Or in RRGGBBAA format if you need transparency
#RRGGBBAA ColorNameTranslucent

// Perhaps you want to support Dark Mode.  Just add a second hex value after the first one.  The first is always 'Any' and the second is for dark mode.
#FF0000 #AA0000 Red You can see that the second value is darker than the first

#010101 _almostBlack This is a private color and will not be exported.

// Create an Alias to an already defined color.  You can see the pattern: $ExistingColorname AliasName.  ($ character required!)
$ColorName MainTitleText

$_almostBlack SecondaryTextColor But private colors can be used to generate 'functional' color names without exposing the abstract name to (say) a developer

// You should ideally define your colors at the top, and all aliases below them!

``
 

colorgen's People

Contributors

horseshoe7 avatar

Stargazers

Marco Lamina avatar

Watchers

 avatar James Cloos avatar

Forkers

mlamina

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.