@anmiles/theme-switcher 1.0.0
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/.eslintignore +2 -0
- package/.eslintrc.js +10 -0
- package/.vscode/settings.json +6 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE.md +21 -0
- package/README.md +88 -0
- package/coverage.config.js +8 -0
- package/dev/index.html +35 -0
- package/dist/theme-switcher-0.1.0.js +2194 -0
- package/dist/theme-switcher-0.1.0.min.js +2 -0
- package/dist/theme-switcher-0.1.0.min.js.LICENSE.txt +9 -0
- package/jest.config.js +26 -0
- package/package.json +71 -0
- package/src/__mocks__/css.ts +1 -0
- package/src/__tests__/index.test.tsx +25 -0
- package/src/__tests__/theme.test.ts +23 -0
- package/src/components/App.tsx +55 -0
- package/src/components/Icon.tsx +19 -0
- package/src/components/ThemeSelector.tsx +34 -0
- package/src/components/__tests__/App.test.tsx +350 -0
- package/src/components/__tests__/__snapshots__/App.test.tsx.snap +153 -0
- package/src/components/icons/Checked.tsx +24 -0
- package/src/components/icons/Dark.tsx +13 -0
- package/src/components/icons/Light.tsx +21 -0
- package/src/components/icons/System.tsx +18 -0
- package/src/index.tsx +20 -0
- package/src/lib/__tests__/eventEmitter.test.ts +109 -0
- package/src/lib/eventEmitter.ts +32 -0
- package/src/lib/theme.ts +21 -0
- package/src/providers/__tests__/systemProvider.test.ts +102 -0
- package/src/providers/__tests__/userProvider.test.ts +60 -0
- package/src/providers/systemProvider.ts +40 -0
- package/src/providers/userProvider.ts +24 -0
- package/src/styles/style.css +52 -0
- package/tsconfig.build.json +7 -0
- package/tsconfig.json +16 -0
- package/tsconfig.test.json +7 -0
- package/webpack.config.js +67 -0
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends" : "./node_modules/@anmiles/tsconfig/tsconfig.json",
|
|
3
|
+
|
|
4
|
+
"compilerOptions" : {
|
|
5
|
+
"rootDir" : "./src",
|
|
6
|
+
"outDir" : "./dist",
|
|
7
|
+
"jsx" : "react-jsx",
|
|
8
|
+
"sourceMap" : false,
|
|
9
|
+
"declaration" : false,
|
|
10
|
+
"declarationMap" : false
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
"include" : [
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
// eslint-disable-next-line n/no-unpublished-require
|
|
3
|
+
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
4
|
+
const { version } = require('./package.json');
|
|
5
|
+
|
|
6
|
+
module.exports = (env) => {
|
|
7
|
+
const isProduction = env.mode === 'production';
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
mode : env.mode,
|
|
11
|
+
entry : [
|
|
12
|
+
...isProduction ? [] : [ 'react-refresh/runtime' ],
|
|
13
|
+
'./src/index.tsx',
|
|
14
|
+
],
|
|
15
|
+
output : {
|
|
16
|
+
libraryTarget : 'umd',
|
|
17
|
+
filename : isProduction
|
|
18
|
+
? `theme-switcher-${version}.min.js`
|
|
19
|
+
: `theme-switcher-${version}.js`,
|
|
20
|
+
},
|
|
21
|
+
module : {
|
|
22
|
+
rules : [
|
|
23
|
+
{
|
|
24
|
+
test : /\.tsx?$/,
|
|
25
|
+
use : [
|
|
26
|
+
{
|
|
27
|
+
loader : 'ts-loader',
|
|
28
|
+
options : {
|
|
29
|
+
transpileOnly : true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
exclude : /node_modules/,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
test : /\.css$/,
|
|
37
|
+
use : [ 'style-loader', 'css-loader' ],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
resolve : {
|
|
42
|
+
extensions : [ '.tsx', '.ts', '.js' ],
|
|
43
|
+
},
|
|
44
|
+
externals : {
|
|
45
|
+
'react' : 'React',
|
|
46
|
+
'react-dom' : 'ReactDOM',
|
|
47
|
+
},
|
|
48
|
+
plugins : [
|
|
49
|
+
...isProduction ? [] : [ new ReactRefreshWebpackPlugin() ],
|
|
50
|
+
],
|
|
51
|
+
devtool : isProduction ? undefined : 'eval-source-map',
|
|
52
|
+
devServer : isProduction
|
|
53
|
+
? undefined
|
|
54
|
+
: {
|
|
55
|
+
static : [
|
|
56
|
+
{
|
|
57
|
+
directory : path.join(__dirname, 'dev'),
|
|
58
|
+
publicPath : '/',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
directory : path.join(__dirname, 'src/images'),
|
|
62
|
+
publicPath : '/images',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
};
|