Skip to content

Commit

Permalink
feat(components): separating theme into light/dark files (#2106)
Browse files Browse the repository at this point in the history
  • Loading branch information
owilliams320 authored Feb 26, 2024
1 parent cbcce6e commit 9c2c486
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 1,650 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ jobs:
cache: npm
- run: npm ci
- run: npx nx affected --target=build --base=${{ github.event.pull_request.base.sha }}
- run: npx nx affected --target=build-scss --base=${{ github.event.pull_request.base.sha }}
3 changes: 3 additions & 0 deletions apps/knapsack/public/ks-overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: var(--mdc-theme-background);
}
18 changes: 9 additions & 9 deletions libs/angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@
},
"defaultConfiguration": "production"
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/libs/angular"],
"options": {
"jestConfig": "libs/angular/jest.config.js",
"passWithNoTests": true
}
},
"build-scss": {
"builder": "nx:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
"mkdir -p dist/libs/angular/common/",
Expand All @@ -42,6 +34,14 @@
"parallel": false
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/libs/angular"],
"options": {
"jestConfig": "libs/angular/jest.config.js",
"passWithNoTests": true
}
},
"lint": {
"executor": "@nx/eslint:lint",
"options": {
Expand Down
2 changes: 1 addition & 1 deletion libs/components/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parameters as mainParameters } from '../../../.storybook/preview';

import '../theme/theme.scss';
import '../src/index.scss';
import '../../../.storybook/theme/markdown-elements.scss';

export const parameters = {
Expand Down
2 changes: 1 addition & 1 deletion libs/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Main entry point to include all of Covalent Components-->
<script type="module" src="src/index.ts"></script>
<link href="theme/theme.scss" rel="stylesheet" />
<link href="src/index.scss" rel="stylesheet" />

<!-- Inter Font Typography & Material Icons Font --->
<link rel="preconnect" href="https://fonts.googleapis.com" />
Expand Down
11 changes: 11 additions & 0 deletions libs/components/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
},
"outputs": ["{workspaceRoot}/dist/libs/components"]
},
"build-scss": {
"executor": "nx:run-commands",
"options": {
"commands": [
"mkdir -p dist/libs/components/theme/",
"./node_modules/.bin/sass --trace --color --style=compressed --load-path=node_modules ./libs/components/src/theme/:./dist/libs/components/theme/"
],
"parallel": false
},
"outputs": ["{workspaceRoot}/dist/libs/components/theme"]
},
"test": {
"executor": "nx:run-commands",
"options": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use '@covalent/tokens/index.scss' as tokens;
@use '../src/icon/icon' as icon;
@use '../src/skeleton/skeleton.styles' as skeleton; // TODO - should be a component for text and block
@use './mixins' as theme;
@use './icon/icon' as icon;
@use './skeleton/skeleton.styles' as skeleton; // TODO - should be a component for text and block
@use './theme/mixins' as theme;
@import '../../icons/covalent-icons.css';

@include icon.core-styles(); // TODO - include future support in icons css
Expand Down
5 changes: 4 additions & 1 deletion libs/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export * from './code-snippet/code-snippet';
export * from './dialog/dialog';
export * from './drawer/drawer';
export * from './empty-state/empty-state';
export * from './expansion-panel/expansion-panel';
export * from './expansion-panel/expansion-panel-item';
export * from './formfield/formfield';
export * from './icon/icon';
export * from './icon-button/icon-button';
export * from './icon-checkbox/icon-check-toggle';
Expand Down Expand Up @@ -44,4 +47,4 @@ export * from './tree-list/tree-list';
export * from './tree-list/tree-list-item';
export * from './typography/typography';

import '../theme/theme.scss';
import './index.scss';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Covalent themed components
@use '../src/data-table/data-table.theme' as data-table;
@use '../data-table/data-table.theme' as data-table;

@mixin components-theme($theme, $typography) {
// Foreground colors
Expand Down
10 changes: 10 additions & 0 deletions libs/components/src/theme/dark-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@use '@covalent/tokens/index.scss' as tokens;
@use './mixins' as theme;

// Define the base theme using light tokens w/ dark tokens overriting for prefers-color-scheme:dark
:root {
@include theme.components-theme(
map-get(tokens.$tokens, 'dark'),
map-get(tokens.$tokens, typography)
);
}
10 changes: 10 additions & 0 deletions libs/components/src/theme/light-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@use '@covalent/tokens/index.scss' as tokens;
@use './mixins' as theme;

// Define the base theme using light tokens w/ dark tokens overriting for prefers-color-scheme:dark
:root {
@include theme.components-theme(
map-get(tokens.$tokens, 'light'),
map-get(tokens.$tokens, typography)
);
}
Loading

0 comments on commit 9c2c486

Please sign in to comment.