Skip to content

Commit

Permalink
feat: Design Token (#1107)
Browse files Browse the repository at this point in the history
## Proposed change

The purpose of this PR is to provide tools to generate a theme (CSS Var
based) from a Design Token specification.

## Included

- [x] Generation of CSS Var for the Showcase application
- [x] Generation of CMS Metadata
- [x] Schematics to access to generator
- [x] CLI to access to the generator
- [x] NgBuilder (including `watch` mode)
- [x] Documentation
- [x] Unit Tests

## Links

- Design Token Specification:
https://design-tokens.github.io/community-group/format/

<!-- Please make sure to follow the contributing guidelines on
https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
  • Loading branch information
kpanot authored Dec 14, 2023
2 parents cf6bf77 + c71fac2 commit fce9421
Show file tree
Hide file tree
Showing 91 changed files with 3,779 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn nx affected -t i18n && yarn lint-staged
yarn lint-staged
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"**/dist/": true,
"**/build/": true,
"**/node_modules": true,
"**/.cache": true
"**/.cache": true,
"**/src/package.json": true,
},
"files.exclude": {
"**/.git": true,
Expand Down
1 change: 1 addition & 0 deletions apps/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"@angular/cli": "~17.0.3",
"@angular/compiler-cli": "~17.0.4",
"@nx/eslint-plugin": "~17.1.1",
"@o3r/design": "workspace:^",
"@o3r/eslint-config-otter": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/schematics": "workspace:^",
Expand Down
40 changes: 37 additions & 3 deletions apps/showcase/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"extract-translations",
"extract-components",
"generate-translations",
"generate-theme",
"compile"
]
},
Expand Down Expand Up @@ -91,16 +92,24 @@
}
},
"defaultConfiguration": "production",
"dependsOn": ["^build", "generate-translations"]
"dependsOn": [
"^build",
"generate-translations",
"generate-theme"
]
},
"serve": {
"executor": "@o3r/core:multi-watcher",
"options": {
"targets": [
"showcase:generate-translations:development",
"showcase:serve-app"
"showcase:serve-app",
"showcase:generate-theme:watch"
]
}
},
"dependsOn": [
"^build-builders"
]
},
"serve-app": {
"executor": "@angular-devkit/build-angular:dev-server",
Expand Down Expand Up @@ -159,6 +168,31 @@
"silent": true
}
},
"generate-theme": {
"executor": "@o3r/design:generate-css",
"outputs": [
"{options.defaultStyleFile}",
"{options.metadataOutput}",
"{projectRoot}/src/**/*.scss"
],
"inputs": [
"{projectRoot}/src/style/design-token.json"
],
"options": {
"metadataOutput": "apps/showcase/styling.metadata.json",
"defaultStyleFile": "apps/showcase/src/style/theme.scss",
"designTokenFilePatterns": "apps/showcase/src/style/design-token.*.json",
"rootPath": "apps/showcase/src"
},
"configurations": {
"watch": {
"watch": true
}
},
"dependsOn": [
"^build-builders"
]
},
"generate-translations": {
"executor": "@o3r/localization:localization",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
o3r-run-app-locally {
/* --- BEGIN THEME Auto-generated --- */
--run-app-locally-tertiary-bg: var(--color-primary-50);
/* --- END THEME Auto-generated --- */

.bg-body-tertiary {
background: var(--run-app-locally-tertiary-bg);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@mixin style {

.bubble {
border-radius: var(--bs-border-radius-xl);

Expand Down
36 changes: 36 additions & 0 deletions apps/showcase/src/style/design-token.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "../../../../packages/@o3r/design/schemas/design-token.schema.json",
"bs": {
"primary": {
"$description": "Application Primary color",
"$type": "color",
"$value": "{color.primary}"
},
"nav-pills": {
"$extensions": {
"o3rScope": ".nav-pills"
},
"link-active-color": {
"$value": "{color.primary}"
}
},
"tertiary": {
"bg": {
"$extensions": {
"o3rImportant": true
},
"$value": "{color.neutral.gray-light}"
}
}
},
"run-app-locally": {
"$extensions": {
"o3rTargetFile": "app/run-app-locally/run-app-locally.style.scss"
},
"tertiary": {
"bg": {
"$value": "{color.primary.50}"
}
}
}
}
Loading

0 comments on commit fce9421

Please sign in to comment.