@aiursoft/autodark.js 1.2.0 → 1.2.1
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/.editorconfig +11 -0
- package/.gitlab-ci.yml +40 -26
- package/LICENSE +21 -0
- package/README.md +14 -38
- package/dist/css/autodark.min.css +1 -3
- package/dist/css/autodark.min.css.map +1 -9
- package/docs/usage.md +54 -0
- package/package.json +6 -6
package/.editorconfig
ADDED
package/.gitlab-ci.yml
CHANGED
|
@@ -2,35 +2,49 @@ stages:
|
|
|
2
2
|
- check
|
|
3
3
|
- publish
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- 'echo "Available Disk Space: $(df -h --output=avail / | tail -1)"'
|
|
12
|
-
- 'echo "IP Address: $(hostname -I)"'
|
|
13
|
-
- 'npm --version'
|
|
14
|
-
- 'node --version'
|
|
5
|
+
workflow:
|
|
6
|
+
rules:
|
|
7
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
8
|
+
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
|
|
9
|
+
when: never
|
|
10
|
+
- if: '$CI_COMMIT_BRANCH'
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
check:
|
|
17
13
|
stage: check
|
|
18
14
|
script:
|
|
19
|
-
- npm
|
|
20
|
-
- npm run
|
|
21
|
-
- npm
|
|
15
|
+
- npm ci
|
|
16
|
+
- npm run check
|
|
17
|
+
- npm pack
|
|
18
|
+
artifacts:
|
|
19
|
+
expire_in: 1 week
|
|
20
|
+
paths:
|
|
21
|
+
- '*.tgz'
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
needs:
|
|
25
|
-
- build_locally
|
|
23
|
+
publish:
|
|
26
24
|
stage: publish
|
|
27
|
-
|
|
25
|
+
needs:
|
|
26
|
+
- job: check
|
|
27
|
+
artifacts: true
|
|
28
|
+
resource_group: npm-publish
|
|
28
29
|
script:
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
- |
|
|
31
|
+
set -- *.tgz
|
|
32
|
+
test "$#" -eq 1
|
|
33
|
+
test -f "$1"
|
|
34
|
+
package_name=$(node -p 'encodeURIComponent(require("./package.json").name)')
|
|
35
|
+
package_version=$(node -p 'require("./package.json").version')
|
|
36
|
+
status=$(curl --silent --show-error --location --output /dev/null --write-out '%{http_code}' \
|
|
37
|
+
"https://registry.npmjs.org/$package_name/$package_version")
|
|
38
|
+
case "$status" in
|
|
39
|
+
200) echo "Version $package_version is already published; skipping."; exit 0 ;;
|
|
40
|
+
404) ;;
|
|
41
|
+
*) echo "Cannot check published versions (HTTP $status)." >&2; exit 1 ;;
|
|
42
|
+
esac
|
|
43
|
+
: "${NPM_TOKEN:?npm publishing credential is required}"
|
|
44
|
+
npm_config_userconfig=$(mktemp)
|
|
45
|
+
export npm_config_userconfig
|
|
46
|
+
trap 'rm -f "$npm_config_userconfig"' EXIT
|
|
47
|
+
printf '%s\n' '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > "$npm_config_userconfig"
|
|
48
|
+
npm publish "$1" --registry=https://registry.npmjs.org --access public --ignore-scripts
|
|
49
|
+
rules:
|
|
50
|
+
- if: '$CI_COMMIT_BRANCH == "master"'
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Anduin Xue
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,52 +1,28 @@
|
|
|
1
|
-
# AutoDark.
|
|
1
|
+
# AutoDark.Js
|
|
2
2
|
|
|
3
|
-
[](https://gitlab.aiursoft.com/aiursoft/autodark.js/-/pipelines) [](https://www.npmjs.com/package/@aiursoft/autodark.js)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Detect the system color scheme and apply a Bootstrap 4.6.2 theme.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```sh
|
|
9
|
+
```bash
|
|
12
10
|
npm install @aiursoft/autodark.js
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
## Reference CSS
|
|
13
|
+
## Usage
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
Requires Bootstrap 4.6.2 and the package stylesheet. See [usage](docs/usage.md) for the HTML setup.
|
|
20
16
|
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
```js
|
|
18
|
+
import { autoTheme } from './node_modules/@aiursoft/autodark.js/dist/esm/autodark.js'
|
|
19
|
+
autoTheme()
|
|
24
20
|
```
|
|
25
21
|
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
You also need to reference bootstrap's JavaScript file:
|
|
29
|
-
|
|
30
|
-
```html
|
|
31
|
-
<script src="./node_modules/jquery/dist/jquery.min.js" defer></script>
|
|
32
|
-
<script src="./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" defer></script>
|
|
33
|
-
<script type="module">
|
|
34
|
-
import { autoTheme } from './node_modules/@aiursoft/autodark.js/dist/esm/autodark.js'
|
|
35
|
-
autoTheme()
|
|
36
|
-
</script>
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## How to build locally
|
|
22
|
+
## Development
|
|
40
23
|
|
|
41
24
|
```bash
|
|
42
|
-
npm
|
|
43
|
-
npm run
|
|
25
|
+
npm ci
|
|
26
|
+
npm run check
|
|
27
|
+
npm pack
|
|
44
28
|
```
|
|
45
|
-
|
|
46
|
-
## How to contribute
|
|
47
|
-
|
|
48
|
-
There are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.
|
|
49
|
-
|
|
50
|
-
Even if you with push rights on the repository, you should create a personal fork and create feature branches there when you need them. This keeps the main repository clean and your workflow cruft out of sight.
|
|
51
|
-
|
|
52
|
-
We're also interested in your feedback on the future of this project. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly.
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
.bg-dark{background-color:#24292e !important}footer{background-color:#f5f5f5}@media
|
|
2
|
-
|
|
3
|
-
/*# sourceMappingURL=autodark.min.css.map */
|
|
1
|
+
.bg-dark{background-color:#24292e !important}footer{background-color:#f5f5f5}@media(prefers-color-scheme: dark){footer{background-color:#1e2024 !important}.dropify-preview{background-color:#2a2b2d !important}.dropify-wrapper{background-color:#202123 !important;border:2px solid #666 !important}.dropify-wrapper:hover{background-image:linear-gradient(-45deg, #161616 25%, transparent 25%, transparent 50%, #161616 50%, #161616 75%, transparent 75%, transparent) !important}.text-muted{color:#8c959d !important}.content-wrapper{color:#fff !important}.jumbotron{background-color:#1e2024 !important}.breadcrumb{background-color:#2a2b2d !important}pre{background-color:#444 !important;color:#fff !important}code{background-color:#444 !important;color:#fff !important}.form-control{background-color:#232425 !important;color:#f0eae0 !important;border-color:#474f57 !important}.navbar-dark{box-shadow:0 10px 39px -6px rgba(0,0,0,.3)}.custom-select{color:#fff !important;background-color:#495057 !important}}/*# sourceMappingURL=autodark.min.css.map */
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"file": "autodark.min.css",
|
|
4
|
-
"sources": [
|
|
5
|
-
"../../src/autodark.scss"
|
|
6
|
-
],
|
|
7
|
-
"names": [],
|
|
8
|
-
"mappings": "AAAA,AAAA,QAAQ,AAAC,CACP,gBAAgB,CAAE,kBAAkB,CACrC,AAED,AAAA,MAAM,AAAC,CACL,gBAAgB,CAAE,OAAO,CAC1B,AAED,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAChC,AAAA,MAAM,AAAC,CACL,gBAAgB,CAAE,kBAAkB,CACrC,AAED,AAAA,gBAAgB,AAAC,CACf,gBAAgB,CAAE,OAAe,CAAC,UAAU,CAC7C,AACD,AAAA,gBAAgB,AAAC,CACf,gBAAgB,CAAE,OAAe,CAAC,UAAU,CAC5C,MAAM,CAAE,yBAAyB,CAalC,AAfD,AAGE,gBAHc,AAGb,MAAM,AAAC,CACN,gBAAgB,CAAE,8HASjB,CAAC,UAAU,CACb,AAEH,AAAA,WAAW,AAAC,CACV,KAAK,CAAE,kBAAkB,CAC1B,AACD,AAAA,gBAAgB,AAAC,CACf,KAAK,CAAE,gBAAgB,CACxB,AACD,AAAA,UAAU,AAAC,CACT,gBAAgB,CAAE,OAAe,CAAC,UAAU,CAC7C,AACD,AAAA,WAAW,AAAC,CACV,gBAAgB,CAAE,OAAe,CAAC,UAAU,CAC7C,AACD,AAAA,GAAG,AAAC,CACF,gBAAgB,CAAE,eAAe,CACjC,KAAK,CAAE,eAAe,CACvB,AACD,AAAA,IAAI,AAAC,CACH,gBAAgB,CAAE,eAAe,CACjC,KAAK,CAAE,eAAe,CACvB,AACD,AAAA,aAAa,AAAC,CACZ,gBAAgB,CAAE,OAAe,CAAC,UAAU,CAC5C,KAAK,CAAE,OAAkB,CAAC,UAAU,CACpC,YAAY,CAAE,OAAe,CAAC,UAAU,CACzC,AACD,AAAA,YAAY,AAAC,CACX,UAAU,CAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAE,IAAG,CAAC,eAAkB,CAChD,AACD,AAAA,cAAc,AAAC,CACb,KAAK,CAAE,gBAAgB,CACvB,gBAAgB,CAAE,kBAAkB,CACrC"
|
|
9
|
-
}
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../src/autodark.scss"],"names":[],"mappings":"AAAA,SACE,oCAGF,OACE,yBAGF,mCACE,OACE,oCAGF,iBACE,oCAEF,iBACE,oCACA,iCACA,uBACE,2JAYJ,YACE,yBAEF,iBACE,sBAEF,WACE,oCAEF,YACE,oCAEF,IACE,iCACA,sBAEF,KACE,iCACA,sBAEF,cACE,oCACA,yBACA,gCAEF,aACE,2CAEF,eACE,sBACA","file":"autodark.min.css"}
|
package/docs/usage.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# AutoDark.js
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/license/mit) [](https://gitlab.aiursoft.com/aiursoft/autodark.js/-/pipelines) [](https://manhours.aiursoft.com/r/github.com/aiursoftweb/autodark.js.html) [](https://www.npmjs.com/package/@aiursoft/autodark.js) [](https://www.npmjs.com/package/@aiursoft/autodark.js)
|
|
4
|
+
|
|
5
|
+
`@aiursoft/autodark.js` is a JavaScript library for detecting user's system dark mode and auto switch your website's theme.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Run the following command to install the most recent version of `@aiursoft/autodark.js` from npm:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @aiursoft/autodark.js
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Bootstrap 4.6.2 is the only version that is tested. To use this project, you need to use bootstrap 4.6.2 in your project.
|
|
16
|
+
|
|
17
|
+
## Importing
|
|
18
|
+
|
|
19
|
+
## Reference CSS
|
|
20
|
+
|
|
21
|
+
You also need to reference the CSS file in your HTML:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css" />
|
|
25
|
+
<link rel="stylesheet" href="./node_modules/@aiursoft/autodark.js/dist/css/autodark.min.css" />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Reference JavaScript
|
|
29
|
+
|
|
30
|
+
You also need to reference bootstrap's JavaScript file:
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<script src="./node_modules/jquery/dist/jquery.min.js" defer></script>
|
|
34
|
+
<script src="./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" defer></script>
|
|
35
|
+
<script type="module">
|
|
36
|
+
import { autoTheme } from './node_modules/@aiursoft/autodark.js/dist/esm/autodark.js'
|
|
37
|
+
autoTheme()
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## How to build locally
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install
|
|
45
|
+
npm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## How to contribute
|
|
49
|
+
|
|
50
|
+
There are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.
|
|
51
|
+
|
|
52
|
+
Even if you with push rights on the repository, you should create a personal fork and create feature branches there when you need them. This keeps the main repository clean and your workflow cruft out of sight.
|
|
53
|
+
|
|
54
|
+
We're also interested in your feedback on the future of this project. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly.
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiursoft/autodark.js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Auto dark theme",
|
|
5
|
-
"main": "dist/cjs/autodark.js",
|
|
6
5
|
"module": "dist/esm/autodark.js",
|
|
7
6
|
"types": "dist/types/autodark.d.ts",
|
|
8
7
|
"scripts": {
|
|
9
8
|
"clean": "rm -rf ./dist",
|
|
10
|
-
"build-css": "
|
|
9
|
+
"build-css": "sass --style=compressed --source-map src/autodark.scss dist/css/autodark.min.css",
|
|
11
10
|
"build-js": "tsc -b ./tsconfig.json ./tsconfig.types.json",
|
|
12
11
|
"build": "npm run build-css && npm run build-js",
|
|
13
12
|
"format": "prettier --write .",
|
|
14
|
-
"lint": "eslint src/ --ext .ts && prettier --check ."
|
|
13
|
+
"lint": "eslint src/ --ext .ts && prettier --check .",
|
|
14
|
+
"check": "npm run lint && npm run build"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://
|
|
18
|
+
"url": "https://github.com/AiursoftWeb/autodark.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"bootstrap": "^4.6.2"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
26
26
|
"@typescript-eslint/parser": "^6.16.0",
|
|
27
27
|
"eslint": "^8.56.0",
|
|
28
|
-
"
|
|
28
|
+
"sass": "^1.105.2",
|
|
29
29
|
"prettier": "^3.1.1",
|
|
30
30
|
"typescript": "^5.3.3"
|
|
31
31
|
},
|