Created
February 1, 2019 20:22
-
-
Save yanfali/012639025085e09ae930f76e68cc58f5 to your computer and use it in GitHub Desktop.
Takes KLE colorway JSON information and writes out a SCSS version of it.
This file contains hidden or 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
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "os" | |
| ) | |
| type color struct { | |
| Name string `json:"name"` | |
| Red int `json:"r"` | |
| Green int `json:"g"` | |
| Blue int `json:"b"` | |
| } | |
| type metainfo struct { | |
| Name string `json:"name"` | |
| Href string `json:"href"` | |
| Description string `json:"description"` | |
| Colors []color `json:"colors"` | |
| } | |
| func main() { | |
| jsonFile, err := os.Open("colors.json") | |
| if err != nil { | |
| panic(err) | |
| } | |
| defer jsonFile.Close() | |
| var infos []metainfo | |
| byteValue, _ := ioutil.ReadAll(jsonFile) | |
| json.Unmarshal(byteValue, &infos) | |
| for i := 0; i < len(infos[2].Colors); i++ { | |
| color := infos[2].Colors[i] | |
| fmt.Printf("$color-sp-pbt-%s: rgb(%d,%d,%d);\n", color.Name, color.Red, color.Green, color.Blue) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment