Skip to content

Commit ed8b444

Browse files
committed
Set up a query parameter to use the token-based Sass API in the dev-app
1 parent 9c1ecc6 commit ed8b444

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

src/dev-app/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ sass_binary(
137137
],
138138
)
139139

140+
sass_binary(
141+
name = "theme_token_api",
142+
src = "theme-token-api.scss",
143+
deps = [
144+
"//src/material:sass_lib",
145+
"//src/material-experimental:sass_lib",
146+
"//src/material/core:theming_scss_lib",
147+
],
148+
)
149+
140150
# Variables that are going to be inlined into the dev app index.html.
141151
filegroup(
142152
name = "variables",
@@ -154,6 +164,7 @@ filegroup(
154164
"favicon.ico",
155165
"index.html",
156166
":theme",
167+
":theme_token_api",
157168
":variables",
158169
"//src/dev-app/icon:icon_demo_assets",
159170
"@npm//:node_modules/moment/min/moment-with-locales.min.js",

src/dev-app/dev-app.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Component, ViewEncapsulation} from '@angular/core';
10-
import {RouterModule} from '@angular/router';
9+
import {Component, inject, ViewEncapsulation} from '@angular/core';
10+
import {ActivatedRoute, RouterModule} from '@angular/router';
1111
import {DevAppLayout} from './dev-app/dev-app-layout';
1212

1313
/** Root component for the dev-app demos. */
@@ -18,4 +18,14 @@ import {DevAppLayout} from './dev-app/dev-app-layout';
1818
standalone: true,
1919
imports: [DevAppLayout, RouterModule],
2020
})
21-
export class DevApp {}
21+
export class DevApp {
22+
route = inject(ActivatedRoute);
23+
24+
constructor() {
25+
this.route.queryParams.subscribe(q => {
26+
(document.querySelector('#theme-styles') as any).href = q.hasOwnProperty('tokenapi')
27+
? 'theme-token-api.css'
28+
: 'theme.css';
29+
});
30+
}
31+
}

src/dev-app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<link rel="preconnect" href="https://fonts.gstatic.com">
1111
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
1212
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
13-
<link href="theme.css" rel="stylesheet">
13+
<link href="theme.css" rel="stylesheet" id="theme-styles">
1414

1515
<!-- FontAwesome for mat-icon demo. -->
1616
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

src/dev-app/theme-token-api.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
dev-app {
2+
&::before {
3+
content: 'Using experimental theming API';
4+
display: inline-block;
5+
position: fixed;
6+
z-index: 100;
7+
bottom: 0;
8+
left: 50%;
9+
transform: translateX(-50%);
10+
padding: 8px;
11+
background: red;
12+
color: white;
13+
}
14+
}

0 commit comments

Comments
 (0)