@erathen/theme 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@ class EraThemeService {
|
|
|
5
5
|
theme = signal('light', ...(ngDevMode ? [{ debugName: "theme" }] : []));
|
|
6
6
|
setTheme(theme) {
|
|
7
7
|
this.theme.set(theme);
|
|
8
|
-
document.documentElement.setAttribute('
|
|
8
|
+
document.documentElement.setAttribute('class', theme);
|
|
9
9
|
}
|
|
10
10
|
getTheme() {
|
|
11
11
|
return this.theme();
|
|
@@ -18,30 +18,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
18
18
|
args: [{ providedIn: 'root' }]
|
|
19
19
|
}] });
|
|
20
20
|
|
|
21
|
-
const ERA_THEME_STYLES = [
|
|
22
|
-
'base.css',
|
|
23
|
-
'light.css',
|
|
24
|
-
'dark.css'
|
|
25
|
-
];
|
|
26
|
-
function loadEraThemeStyles() {
|
|
27
|
-
ERA_THEME_STYLES.forEach(file => {
|
|
28
|
-
const id = `era-theme-${file}`;
|
|
29
|
-
if (document.getElementById(id))
|
|
30
|
-
return;
|
|
31
|
-
const link = document.createElement('link');
|
|
32
|
-
link.id = id;
|
|
33
|
-
link.rel = 'stylesheet';
|
|
34
|
-
link.href = `node_modules/@erathen/theme/styles/${file}`;
|
|
35
|
-
document.head.appendChild(link);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
21
|
// theme.provider.ts
|
|
22
|
+
var EraTheme;
|
|
23
|
+
(function (EraTheme) {
|
|
24
|
+
EraTheme["LIGHT"] = "e-light";
|
|
25
|
+
EraTheme["DARK"] = "e-dark";
|
|
26
|
+
})(EraTheme || (EraTheme = {}));
|
|
40
27
|
function provideEraTheme(config = {}) {
|
|
41
28
|
return makeEnvironmentProviders([
|
|
42
29
|
provideAppInitializer(() => {
|
|
43
|
-
|
|
44
|
-
document.documentElement.setAttribute('data-era-theme', config.defaultTheme ?? 'light');
|
|
30
|
+
document.documentElement.setAttribute('class', config.defaultTheme ?? '');
|
|
45
31
|
})
|
|
46
32
|
]);
|
|
47
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erathen-theme.mjs","sources":["../../../projects/theme/src/lib/theme/theme.service.ts","../../../projects/theme/src/lib/theme/
|
|
1
|
+
{"version":3,"file":"erathen-theme.mjs","sources":["../../../projects/theme/src/lib/theme/theme.service.ts","../../../projects/theme/src/lib/theme/theme.provider.ts","../../../projects/theme/src/lib/theme/index.ts","../../../projects/theme/src/public-api.ts","../../../projects/theme/src/erathen-theme.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class EraThemeService {\r\n private theme = signal<string>('light');\r\n\r\n setTheme(theme: string): void {\r\n this.theme.set(theme);\r\n document.documentElement.setAttribute('class', theme);\r\n }\r\n\r\n getTheme(): string {\r\n return this.theme();\r\n }\r\n}\r\n","// theme.provider.ts\r\nimport {\r\n EnvironmentProviders,\r\n makeEnvironmentProviders,\r\n provideAppInitializer\r\n} from '@angular/core';\r\n\r\nenum EraTheme {\r\n LIGHT = 'e-light',\r\n DARK = 'e-dark'\r\n}\r\n\r\nexport interface EraThemeConfig {\r\n defaultTheme?: EraTheme;\r\n}\r\n\r\nexport function provideEraTheme(\r\n config: EraThemeConfig = {}\r\n): EnvironmentProviders {\r\n return makeEnvironmentProviders([\r\n provideAppInitializer(() => {\r\n document.documentElement.setAttribute(\r\n 'class',\r\n config.defaultTheme ?? ''\r\n );\r\n })\r\n ]);\r\n}\r\n","// index.ts\r\nexport * from './theme.service';\r\nexport * from './theme.provider';\r\n","/*\r\n * Public API Surface of theme\r\n */\r\n\r\nexport * from './lib/theme';\r\n\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAGa,eAAe,CAAA;AAClB,IAA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|
|
9
9
|
static ɵprov: i0.ɵɵInjectableDeclaration<EraThemeService>;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
declare enum EraTheme {
|
|
13
|
+
LIGHT = "e-light",
|
|
14
|
+
DARK = "e-dark"
|
|
15
|
+
}
|
|
12
16
|
interface EraThemeConfig {
|
|
13
|
-
defaultTheme?:
|
|
17
|
+
defaultTheme?: EraTheme;
|
|
14
18
|
}
|
|
15
19
|
declare function provideEraTheme(config?: EraThemeConfig): EnvironmentProviders;
|
|
16
20
|
|
package/styles/light.css
DELETED