All Projects → kaelig → google-spreadsheets-theo

kaelig / google-spreadsheets-theo

Licence: MIT license
Import Google Spreadsheets to a format digestable by Theo

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to google-spreadsheets-theo

Style Dictionary
A build system for creating cross-platform styles.
Stars: ✭ 2,097 (+16030.77%)
Mutual labels:  design-systems, design-tokens
mole
A tool for managing design decision outputs for different platforms
Stars: ✭ 30 (+130.77%)
Mutual labels:  design-systems, design-tokens
design-tokens-generator
Create your Semantic Style Variables (Universal language for developers and designers).
Stars: ✭ 41 (+215.38%)
Mutual labels:  design-systems, design-tokens
Theo
Theo is a an abstraction for transforming and formatting Design Tokens
Stars: ✭ 1,697 (+12953.85%)
Mutual labels:  design-systems, design-tokens
hv-uikit-react
React UI library for the Hitachi Vantara Design System.
Stars: ✭ 29 (+123.08%)
Mutual labels:  design-systems
System Design Interview
System design interview for IT companies
Stars: ✭ 16,342 (+125607.69%)
Mutual labels:  design-systems
Viewui
A high quality UI Toolkit built on Vue.js 2.0
Stars: ✭ 2,487 (+19030.77%)
Mutual labels:  design-systems
Awesome Design Systems
💅🏻 ⚒ A collection of awesome design systems
Stars: ✭ 13,308 (+102269.23%)
Mutual labels:  design-systems
standard-components
A specification for functional UI components
Stars: ✭ 52 (+300%)
Mutual labels:  design-systems
lighthouse
Lighthouse is a continuous design system for integrating design with development workflows.
Stars: ✭ 25 (+92.31%)
Mutual labels:  design-systems
awesome-software-architecture
A curated list of awesome articles, videos, and other resources to learn and practice software architecture, patterns, and principles.
Stars: ✭ 1,594 (+12161.54%)
Mutual labels:  design-systems
Retro Css
A list of retro-inspired CSS frameworks and design systems
Stars: ✭ 218 (+1576.92%)
Mutual labels:  design-systems
moon-design
Moon Design System for React
Stars: ✭ 209 (+1507.69%)
Mutual labels:  design-systems
Govuk Design System
One place for service teams to find styles, components and patterns for designing government services.
Stars: ✭ 197 (+1415.38%)
Mutual labels:  design-systems
salsa
A tool for exporting iOS components into Sketch 📱💎
Stars: ✭ 62 (+376.92%)
Mutual labels:  design-systems
Argon Design System
Argon - Design System for Bootstrap 4 by Creative Tim
Stars: ✭ 2,307 (+17646.15%)
Mutual labels:  design-systems
Material Ui
MUI (formerly Material-UI) is the React UI library you always wanted. Follow your own design system, or start with Material Design.
Stars: ✭ 73,739 (+567123.08%)
Mutual labels:  design-systems
elm-antd
The official Ant Design UI Kit for Elm
Stars: ✭ 56 (+330.77%)
Mutual labels:  design-systems
Storybook
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!
Stars: ✭ 67,445 (+518707.69%)
Mutual labels:  design-systems
Oui
Optimizely's Component Library
Stars: ✭ 228 (+1653.85%)
Mutual labels:  design-systems

google-spreadsheets-theo

Import design tokens from a Google Spreadsheet to a format digestable by Theo.

Quick start

This example shows how to manage color tokens using Google Spreadsheets and Theo.

The end result is available in the ./example directory.

A ready-to-use demo project (more detailed and published to npm), is available at https://github.com/kaelig/google-spreadsheets-theo-demo.

1. Create a Google Spreadsheet to store the design tokens

Paste this table in a new Google spreadsheet, and populate it with the project or company’s design tokens:

name value type category comment
color-primary red color background-color Primary color for use on all main actions
color-secondary #ff00ff color background-color
color-tertiary green color background-color

It should look something like this example Google Spreadsheet.

2. Publish the spreadsheet to the web

google-spreadsheets-theo is only able to access the contents of the spreadsheet if it’s publicly published to the web.

  1. In the File menu, select Publish to the web…
  2. Click the Publish button (leave the default options)

3. Install Theo and google-spreadsheets-theo

Using yarn:

yarn add theo google-spreadsheets-theo --dev

Or, using npm:

npm install theo google-spreadsheets-theo --save-dev

4. Set up Theo and google-spreadsheets-theo

In a file called build-tokens.js, paste:

const fs = require('fs');
const path = require('path');
const theo = require('theo');
const googleSpreadsheetsTheo = require('google-spreadsheets-theo');

const config = {
  // URL of the spreadsheet
  // REPLACE WITH YOUR OWN
  spreadsheetUrl: 'https://docs.google.com/spreadsheets/d/xxx/edit#gid=0',

  // Each worksheet is for a different type of tokens (colors, spacing, typography…)
  worksheets: [
    {
      id: 1, // position of the worksheet (or "tab") in Google Spreadsheets
      name: 'colors',
    },
    // Example for adding spacing tokens:
    // {
    //   id: 2,
    //   name: 'spacing',
    // },
  ],

  // Output formats (see https://github.com/salesforce-ux/theo#formats)
  formats: [
    {
      transform: 'web',
      format: 'scss',
    },
    // Add formats below.
    // {
    //   transform: 'ios',
    //   format: 'ios.json',
    // },
  ],

  // Where the output files should be stored
  outputDirectory: './tokens/',
};

const convert = (name, transform, format, data) =>
  theo
    .convert({
      transform: {
        type: transform,
        file: `${name}.json`,
        data,
      },
      format: {
        type: format,
      },
    })
    .then((contents) => contents)
    .catch((error) => console.log(`Something went wrong: ${error}`));

const main = async (config) => {
  for ({id, name} of config.worksheets) {
    const data = await googleSpreadsheetsTheo(config.spreadsheetUrl, id);

    for ({transform, format} of config.formats) {
      const tokens = await convert(name, transform, format, data);
      const filename = `${config.outputDirectory}${name}.${format}`;
      await fs.promises
        .mkdir(path.dirname(filename), {recursive: true})
        .then(() => {
          fs.writeFileSync(filename, tokens);
        });
      console.log(`✔ Design tokens written to ${filename}`);
    }
  }
};

main(config);

Don’t forget to change the value of spreadsheetUrl in the config object.

5. Run the script

Add the script to the project’s package.json:

  // package.json
  "scripts": {
    // copy-paste this line:
    "build-tokens": "node ./build-tokens.js",
  },

In a terminal, run:

yarn build-tokens

Or, using npm:

npm run build-tokens

This should appear:

yarn build-tokens
yarn run v1.12.3
$ node ./build-tokens.js
✔ Design tokens written to ./tokens/colors.scss
✔ Design tokens written to ./tokens/colors.common.js
✔ Design tokens written to ./tokens/colors.android.xml
✔ Design tokens written to ./tokens/colors.ios.json
✨  Done in 2.29s.

Voilà! Tokens should now be available in the ./tokens directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].