Skip to content

Nicejinux/NXColorsetMaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Python Xcode Platform

NXColorsetMaker

NXColorsetMaker can generate colorset files and folders for Xcode from an Excel file.

Purpose

I needed to apply iOS / tvOS dark mode. but there were so many things to do and should communicate with designers about the way to let the developers know the color sets. It was so hard to understand to each other. so I gave designer an Excel file and we did it easily.

How it works

When you make a colorset on Xcode, JSON file and directory is generated. so NXColorsetMaker makes same directory and JSON file as Xcode from an Excel file. and UIColor+DarkMode.swift file is generated in the NXColorsetMaker directory.
If you use .xlsx file, each sheet name is used for the Colorsets directory name.
If you use .csv file, each file name is used for the Colorsets directory name.

    ColorSets
       ㄴ Sheet1
           ㄴ Contents.json
           ㄴ defaultText.colorset
	       ㄴ Contents.json
	   ㄴ defaultCellTextColor.colorset
	       ㄴ Contents.json
       ㄴ Sheet2
           ㄴ Contents.json
	   .
	   .
	   .

Alt text

And, NXColorsetMaker output color values are HEX format, but you can change to float value format.

HEX: __getHex() # default
Float: __getFloat()

Install component

pandas

You should install pandas to read an Excel file. I assume that you are using python3.

$ sudo pip3 install pandas

makeColorsets

Download all files where you want.
Fill all the colors that you are using with designers in the Excel file properly.
Please don't change header title in the first row of Excel file.
If row[0].value == 'name', that row will be ignored.

Usage

Options

  -h, --help            show this help message and exit
  -f EXCEL_FILE_NAME, --file EXCEL_FILE_NAMES
                        excel file names.
			ex) -f colorSheet1.csv colorSheet2.csv
			default: ./colorSheet.xlsx
  -t [TYPE [TYPE ...]], --type [TYPE [TYPE ...]]
                        target device types. 
			default: universal
			all types: [ universal, iphone, ipad, carplay, watch, tv, mac ]
                        ex) -t iphone ipad
  -d DESTINATION_DIR, --dir DESTINATION_DIR
                        target directory. 
			default: ./ColorSets
  -c, --catalyst        add colorset for mac-catalyst ex) -t ipad -c

Excute

All options have default value. so you don't have to add any option if you can use default values.

$ python3 colorsetMaker.py
or
$ python3 colorsetMaker.py -f ~/colors.xlsx -t universal iphone ipad -c -d ~/myproject/image.xcassets/colorSets

Result

Alt text

Will be improved

  • Split files to classes
  • Support CSV file

Author

This is Jinwook Jeon.
I've been working as an iOS developer in Korea.
This is my first Python script, so there can be lots of weird things in this source.
I'm waiting for your comments, suggestions, fixes, everything what you want to say.
Feel free to contact me.

MIT License

Copyright (c) 2019 Jinwook Jeon. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

NXColorsetMaker can make colorsets for Xcode from Excel file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages