Skip to content

Commit e283e8b

Browse files
committed
feat(core): rename dark mode params, props, events and methods
Param: `autoDarkTheme` -> `autoDarkMode` Event: `darkThemeChange` -> `darkModeChange` Prop: `darkTheme` -> `darkMode` Methods: - `enableAutoDarkTheme` -> `enableAutoDarkMode` - `disableAutoDarkTheme` -> `disableAutoDarkMode`
1 parent 8144a59 commit e283e8b

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/core/components/app/app-class.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export interface Framework7Parameters {
5353
language?: string;
5454
/** Array with default routes to all views.. (default []) */
5555
routes?: Router.RouteParameters[];
56-
/** Enables auto dark theme */
57-
autoDarkTheme?: boolean;
56+
/** Enables auto dark mode */
57+
autoDarkMode?: boolean;
5858
/** Lazy modules path */
5959
lazyModulesPath?: string;
6060
/** By default Framework7 will be initialized automatically when you call new Framework7(). If you want to prevent this behavior you can disable it with this option and then initialize it manually with init() when you need it.. (default true) */
@@ -116,8 +116,8 @@ export interface Framework7Plugin {
116116
export interface Framework7Events {
117117
/** Event will be fired on app initialization. Automatically after new Framework7() or after app.init() if you disabled auto init. */
118118
init: () => void;
119-
/** Event will be fired on device preferred color scheme change. It has effect only when `autoDarkTheme` enabled */
120-
darkThemeChange: (isDark: boolean) => void;
119+
/** Event will be fired on device preferred color scheme change. It has effect only when `autoDarkMode` enabled */
120+
darkModeChange: (isDark: boolean) => void;
121121
/** Event will be fired when app goes online */
122122
online: () => void;
123123
/** Event will be fired when app goes offline */
@@ -145,8 +145,8 @@ interface Framework7 extends Framework7Class<Framework7Events> {
145145
rtl: boolean;
146146
/** Current app theme. Can be md, ios or aurora */
147147
theme: string;
148-
/** Indicates whether the dark theme active or not. This property has effect only when `autoDarkTheme` enabled */
149-
darkTheme: boolean;
148+
/** Indicates whether the dark theme active or not. This property has effect only when `autoDarkMode` enabled */
149+
darkMode: boolean;
150150
/** Object with app root data passed on intialization */
151151
data: any;
152152
/** Object with app root methods */
@@ -159,10 +159,10 @@ interface Framework7 extends Framework7Class<Framework7Events> {
159159
$: Dom7;
160160
/** App parameters */
161161
params: Framework7Parameters;
162-
/** Enables auto dark theme detection */
163-
enableAutoDarkTheme(): void;
164-
/** Disables auto dark theme detection */
165-
disableAutoDarkTheme(): void;
162+
/** Enables auto dark mode detection */
163+
enableAutoDarkMode(): void;
164+
/** Disables auto dark mode detection */
165+
disableAutoDarkMode(): void;
166166
/** Initialize app. In case you disabled auto initialization with init: false parameter */
167167
init(): void;
168168
/** Load module */

src/core/components/app/app-class.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Framework7 extends Framework7Class {
4646
lazyModulesPath: null,
4747
initOnDeviceReady: true,
4848
init: true,
49-
autoDarkTheme: false,
49+
autoDarkMode: false,
5050
iosTranslucentBars: true,
5151
iosTranslucentModals: true,
5252
component: undefined,
@@ -142,13 +142,13 @@ class Framework7 extends Framework7Class {
142142
}
143143
const html = document.querySelector('html');
144144
if (media === DARK) {
145-
html.classList.add('theme-dark');
146-
app.darkTheme = true;
147-
app.emit('darkThemeChange', true);
145+
html.classList.add('dark');
146+
app.darkMode = true;
147+
app.emit('darkModeChange', true);
148148
} else if (media === LIGHT) {
149-
html.classList.remove('theme-dark');
150-
app.darkTheme = false;
151-
app.emit('darkThemeChange', false);
149+
html.classList.remove('dark');
150+
app.darkMode = false;
151+
app.emit('darkModeChange', false);
152152
}
153153
};
154154
app.emit('mount');
@@ -163,7 +163,7 @@ class Framework7 extends Framework7Class {
163163
}
164164
}
165165

166-
enableAutoDarkTheme() {
166+
enableAutoDarkMode() {
167167
const window = getWindow();
168168
const document = getDocument();
169169
if (!window.matchMedia) return;
@@ -174,17 +174,17 @@ class Framework7 extends Framework7Class {
174174
app.mq.light.addListener(app.colorSchemeListener);
175175
}
176176
if (app.mq.dark && app.mq.dark.matches) {
177-
html.classList.add('theme-dark');
178-
app.darkTheme = true;
179-
app.emit('darkThemeChange', true);
177+
html.classList.add('dark');
178+
app.darkMode = true;
179+
app.emit('darkModeChange', true);
180180
} else if (app.mq.light && app.mq.light.matches) {
181-
html.classList.remove('theme-dark');
182-
app.darkTheme = false;
183-
app.emit('darkThemeChange', false);
181+
html.classList.remove('dark');
182+
app.darkMode = false;
183+
app.emit('darkModeChange', false);
184184
}
185185
}
186186

187-
disableAutoDarkTheme() {
187+
disableAutoDarkMode() {
188188
const window = getWindow();
189189
if (!window.matchMedia) return;
190190
const app = this;
@@ -225,8 +225,8 @@ class Framework7 extends Framework7Class {
225225
}
226226

227227
// Auto Dark Theme
228-
if (app.params.autoDarkTheme) {
229-
app.enableAutoDarkTheme();
228+
if (app.params.autoDarkMode) {
229+
app.enableAutoDarkMode();
230230
}
231231

232232
// Watch for online/offline state

0 commit comments

Comments
 (0)