Skip to content

Commit

Permalink
feat: design tokens package
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Sep 10, 2020
1 parent e2fba85 commit f45c523
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/gatsby/.config/buildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
'../../../ui/app/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/components/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/blocks/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/design-tokens/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../core/core/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/editors/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/axe-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
Expand Down
2 changes: 1 addition & 1 deletion examples/gatsby/.config/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Link } from "@component-controls/components";
import { OctofaceIcon } from '@primer/octicons-react';
import { TestingPage } from "./TestingPage";

const categories = ['Introduction', 'Application','Controls','Blocks', 'Editors', 'Components', 'Plugins']
const categories = ['Introduction', 'Application','Controls','Blocks', 'Design Tokens', 'Editors', 'Components', 'Plugins']

const config: RunOnlyConfiguration = {
analytics: 'UA-172446254-1',
Expand Down
1 change: 1 addition & 0 deletions examples/nextjs/.config/buildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
'../../../ui/app/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/components/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/blocks/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/design-tokens/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../core/core/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/editors/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/axe-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/.config/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Link } from "@component-controls/components";
import { OctofaceIcon } from '@primer/octicons-react';
import { TestingPage } from "./TestingPage";

const categories = ['Introduction', 'Application','Controls','Blocks', 'Editors', 'Components', 'Plugins']
const categories = ['Introduction', 'Application','Controls','Blocks', 'Design Tokens', 'Editors', 'Components', 'Plugins']

const config: RunOnlyConfiguration = {
analytics: 'UA-172446254-1',
Expand Down
1 change: 1 addition & 0 deletions examples/storybook-6-no-docs/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
'../../../ui/components/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/app/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/blocks/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/design-tokens/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../core/core/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/axe-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/viewport-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
Expand Down
2 changes: 1 addition & 1 deletion examples/storybook-6-no-docs/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ThemeProvider } from '@component-controls/storybook';
addDecorator(story => (
<ThemeProvider>{story()}</ThemeProvider>
));
const categories = ['Introduction', 'Application','Controls','Blocks', 'Editors', 'Components', 'Plugins']
const categories = ['Introduction', 'Application','Controls','Blocks', 'Design Tokens', 'Editors', 'Components', 'Plugins']
addParameters({
dependencies: { hideEmpty: true },
options: {
Expand Down
1 change: 1 addition & 0 deletions examples/storybook-6/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'../../../ui/components/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/app/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/blocks/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/design-tokens/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../core/core/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/axe-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/viewport-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
Expand Down
2 changes: 1 addition & 1 deletion examples/storybook-6/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ThemeProvider } from '@component-controls/storybook';
addDecorator(story => (
<ThemeProvider>{story()}</ThemeProvider>
));
const categories = ['Introduction', 'Application','Controls','Blocks', 'Editors', 'Components', 'Plugins']
const categories = ['Introduction', 'Application','Controls','Blocks', 'Design Tokens', 'Editors', 'Components', 'Plugins']
addParameters({
dependencies: { hideEmpty: true },
options: {
Expand Down
13 changes: 13 additions & 0 deletions ui/design-tokens/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
"@babel/preset-typescript",
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
1 change: 1 addition & 0 deletions ui/design-tokens/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
21 changes: 21 additions & 0 deletions ui/design-tokens/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Atanas Stoyanov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions ui/design-tokens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Table of contents

# Overview

# List of components

<react-docgen-typescript path="./src" exclude="index.ts," />

62 changes: 62 additions & 0 deletions ui/design-tokens/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@component-controls/design-tokens",
"version": "1.25.1",
"description": "Component controls design tokens components.",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist/",
"package.json",
"README.md"
],
"scripts": {
"build": "yarn cross-env NODE_ENV=production rollup -c",
"dev": "yarn cross-env NODE_ENV=development rollup -cw",
"docs": "ts-md",
"fix": "yarn lint --fix",
"lint": "yarn eslint . --ext mdx,ts,tsx",
"prepare": "yarn build",
"test": "cc-jest -c ./.config"
},
"homepage": "https://github.com/ccontrols/component-controls",
"bugs": {
"url": "https://github.com/ccontrols/component-controls/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/ccontrols/component-controls.git",
"directory": "ui/design-tokens"
},
"license": "MIT",
"dependencies": {
"@component-controls/components": "^1.25.1",
"@component-controls/core": "^1.25.0",
"@component-controls/editors": "^1.25.1",
"@component-controls/store": "^1.25.1",
"@primer/octicons-react": "^10.0.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"polished": "^3.4.4",
"theme-ui": "^0.4.0-rc.1"
},
"devDependencies": {
"@component-controls/jest-snapshots": "^1.25.1",
"@component-controls/ts-markdown-docs": "^1.21.0",
"cross-env": "^5.2.1",
"eslint": "^6.5.1"
},
"peerDependencies": {
"@primer/octicons-react": ">= 10.0.0",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"theme-ui": ">= 0.4.0-rc.1"
},
"publishConfig": {
"access": "public"
},
"authors": [
"Atanas Stoyanov"
],
"gitHead": "c5145d66c6b8a355839e53c3bca97fd361ce9377"
}
5 changes: 5 additions & 0 deletions ui/design-tokens/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { config } from '../../rollup-config';

export default config({
input: './src/index.ts',
});
16 changes: 16 additions & 0 deletions ui/design-tokens/src/ColorBlock/ColorBlock.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { ColorBlock, ColorBlockProps } from './ColorBlock';

export default {
title: 'Design Tokens/ColorBlock',
component: ColorBlock,
};

export const overview = ({ color, name }: ColorBlockProps) => (
<ColorBlock name={name} color={color} />
);

overview.colors = {
name: { type: 'text' },
color: { type: 'color', value: 'blue' },
};
40 changes: 40 additions & 0 deletions ui/design-tokens/src/ColorBlock/ColorBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/** @jsx jsx */
import { FC } from 'react';
import { jsx, Box, Theme } from 'theme-ui';
import { parseToRgb } from 'polished';

export interface ColorBlockProps {
name?: string;
color: string;
}

export const ColorBlock: FC<ColorBlockProps> = ({ name, color }) => {
const hex = color;
const rgb = parseToRgb(color);
return (
<Box sx={{ display: 'flex', flexDirection: 'row', width: '220px' }}>
<Box sx={{ bg: color, width: 64, height: 64 }}></Box>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
ml: 2,
lineHeight: '16px',
justifyContent: 'space-between',
fontSize: 0,
}}
>
<Box
sx={{
fontWeight: 'bold',
borderBottom: (t: Theme) => ` 1px solid ${t.colors?.shadow}`,
}}
>
{name || hex}
</Box>
<Box>HEX: {hex}</Box>
<Box>RGB: {`${rgb.red},${rgb.green},${rgb.blue}`}</Box>
</Box>
</Box>
);
};
Empty file added ui/design-tokens/src/index.ts
Empty file.
13 changes: 13 additions & 0 deletions ui/design-tokens/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist",
"rootDir": "src",
"declaration": true,
"types": ["node", "jest"],
"typeRoots": ["../../node_modules/@types", "node_modules/@types"]
},
"include": ["src/**/*", "src/typings.d.ts"],
"exclude": ["node_modules/**"]
}

0 comments on commit f45c523

Please sign in to comment.