@fxlt/common-ui 0.0.4-beta1 → 0.0.4-beta2
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.
- package/fesm2022/fxlt-common-ui.mjs +55 -1
- package/fesm2022/fxlt-common-ui.mjs.map +1 -1
- package/index.d.ts +18 -2
- package/package.json +1 -1
- package/src/lib/styles/theme.css +3 -3
- package/theme.css +3 -3
|
@@ -1192,6 +1192,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImpor
|
|
|
1192
1192
|
args: [PLATFORM_ID]
|
|
1193
1193
|
}] }] });
|
|
1194
1194
|
|
|
1195
|
+
class ThemeService {
|
|
1196
|
+
renderer;
|
|
1197
|
+
lightClass = 'light_theme';
|
|
1198
|
+
theme$ = new BehaviorSubject('dark');
|
|
1199
|
+
themeStorageKey = 'host-theme';
|
|
1200
|
+
constructor(rendererFactory) {
|
|
1201
|
+
this.renderer = rendererFactory.createRenderer(null, null);
|
|
1202
|
+
const savedTheme = localStorage.getItem(this.themeStorageKey);
|
|
1203
|
+
if (savedTheme) {
|
|
1204
|
+
this.setLightMode(savedTheme === 'light');
|
|
1205
|
+
}
|
|
1206
|
+
else {
|
|
1207
|
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
1208
|
+
const isDark = document.body.classList.contains(this.lightClass) || prefersDark;
|
|
1209
|
+
this.setLightMode(isDark);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
setLightMode(enable) {
|
|
1213
|
+
if (enable) {
|
|
1214
|
+
this.renderer.addClass(document.body, this.lightClass);
|
|
1215
|
+
this.theme$.next('light');
|
|
1216
|
+
localStorage.setItem(this.themeStorageKey, 'light');
|
|
1217
|
+
}
|
|
1218
|
+
else {
|
|
1219
|
+
this.renderer.removeClass(document.body, this.lightClass);
|
|
1220
|
+
this.theme$.next('dark');
|
|
1221
|
+
localStorage.setItem(this.themeStorageKey, 'dark');
|
|
1222
|
+
}
|
|
1223
|
+
window.dispatchEvent(new CustomEvent('theme-changed', { detail: { dark: !enable } }));
|
|
1224
|
+
}
|
|
1225
|
+
toggleTheme() {
|
|
1226
|
+
const isLight = this.theme$.value === 'light';
|
|
1227
|
+
this.setLightMode(!isLight);
|
|
1228
|
+
}
|
|
1229
|
+
themeChanges() {
|
|
1230
|
+
return this.theme$.asObservable();
|
|
1231
|
+
}
|
|
1232
|
+
getCurrentTheme() {
|
|
1233
|
+
return this.theme$.value;
|
|
1234
|
+
}
|
|
1235
|
+
isLight() {
|
|
1236
|
+
return this.theme$.value === 'light';
|
|
1237
|
+
}
|
|
1238
|
+
getLogoPath() {
|
|
1239
|
+
return 'assets/images/logo.png';
|
|
1240
|
+
}
|
|
1241
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ThemeService, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1242
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ThemeService, providedIn: 'root' });
|
|
1243
|
+
}
|
|
1244
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ThemeService, decorators: [{
|
|
1245
|
+
type: Injectable,
|
|
1246
|
+
args: [{ providedIn: 'root' }]
|
|
1247
|
+
}], ctorParameters: () => [{ type: i0.RendererFactory2 }] });
|
|
1248
|
+
|
|
1195
1249
|
const MATERIAL_MODULE = [
|
|
1196
1250
|
MatSelectModule,
|
|
1197
1251
|
MatRadioModule,
|
|
@@ -2924,5 +2978,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImpor
|
|
|
2924
2978
|
* Generated bundle index. Do not edit.
|
|
2925
2979
|
*/
|
|
2926
2980
|
|
|
2927
|
-
export { AuthInterceptor, AuthStateService, BaseComponent, BaseDialogComponent, BaseResolver, BaseTableComponent, BreadcrumbService, ButtonComponent, ChartComponent, CheckboxComponent, CircleProgressBar, ConfirmationDialogComponent, DatetimePicker, DndUploadComponent, FlowConnection, FxLoadingService, FxStorageService, FxToastrService, FxUtils, HasPermissionDirective, HeroIconComponent, HttpLoaderFactory, HttpWrapper, InputComponent, LoadingPanel, MY_MOMENT_FORMATS, PermissionGuard, PermissionService, QuillStyleLoaderService, RadioButtonComponent, RadioButtonToggleComponent, RichTextAreaComponent, SearchBarComponent, SelectComponent, SkeletonTableLoadingComponent, SliderComponent, SwitchComponent, TabComponent, TabGroupComponent, TagComponent, ToastComponent, ToastContainerComponent, TranslationModule, TranslationService, TreeDiagram, TrimOnBlurDirective, UiModule };
|
|
2981
|
+
export { AuthInterceptor, AuthStateService, BaseComponent, BaseDialogComponent, BaseResolver, BaseTableComponent, BreadcrumbService, ButtonComponent, ChartComponent, CheckboxComponent, CircleProgressBar, ConfirmationDialogComponent, DatetimePicker, DndUploadComponent, FlowConnection, FxLoadingService, FxStorageService, FxToastrService, FxUtils, HasPermissionDirective, HeroIconComponent, HttpLoaderFactory, HttpWrapper, InputComponent, LoadingPanel, MY_MOMENT_FORMATS, PermissionGuard, PermissionService, QuillStyleLoaderService, RadioButtonComponent, RadioButtonToggleComponent, RichTextAreaComponent, SearchBarComponent, SelectComponent, SkeletonTableLoadingComponent, SliderComponent, SwitchComponent, TabComponent, TabGroupComponent, TagComponent, ThemeService, ToastComponent, ToastContainerComponent, TranslationModule, TranslationService, TreeDiagram, TrimOnBlurDirective, UiModule };
|
|
2928
2982
|
//# sourceMappingURL=fxlt-common-ui.mjs.map
|