-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design): create theming CSS custom properties (#1836)
- Loading branch information
Showing
11 changed files
with
185 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
apps/design-land/src/app/foundations/variables/variables-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { | ||
Routes, | ||
RouterModule, | ||
} from '@angular/router'; | ||
|
||
import { DesignLandVariablesComponent } from './variables.component'; | ||
|
||
export const variablesRoutes: Routes = [ | ||
{ path: '', component: DesignLandVariablesComponent }, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
RouterModule.forChild(variablesRoutes), | ||
], | ||
exports: [ | ||
RouterModule, | ||
], | ||
}) | ||
export class DesignLandVariablesRoutingModule {} |
57 changes: 57 additions & 0 deletions
57
apps/design-land/src/app/foundations/variables/variables.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<daff-article> | ||
<h1 daffArticleTitle>Variables</h1> | ||
<p daffArticleLead>Daffodil's CSS custom properties can be used for fast and easy design and development. We provide common, functional CSS variables that can be used to quickly style elements without the need to create theme files.</p> | ||
|
||
<h2>CSS Custom Properties</h2> | ||
<p>Our custom properties are prefixed with <code>daff-</code> to avoid conflicts with third party variables.</p> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Variable</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>--daff-theme-rgb</td> | ||
<td>The theme's base color in RGB</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-contrast-rgb</td> | ||
<td>The theme's base contrast color in RGB</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme</td> | ||
<td>The theme's base color</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-contrast</td> | ||
<td>The theme's base contrast color</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-primary</td> | ||
<td>The theme's primary color</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-secondary</td> | ||
<td>The theme's secondary color</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-tertiary</td> | ||
<td>The theme's tertiary color</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-warn</td> | ||
<td>The theme's warning color</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-success</td> | ||
<td>The theme's success color</td> | ||
</tr> | ||
<tr> | ||
<td>--daff-theme-danger</td> | ||
<td>The theme's danger color</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</daff-article> |
8 changes: 8 additions & 0 deletions
8
apps/design-land/src/app/foundations/variables/variables.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@import 'utilities'; | ||
@import 'theme'; | ||
|
||
.variables { | ||
&__custom { | ||
background: var(--daff-theme-primary); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
apps/design-land/src/app/foundations/variables/variables.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
|
||
import { DesignLandVariablesComponent } from './variables.component'; | ||
|
||
describe('DesignLandVariablesComponent', () => { | ||
let component: DesignLandVariablesComponent; | ||
let fixture: ComponentFixture<DesignLandVariablesComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
DesignLandVariablesComponent, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DesignLandVariablesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
apps/design-land/src/app/foundations/variables/variables.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'design-land-variables', | ||
templateUrl: './variables.component.html', | ||
}) | ||
export class DesignLandVariablesComponent {} |
21 changes: 21 additions & 0 deletions
21
apps/design-land/src/app/foundations/variables/variables.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { DaffArticleModule } from '@daffodil/design'; | ||
|
||
import { DesignLandExampleViewerModule } from '../../core/code-preview/container/example-viewer.module'; | ||
import { DesignLandVariablesRoutingModule } from './variables-routing.module'; | ||
import { DesignLandVariablesComponent } from './variables.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
DesignLandVariablesComponent, | ||
], | ||
imports: [ | ||
CommonModule, | ||
DesignLandExampleViewerModule, | ||
DesignLandVariablesRoutingModule, | ||
DaffArticleModule, | ||
], | ||
}) | ||
export class DesignLandVariablesModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@mixin daff-theme-css-variables($theme) { | ||
$base: daff-map-deep-get($theme, 'core.base'); | ||
$base-contrast: daff-map-deep-get($theme, 'core.base-contrast'); | ||
$primary: map-get($theme, primary); | ||
$secondary: map-get($theme, secondary); | ||
$tertiary: map-get($theme, tertiary); | ||
$white: daff-map-deep-get($theme, 'core.white'); | ||
$black: daff-map-deep-get($theme, 'core.black'); | ||
$gray: daff-map-deep-get($theme, 'core.gray'); | ||
|
||
// @docs | ||
// | ||
// Global theming css variables | ||
:root { | ||
--daff-theme-rgb: #{red($base), green($base), blue($base)}; | ||
--daff-theme-contrast-rgb: #{red($base-contrast), green($base-contrast), blue($base-contrast)}; | ||
--daff-theme: #{$base}; | ||
--daff-theme-contrast: #{$base-contrast}; | ||
--daff-theme-primary: #{daff-color($primary)}; | ||
--daff-theme-secondary: #{daff-color($secondary)}; | ||
--daff-theme-tertiary: #{daff-color($tertiary)}; | ||
--daff-theme-warn: #{daff-color($daff-bronze, 60)}; | ||
--daff-theme-success: #{daff-color($daff-green, 60)}; | ||
--daff-theme-danger: #{daff-color($daff-red, 60)}; | ||
--daff-theme-white: #{$white}; | ||
--daff-theme-black: #{$black}; | ||
--daff-theme-gray: #{daff-color($gray)}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters