@zuzjs/ui 0.3.3 → 0.3.4
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/README.md +0 -0
- package/dist/hooks.js +89 -0
- package/dist/styles.css +37 -62
- package/dist/ui.js +665 -0
- package/jest.config.js +0 -0
- package/package.json +16 -18
- package/rollup.config.js +30 -47
- package/src/comps/box.tsx +24 -28
- package/src/comps/button.tsx +23 -47
- package/src/comps/crumb.tsx +9 -0
- package/src/comps/form.tsx +57 -88
- package/src/comps/heading.tsx +25 -31
- package/src/comps/icon.tsx +24 -36
- package/src/comps/input.tsx +24 -224
- package/src/comps/select.tsx +23 -63
- package/src/comps/spinner.tsx +23 -35
- package/src/comps/stylesheet.tsx +5 -0
- package/src/context/AppContext.tsx +2 -2
- package/src/context/AppProvider.tsx +68 -105
- package/src/context/createSlice.tsx +15 -39
- package/src/context/index.tsx +4 -5
- package/src/core/css.ts +1 -0
- package/src/core/index.tsx +241 -0
- package/src/core/styles.ts +378 -371
- package/src/hooks/index.tsx +2 -10
- package/src/hooks/useDispatch.tsx +36 -36
- package/src/hooks/useStore.tsx +24 -26
- package/src/hooks.tsx +8 -0
- package/src/scss/mixins.scss +2 -2
- package/src/scss/props.scss +91 -69
- package/src/scss/{style.scss → styles.scss} +102 -132
- package/src/ui.tsx +13 -0
- package/tsconfig.json +0 -0
- package/tsconfig.lib.json +0 -0
- package/tsconfig.spec.json +0 -0
- package/dist/index.js +0 -1879
- package/src/actions/addForm.tsx +0 -0
- package/src/actions/index.tsx +0 -29
- package/src/actions/redo.tsx +0 -1
- package/src/actions/reset.tsx +0 -1
- package/src/actions/undo.tsx +0 -1
- package/src/comps/app.tsx +0 -34
- package/src/comps/checkbox.tsx +0 -74
- package/src/comps/component.tsx +0 -32
- package/src/comps/contextmenu.tsx +0 -60
- package/src/comps/cover.tsx +0 -34
- package/src/comps/image.tsx +0 -34
- package/src/comps/masonry.tsx +0 -192
- package/src/comps/mediaplayer.tsx +0 -12
- package/src/comps/placeholder.tsx +0 -58
- package/src/comps/root.tsx +0 -32
- package/src/comps/spacer.tsx +0 -20
- package/src/comps/text.tsx +0 -27
- package/src/comps/toaster.tsx +0 -123
- package/src/comps/tweet.tsx +0 -48
- package/src/context/_AppProvider.tsx +0 -116
- package/src/context/combineReducers.tsx +0 -47
- package/src/context/combineState.tsx +0 -14
- package/src/context/reduceReducers.tsx +0 -6
- package/src/context/store/appbase.tsx +0 -19
- package/src/context/store/lang.tsx +0 -26
- package/src/context/store/theme.tsx +0 -54
- package/src/core/extractCurrentDesignState.tsx +0 -0
- package/src/core/index.ts +0 -431
- package/src/core/router.ts +0 -86
- package/src/hooks/useAppReducer.tsx +0 -40
- package/src/hooks/useChooseEffect.tsx +0 -6
- package/src/hooks/useContextMenu.tsx +0 -123
- package/src/hooks/useDevice.tsx +0 -168
- package/src/hooks/useImage.tsx +0 -84
- package/src/hooks/useLang.tsx +0 -9
- package/src/hooks/useMediaPlayer.tsx +0 -27
- package/src/hooks/useNavigator.tsx +0 -6
- package/src/hooks/useRender.tsx +0 -29
- package/src/hooks/useResizeObserver.tsx +0 -84
- package/src/hooks/useRouter.tsx +0 -45
- package/src/hooks/useSelector.tsx +0 -9
- package/src/hooks/useTheme.tsx +0 -9
- package/src/hooks/useToast.tsx +0 -11
- package/src/index.tsx +0 -33
- package/src/kit/Builder.tsx +0 -18
- package/src/kit/Component.tsx +0 -32
- package/src/kit/Header.tsx +0 -21
- package/src/scss/constants.scss +0 -4
package/src/comps/toaster.tsx
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { nanoid } from 'nanoid'
|
|
2
|
-
|
|
3
|
-
class Toaster {
|
|
4
|
-
|
|
5
|
-
#container : any;
|
|
6
|
-
#startTop : number
|
|
7
|
-
#tout : null
|
|
8
|
-
#defaultTimeLeft : number
|
|
9
|
-
#root : string
|
|
10
|
-
|
|
11
|
-
constructor(config?: {
|
|
12
|
-
root : string,
|
|
13
|
-
duration: number
|
|
14
|
-
}){
|
|
15
|
-
this.#startTop = 20
|
|
16
|
-
this.#defaultTimeLeft = 4
|
|
17
|
-
const rootID = config?.root || `toast-container`;
|
|
18
|
-
this.#root = rootID;
|
|
19
|
-
|
|
20
|
-
this.addRoot();
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
addRoot(){
|
|
25
|
-
if(window.document.querySelector(`#${this.#root}`)) return;
|
|
26
|
-
var root = window.document.createElement('div');
|
|
27
|
-
root.id = this.#root;
|
|
28
|
-
window.document.body.appendChild(root);
|
|
29
|
-
this.#container = window.document.querySelector(`#${this.#root}`)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
show = (
|
|
33
|
-
message: string | null,
|
|
34
|
-
duration?: number
|
|
35
|
-
) => {
|
|
36
|
-
let self = this;
|
|
37
|
-
self.toast({
|
|
38
|
-
message: message,
|
|
39
|
-
duration: duration
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
dismiss(ID: string){
|
|
44
|
-
let self = this
|
|
45
|
-
self.#tout && clearTimeout(self.#tout);
|
|
46
|
-
setTimeout(()=>{
|
|
47
|
-
let tost = document.querySelector(`#${ID}`);
|
|
48
|
-
tost && tost.classList.remove("visible");
|
|
49
|
-
// tost && tost.classList.add("hidden");
|
|
50
|
-
setTimeout(()=>{
|
|
51
|
-
try{
|
|
52
|
-
document.getElementById(ID).parentNode.removeChild(document.getElementById(ID));
|
|
53
|
-
}catch(e){}
|
|
54
|
-
self.arrangeToasts();
|
|
55
|
-
}, 200);
|
|
56
|
-
}, 200);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
toast(config?: {
|
|
60
|
-
message: string | null,
|
|
61
|
-
duration: number
|
|
62
|
-
}){
|
|
63
|
-
|
|
64
|
-
var self = this;
|
|
65
|
-
self.addRoot();
|
|
66
|
-
var tout = null,
|
|
67
|
-
ID = 'toast-' + nanoid(),
|
|
68
|
-
toast = window.document.createElement('div'),
|
|
69
|
-
toastBG = window.document.createElement('div');
|
|
70
|
-
|
|
71
|
-
toast.id = ID;
|
|
72
|
-
toast.style.backgroundColor = `#111`
|
|
73
|
-
toast.style.color = `#fff`
|
|
74
|
-
toast.style.transform = `translate(-50%, -300px) scale(0.5)`;
|
|
75
|
-
toast.style.position = `fixed`
|
|
76
|
-
toast.style.padding = `6px 12px`
|
|
77
|
-
toast.style.fontSize = `14px`
|
|
78
|
-
toast.style.left = `50%`
|
|
79
|
-
toast.style.maxWidth = `95%`
|
|
80
|
-
toast.style.zIndex = `2147483647`
|
|
81
|
-
toast.classList.add( 'zuz-toast' );
|
|
82
|
-
toast.classList.add( 'fixed' );
|
|
83
|
-
toast.classList.add( 'f' );
|
|
84
|
-
|
|
85
|
-
toast.innerHTML = config.message || `You haven't passed "message" in this toast`;
|
|
86
|
-
|
|
87
|
-
(self.#container || window.document.querySelector(`#${self.#root}`)).appendChild(toast);
|
|
88
|
-
|
|
89
|
-
self.arrangeToasts()
|
|
90
|
-
.then(() => {
|
|
91
|
-
setTimeout(()=>{
|
|
92
|
-
let tost = document.querySelector("#"+ID);
|
|
93
|
-
tost.classList.add("showing");
|
|
94
|
-
tout = setTimeout(() => self.dismiss(ID), (config?.duration == undefined ? self.#defaultTimeLeft : config?.duration == -1 ? 86400 : config?.duration) * 1000);
|
|
95
|
-
setTimeout(()=>{
|
|
96
|
-
let tost = document.querySelector("#"+ID);
|
|
97
|
-
tost.classList.remove("showing");
|
|
98
|
-
tost.classList.add("visible");
|
|
99
|
-
}, 200)
|
|
100
|
-
|
|
101
|
-
}, 10)
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
arrangeToasts(){
|
|
106
|
-
var self = this, top = self.#startTop;
|
|
107
|
-
return new Promise((resolve, reject) => {
|
|
108
|
-
var toasts = document.querySelectorAll(".zuz-toast"),
|
|
109
|
-
i = toasts.length;
|
|
110
|
-
while(i--){
|
|
111
|
-
toasts[i]['style'].top = `${top}px`
|
|
112
|
-
top += parseInt(getComputedStyle(toasts[i]).height.replace('px', '')) + 6;
|
|
113
|
-
}
|
|
114
|
-
resolve(null);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export default Toaster;
|
package/src/comps/tweet.tsx
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
// import PropTypes from `prop-types`
|
|
3
|
-
import Box from './box'
|
|
4
|
-
import { addScript } from '../core';
|
|
5
|
-
|
|
6
|
-
const Tweet = (props) => {
|
|
7
|
-
|
|
8
|
-
const [rand, setRand] = useState(Math.random())
|
|
9
|
-
const _tweet = useRef()
|
|
10
|
-
|
|
11
|
-
const renderTweet = () => {
|
|
12
|
-
const twttr = window['twttr']
|
|
13
|
-
twttr.ready().then(({ widgets }) => {
|
|
14
|
-
const { options, onTweetLoadSuccess, onTweetLoadError } = props
|
|
15
|
-
widgets
|
|
16
|
-
.createTweetEmbed(props.id, _tweet.current, options || {})
|
|
17
|
-
.then((twitterWidgetElement) => {
|
|
18
|
-
// this.setState({
|
|
19
|
-
// isLoading: false
|
|
20
|
-
// })
|
|
21
|
-
// onTweetLoadSuccess && onTweetLoadSuccess(twitterWidgetElement)
|
|
22
|
-
})
|
|
23
|
-
.catch(() => {})
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const twttr = window['twttr']
|
|
30
|
-
if (!(twttr && twttr.ready)){
|
|
31
|
-
addScript(`https://platform.twitter.com/widgets.js`, renderTweet)
|
|
32
|
-
}else{
|
|
33
|
-
renderTweet()
|
|
34
|
-
}
|
|
35
|
-
}, [])
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
|
|
39
|
-
}, [rand])
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Box as={`tweet`} weight={1} bref={_tweet}></Box>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export default Tweet;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useCallback,
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
useReducer
|
|
6
|
-
} from 'react'
|
|
7
|
-
import PropTypes from 'prop-types'
|
|
8
|
-
import AppContext from './AppContext'
|
|
9
|
-
// import useAppReducer from '../hooks/useAppReducer'
|
|
10
|
-
import AppTheme from './store/theme'
|
|
11
|
-
let isMounted = true;
|
|
12
|
-
import appSlice from './store/appbase'
|
|
13
|
-
import combineReducers, { combineState } from './combineReducers'
|
|
14
|
-
import reduceReducers from './reduceReducers'
|
|
15
|
-
// const rootReducer = (state, action ) => ({
|
|
16
|
-
// ...state,
|
|
17
|
-
// ...action.payload
|
|
18
|
-
// })
|
|
19
|
-
|
|
20
|
-
// const rootReducer = combineReducers()
|
|
21
|
-
|
|
22
|
-
const AppProvider = ({
|
|
23
|
-
children,
|
|
24
|
-
// initialState = {},
|
|
25
|
-
reducers = {},
|
|
26
|
-
theme = {}
|
|
27
|
-
}) => {
|
|
28
|
-
|
|
29
|
-
const _dynamiceState = useMemo(() => {
|
|
30
|
-
const __ = {}
|
|
31
|
-
Object.keys(reducers).map(k => {
|
|
32
|
-
__[reducers[k].name] = [reducers[k].reducer, reducers[k].state]
|
|
33
|
-
})
|
|
34
|
-
return __
|
|
35
|
-
}, [reducers])
|
|
36
|
-
|
|
37
|
-
const _dynamiceReducers = useMemo(() => {
|
|
38
|
-
const __ = {}
|
|
39
|
-
Object.keys(reducers).map(k => {
|
|
40
|
-
__[reducers[k].name] = reduceReducers(reducers[k].reducer)
|
|
41
|
-
})
|
|
42
|
-
return __
|
|
43
|
-
}, [reducers])
|
|
44
|
-
|
|
45
|
-
const themeReducer = useCallback(() => {
|
|
46
|
-
(state, action) => ({
|
|
47
|
-
...state,
|
|
48
|
-
...action.payload
|
|
49
|
-
})
|
|
50
|
-
}, [])
|
|
51
|
-
|
|
52
|
-
// const [rootReducer, rootState] = useMemo(() => combineReducers({
|
|
53
|
-
// theme: [themeReducer, new AppTheme({ theme }).get()],
|
|
54
|
-
// [appSlice.name] : [appSlice.reducer, appSlice.state],
|
|
55
|
-
// ..._dynamiceReducers
|
|
56
|
-
// }), [reducers]);
|
|
57
|
-
|
|
58
|
-
const [_, rootState] = combineState({
|
|
59
|
-
theme: [themeReducer, new AppTheme({ theme }).get()],
|
|
60
|
-
[appSlice.name] : [appSlice.reducer, appSlice.state],
|
|
61
|
-
..._dynamiceState
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
const rootReducer = combineReducers({
|
|
65
|
-
theme: reduceReducers(themeReducer),
|
|
66
|
-
[appSlice.name] : reduceReducers(appSlice.reducer),
|
|
67
|
-
..._dynamiceReducers
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
console.log(rootState)
|
|
71
|
-
|
|
72
|
-
const [state, dispatch] = useReducer(
|
|
73
|
-
rootReducer,
|
|
74
|
-
rootState
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
isMounted = true;
|
|
79
|
-
return () => {
|
|
80
|
-
isMounted = false;
|
|
81
|
-
}
|
|
82
|
-
}, [])
|
|
83
|
-
|
|
84
|
-
// const dispatch = useCallback(() => {
|
|
85
|
-
// if(isMounted){
|
|
86
|
-
// // let ags = { ...args, action: }
|
|
87
|
-
// _dispatch();
|
|
88
|
-
// // _dispatch({ action: action, payload: payload })
|
|
89
|
-
// }
|
|
90
|
-
// }, [_dispatch]);
|
|
91
|
-
|
|
92
|
-
const providedValue = useMemo(
|
|
93
|
-
() => ({
|
|
94
|
-
...rootState,
|
|
95
|
-
// defaultState,
|
|
96
|
-
dispatch
|
|
97
|
-
}),
|
|
98
|
-
[state]
|
|
99
|
-
// [defaultState, state]
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
return <AppContext.Provider value={providedValue}>{children}</AppContext.Provider>
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
AppProvider.defaultProps = {
|
|
106
|
-
reducers: {}
|
|
107
|
-
// initialState : {},
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
AppProvider.propTypes = {
|
|
111
|
-
children: PropTypes.node.isRequired,
|
|
112
|
-
// initialState: PropTypes.instanceOf(Object)
|
|
113
|
-
reducers: PropTypes.instanceOf(Object)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export default AppProvider
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export const combineState = reducers => {
|
|
2
|
-
const reducerKeys = Object.keys(reducers);
|
|
3
|
-
const reducerValues = Object.values(reducers);
|
|
4
|
-
|
|
5
|
-
let globalState
|
|
6
|
-
reducerKeys.forEach((k, i) => globalState = { ...globalState, [k]: reducerValues[i][1] } )
|
|
7
|
-
|
|
8
|
-
let finalReducers = {}
|
|
9
|
-
reducerValues.forEach((v, i) => finalReducers = { ...finalReducers, [reducerKeys[i]] : v[0] });
|
|
10
|
-
|
|
11
|
-
return [
|
|
12
|
-
(state, action) => {
|
|
13
|
-
console.log('state', state)
|
|
14
|
-
console.log('action', action)
|
|
15
|
-
let hasStateChanged = false
|
|
16
|
-
const newState = {}
|
|
17
|
-
let nextStateForCurrentKey = {}
|
|
18
|
-
for(let i = 0; i < reducerKeys.length; i++){
|
|
19
|
-
const currentKey = reducerKeys[i]
|
|
20
|
-
const currentReducer = finalReducers[currentKey]
|
|
21
|
-
const prevStateForCurrentKey = state[currentKey]
|
|
22
|
-
nextStateForCurrentKey = currentReducer(
|
|
23
|
-
prevStateForCurrentKey,
|
|
24
|
-
action
|
|
25
|
-
)
|
|
26
|
-
hasStateChanged = hasStateChanged || nextStateForCurrentKey !== prevStateForCurrentKey
|
|
27
|
-
newState[currentKey] = nextStateForCurrentKey
|
|
28
|
-
}
|
|
29
|
-
return hasStateChanged ? newState : state
|
|
30
|
-
},
|
|
31
|
-
globalState
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const combineReducers = slices => {
|
|
37
|
-
return (state, action) =>
|
|
38
|
-
Object.keys(slices).reduce(
|
|
39
|
-
(acc, prop) => ({
|
|
40
|
-
...acc,
|
|
41
|
-
[prop]: slices[prop](acc[prop], action)
|
|
42
|
-
}),
|
|
43
|
-
state
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default combineReducers;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const combineState = (state) => {
|
|
2
|
-
// const reducerKeys = Object.keys(state);
|
|
3
|
-
// const stateValues = Object.values(state);
|
|
4
|
-
|
|
5
|
-
// let globalState
|
|
6
|
-
|
|
7
|
-
// reducerKeys.forEach((k, i) => globalState = { ...globalState, [k]: reducerValues[i][1] } )
|
|
8
|
-
|
|
9
|
-
// console.log(globalState)
|
|
10
|
-
|
|
11
|
-
return state;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default combineState
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import createSlice from '../createSlice'
|
|
2
|
-
|
|
3
|
-
const appSlice = createSlice({
|
|
4
|
-
name: 'app',
|
|
5
|
-
initialState: {
|
|
6
|
-
debug: true,
|
|
7
|
-
version: 1.2,
|
|
8
|
-
loading: false
|
|
9
|
-
},
|
|
10
|
-
reducers: {
|
|
11
|
-
setCVersion: (state, action) => state.version = action.payload
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const {
|
|
16
|
-
setLoading
|
|
17
|
-
} = appSlice.actions
|
|
18
|
-
|
|
19
|
-
export default appSlice;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
class AppLang {
|
|
2
|
-
|
|
3
|
-
#mode;
|
|
4
|
-
#listen;
|
|
5
|
-
#lang;
|
|
6
|
-
|
|
7
|
-
constructor(_conf){
|
|
8
|
-
const conf = _conf || {}
|
|
9
|
-
this.#listen = "listen" in conf ? conf.listen : (mod) => { console.log(`Lang switched to ${mod}`); };
|
|
10
|
-
this.#mode = conf.mode || "en";
|
|
11
|
-
this.#lang = {
|
|
12
|
-
//CORE
|
|
13
|
-
tag: "en",
|
|
14
|
-
...( "lang" in conf ? {...conf.lang} : {})
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
get = () => {
|
|
19
|
-
let self = this;
|
|
20
|
-
return self.#lang
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default AppLang
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
class AppTheme {
|
|
2
|
-
|
|
3
|
-
#mode;
|
|
4
|
-
#listen;
|
|
5
|
-
#lightTheme;
|
|
6
|
-
#darkTheme;
|
|
7
|
-
|
|
8
|
-
constructor(_conf){
|
|
9
|
-
const conf = _conf || {}
|
|
10
|
-
this.#listen = "listen" in conf ? conf.listen : (mod) => { console.log(`Theme switched to ${mod}`); };
|
|
11
|
-
this.#mode = conf.mode || conf.theme.mode || "auto";
|
|
12
|
-
this.#lightTheme = {
|
|
13
|
-
//CORE
|
|
14
|
-
tag: "light",
|
|
15
|
-
dark: false,
|
|
16
|
-
primary: '#edeef5',
|
|
17
|
-
secondary: '#f9f9f9',
|
|
18
|
-
textColor: '#111111',
|
|
19
|
-
...( "theme" in conf && "light" in conf.theme ? {...conf.theme.light} : {})
|
|
20
|
-
};
|
|
21
|
-
this.#darkTheme = {
|
|
22
|
-
//CORE
|
|
23
|
-
tag: "dark",
|
|
24
|
-
dark: true,
|
|
25
|
-
primary: '#21222d',
|
|
26
|
-
secondary: '#282a37',
|
|
27
|
-
textColor: '#f9f9f9',
|
|
28
|
-
...( "theme" in conf && "dark" in conf.theme ? {...conf.theme.dark} : {})
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
get = () => {
|
|
33
|
-
let self = this;
|
|
34
|
-
if(self.#mode === "auto"){
|
|
35
|
-
typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
|
36
|
-
self.#mode = event.matches ? "dark" : "light";
|
|
37
|
-
self.#listen(self.#mode);
|
|
38
|
-
});
|
|
39
|
-
return typeof window !== 'undefined' && window.matchMedia &&
|
|
40
|
-
window.matchMedia('(prefers-color-scheme: dark)').matches ?
|
|
41
|
-
self.#darkTheme : self.#lightTheme;
|
|
42
|
-
}else{
|
|
43
|
-
if(self.#mode === "light"){
|
|
44
|
-
return self.#lightTheme;
|
|
45
|
-
}else if(self.#mode === "dark"){
|
|
46
|
-
return self.#darkTheme;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default AppTheme
|
|
File without changes
|