Skip to content

Instantly share code, notes, and snippets.

@yanfali
Created February 1, 2019 20:22
Show Gist options
  • Select an option

  • Save yanfali/012639025085e09ae930f76e68cc58f5 to your computer and use it in GitHub Desktop.

Select an option

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.
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