Skip to content

Commit

Permalink
chore: Initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck committed Jun 15, 2021
1 parent 506390f commit 390c533
Show file tree
Hide file tree
Showing 11 changed files with 2,396 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": ["eslint:recommended", "prettier"],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
}
};
Empty file added .github/CODE_OF_CONDUCT.md
Empty file.
Empty file added .github/CONTRIBUTING.md
Empty file.
121 changes: 121 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# library build output
dist
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
build
dist
coverage
Empty file added .prettierrc.json
Empty file.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `tokens`

> TODO: description
## Usage

```
const tokens = require('tokens');
// TODO: DEMONSTRATE API
```
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@igloo-ui/tokens",
"version": "0.0.0",
"description": "Design tokens are all the values needed to construct and maintain a design system — spacing, color, typography, object styles, animation, etc.",
"main": "index.js",
"type": "module",
"scripts": {
"build": "node src/tokens.js",
"lint": "eslint src/*.js",
"format": "prettier -w src/*",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gsoft-inc/igloo-ui-tokens.git"
},
"keywords": [
"design tokens",
"igloo-ui"
],
"author": "Officevibe",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/gsoft-inc/igloo-ui-tokens/issues"
},
"homepage": "https://github.com/gsoft-inc/igloo-ui-tokens#readme",
"devDependencies": {
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"prettier": "2.3.1",
"theo": "^8.1.5"
}
}
45 changes: 45 additions & 0 deletions src/tokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*global process*/

import theo from "theo";
import fs from "fs";

const OUTPUT = "dist";
const SOURCE = "src/tokens";

const files = {
scss: `${OUTPUT}/index.scss`,
};

function createDir(dirPath) {
fs.mkdirSync(`${process.cwd()}/${dirPath}`, { recursive: true }, (error) => {
if (error) throw error;
});
}

function createFile(filePath, fileContent) {
fs.writeFile(filePath, fileContent, (err) => {
if (err) throw err;
console.log("The file was succesfully saved!");
});
}

async function generateTokens() {
theo.registerTransform("web", ["color/hex"]);

theo
.convert({
transform: {
type: "web",
file: `${SOURCE}/colors.json`,
},
format: {
type: "scss",
},
})
.then((scss) => {
!fs.existsSync(OUTPUT) ? createDir(OUTPUT) : createFile(files.scss, scss);
})
.catch((error) => console.log(`Something went wrong: ${error}`));
}

generateTokens();
9 changes: 9 additions & 0 deletions src/tokens/colors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"props": {
"electric-blue-50": {
"value": "EDF3FE",
"type": "color",
"category": "colors"
}
}
}
Loading

0 comments on commit 390c533

Please sign in to comment.