CSS Custom Properties

This template is dedicated for Web developers using CSS. It helps you generate all types of design tokens as CSS Custom Properties in their respective CSS file and it helps you to optimize your SVG's.

This example uses 5 different parsers:

This template is an example among others. Head toward the to-css-custom-propertiesarrow-up-right page to get all available options.

When using the CLI, you need to fill three properties:

.specifyrc.json
{
  "version": "2",
  "repository": "@organization/repository",
  "personalAccessToken": "<your-personal-access-token>",
  "rules": [
    {
      "name": "Generate colors in HSL",
      "parsers": [
        {
          "name": "filter",
          "options": {
            "query": {
              "where": {
                "token": ".*",
                "withTypes": {
                  "include": [
                    "color"
                  ]
                },
                "select": {
                  "parents": true
                }
              }
            }
          }
        },
        {
          "name": "convert-color",
          "options": {
            "toFormat": "hsl",
            "applyTo": {
              "collection": true
            }
          }
        },
        {
          "name": "change-case",
          "options": {
            "change": "names",
            "toCase": "kebabCase",
            "applyTo": {
              "collection": true
            }
          }
        },
        {
          "name": "change-case",
          "options": {
            "change": "modes",
            "toCase": "kebabCase",
            "applyTo": {
              "collection": true
            }
          }
        },
        {
          "name": "to-css-custom-properties",
          "output": {
            "type": "file",
            "filePath": "output/colors.css"
          }
        }
      ]
    },
    {
      "name": "Generate text styles as CSS classes",
      "parsers": [
        {
          "name": "filter",
          "options": {
            "query": {
              "where": {
                "token": ".*",
                "withTypes": {
                  "include": [
                    "textStyle"
                  ]
                },
                "select": {
                  "token": true
                }
              }
            }
          }
        },
        {
          "name": "change-case",
          "options": {
            "toCase": "kebabCase",
            "applyTo": {
              "token": true
            }
          }
        },
        {
          "name": "make-line-height-relative",
          "options": {}
        },
        {
          "name": "convert-dimension",
          "options": {
            "applyToKeys": {
              "textStyle": [
                "fontSize"
              ]
            },
            "toFormat": "rem"
          }
        },   
        {
          "name": "to-css-text-style",
          "output": {
            "type": "file",
            "filePath": "output/text-styles.scss"
          },
          "options": {
            "genericFamily": "sans-serif",
            "tokenNameTemplate": "text-style-{{token}}"
          }
        }
      ]
    },
    {
      "name": "Optimize and transform vectors with svgo + Generate SVG files",
      "parsers": [
        {
          "name": "svgo",
          "output": {
            "type": "directory",
            "directoryPath": "output/assets"
          },
          "options": {
            "svgo": {
              "plugins": [
                {
                  "name": "removeDimensions"
                },
                {
                  "name": "convertColors",
                  "params": {
                    "currentColor": true
                  }
                }
              ]
            }
          }
        }
      ]
    }
  ]
}

Last updated

Was this helpful?