Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style-dictionary and generate initial tokens #18

Merged
merged 17 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"homepage": "https://department-of-veterans-affairs.github.io/va-mobile-library",
"dependencies": {
"@department-of-veterans-affairs/mobile-tokens": "0.0.4",
"@os-team/i18next-react-native-language-detector": "^1.0.28",
"i18next": "^23.4.3",
"react-i18next": "^13.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Colors } from '@department-of-veterans-affairs/mobile-tokens'
import {
Text,
TextStyle,
Expand Down Expand Up @@ -59,27 +60,16 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
onChange(selected)
}, [selected, onChange, labels])

// Copied from DSVA color tokens in css-library
const colorTokens = {
white: '#FFFFFF',
gray: {
dark: '#323A45',
lighter: '#D6D7D9',
lightest: '#F1F1F1',
medium: '#757575',
},
}

let textColor: string, activeBgColor: string, inactiveBgColor: string

if (colorScheme === 'light') {
textColor = colorTokens.gray.dark
activeBgColor = colorTokens.white
inactiveBgColor = colorTokens.gray.lighter
textColor = Colors.grayDark
activeBgColor = Colors.white
inactiveBgColor = Colors.grayLighter
} else {
textColor = colorTokens.gray.lightest
activeBgColor = colorTokens.gray.medium
inactiveBgColor = colorTokens.gray.dark
textColor = Colors.grayLightest
activeBgColor = Colors.grayMedium
inactiveBgColor = Colors.grayDark
}

const viewStyle: ViewStyle = {
Expand Down
8 changes: 8 additions & 0 deletions packages/components/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,7 @@ __metadata:
dependencies:
"@babel/core": ^7.20.0
"@babel/plugin-proposal-export-namespace-from": ^7.18.9
"@department-of-veterans-affairs/mobile-tokens": 0.0.4
"@expo/webpack-config": ^18.1.2
"@os-team/i18next-react-native-language-detector": ^1.0.28
"@react-native-async-storage/async-storage": ^1.19.0
Expand Down Expand Up @@ -2881,6 +2882,13 @@ __metadata:
languageName: unknown
linkType: soft

"@department-of-veterans-affairs/mobile-tokens@npm:0.0.4":
version: 0.0.4
resolution: "@department-of-veterans-affairs/mobile-tokens@npm:0.0.4"
checksum: a3455980b9733d7c3102824cb7f9531abcc0e3084ed2f265442ccd4bf15b3a4538cbc4796c58c347aa3dab0d0130a8989f9da628a3fc0726fdcedd8a7187c423
languageName: node
linkType: hard

"@discoveryjs/json-ext@npm:^0.5.3":
version: 0.5.7
resolution: "@discoveryjs/json-ext@npm:0.5.7"
Expand Down
1 change: 1 addition & 0 deletions packages/tokens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# VA Mobile Design Tokens
23 changes: 23 additions & 0 deletions packages/tokens/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"source": [
"./src/tokens/**/*.json"
],
"platforms": {
"rn": {
"transformGroup": "react-native",
"buildPath": "./dist/",
"prefix": "",
"files": [
{
"destination": "js/colors.js",
"format": "javascript/es6",
"filter": {
"attributes": {
"category": "color"
}
}
}
]
}
}
}
16 changes: 16 additions & 0 deletions packages/tokens/dist/js/colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Do not edit directly
* Generated on Thu, 21 Sep 2023 17:49:25 GMT
*/

export const white = "#ffffff";
export const gray = "#5b616b";
export const grayDark = "#323a45";
export const grayMedium = "#757575";
export const grayLight = "#aeb0b5";
export const grayLightAlt = "#eeeeee";
export const grayLighter = "#d6d7d9";
export const grayLightest = "#f1f1f1";
export const grayWarmDark = "#494440";
export const grayWarmLight = "#e4e2e0";
export const grayCoolLight = "#dce4ef";
narin marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 10 additions & 3 deletions packages/tokens/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "@department-of-veterans-affairs/mobile-tokens",
"version": "0.0.1",
"version": "0.0.4",
"description": "VA Design System Mobile Token Library",
"main": "index.js",
"main": "src/index.ts",
"scripts": {
"build": "style-dictionary build",
"publish-package": "npm publish --access public --tolerate-republish"
},
"repository": {
"type": "git",
"url": "git+https://github.com/department-of-veterans-affairs/va-mobile-library.git"
Expand All @@ -22,5 +26,8 @@
"url": "https://github.com/department-of-veterans-affairs/va-mobile-library/issues"
},
"homepage": "https://github.com/department-of-veterans-affairs/va-mobile-library#readme",
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"devDependencies": {
"style-dictionary": "^3.8.0"
}
}
1 change: 1 addition & 0 deletions packages/tokens/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as Colors from '../dist/js/colors'
Empty file.
190 changes: 190 additions & 0 deletions packages/tokens/src/tokens/colors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"white": {
"value": "#fff",
"attributes": {
"category": "color"
}
},
"gray": {
"*": {
"value": "#5b616b",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#5b616b"
},
"name": "color-gray",
"attributes": {
"category": "color",
"type": "gray",
"item": "*"
},
"path": [
"gray",
"*"
]
},
"dark": {
"value": "#323a45",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#323a45"
},
"name": "color-gray-dark",
"attributes": {
"category": "color",
"type": "gray",
"item": "dark"
},
"path": [
"gray",
"dark"
]
},
"medium": {
"value": "#757575",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#757575"
},
"name": "color-gray-medium",
"attributes": {
"category": "color",
"type": "gray",
"item": "medium"
},
"path": [
"gray",
"medium"
]
},
"light": {
"value": "#aeb0b5",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#aeb0b5"
},
"name": "color-gray-light",
"attributes": {
"category": "color",
"type": "gray",
"item": "light"
},
"path": [
"gray",
"light"
]
},
"light-alt": {
"value": "#eeeeee",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#eeeeee"
},
"name": "color-gray-light-alt",
"attributes": {
"category": "color",
"type": "gray",
"item": "light-alt"
},
"path": [
"gray",
"light-alt"
]
},
"lighter": {
"value": "#d6d7d9",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#d6d7d9"
},
"name": "color-gray-lighter",
"attributes": {
"category": "color",
"type": "gray",
"item": "lighter"
},
"path": [
"gray",
"lighter"
]
},
"lightest": {
"value": "#f1f1f1",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#f1f1f1"
},
"name": "color-gray-lightest",
"attributes": {
"category": "color",
"type": "gray",
"item": "lightest"
},
"path": [
"gray",
"lightest"
]
},
"warm-dark": {
"value": "#494440",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#494440"
},
"name": "color-gray-warm-dark",
"attributes": {
"category": "color",
"type": "gray",
"item": "warm-dark"
},
"path": [
"gray",
"warm-dark"
]
},
"warm-light": {
"value": "#e4e2e0",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#e4e2e0"
},
"name": "color-gray-warm-light",
"attributes": {
"category": "color",
"type": "gray",
"item": "warm-light"
},
"path": [
"gray",
"warm-light"
]
},
"cool-light": {
"value": "#dce4ef",
"filePath": "tokens/color.json",
"isSource": true,
"original": {
"value": "#dce4ef"
},
"name": "color-gray-cool-light",
"attributes": {
"category": "color",
"type": "gray",
"item": "cool-light"
},
"path": [
"gray",
"cool-light"
]
}
}
}
Loading