daily-color 2.0.0 → 2.1.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/README.md CHANGED
@@ -18,6 +18,7 @@ In a JavaScript/TypeScript project, using NPM:
18
18
  import { getDailyColor } from "daily-color";
19
19
 
20
20
  console.log("Today's color is:", getDailyColor());
21
+ console.log("Another day's color is:", getDailyColor(new Date("2024-11-09")));
21
22
  ```
22
23
 
23
24
  Directly loading the bundled JavaScript, for static projects not using NPM:
@@ -27,6 +28,7 @@ Directly loading the bundled JavaScript, for static projects not using NPM:
27
28
  import { getDailyColor } from "https://www.aimeerivers.com/daily-color/dist/daily-color.js";
28
29
 
29
30
  console.log("Today's color is:", getDailyColor());
31
+ console.log("Another day's color is:", getDailyColor(new Date("2024-11-09")));
30
32
  </script>
31
33
  ```
32
34
 
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export function getDailyColor(): string;
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
- export function getDailyColor() {
2
- const date = new Date();
1
+ export function getDailyColor(date = new Date()) {
3
2
  const hash = getSimpleHash(date);
4
3
 
5
4
  const r = (hash >> 16) & 0xff; // Red
@@ -14,7 +13,7 @@ function getSimpleHash(date) {
14
13
  const month = date.getMonth() + 1; // getMonth() is zero-based
15
14
  const year = date.getFullYear();
16
15
 
17
- const dateString = `${year}-${month}-${day}`;
16
+ const dateString = `${day}${day * year * month}${year}${month}${day}${year}${month}${day}`;
18
17
  let hash = 0;
19
18
 
20
19
  // Simple hash function: Iterate over each character in the date string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daily-color",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Provides a unique hex code each day",
5
5
  "keywords": [
6
6
  "color",
@@ -15,6 +15,10 @@
15
15
  },
16
16
  "license": "ISC",
17
17
  "author": "aimee rivers",
18
+ "files": [
19
+ "index.d.ts",
20
+ "index.js"
21
+ ],
18
22
  "main": "index.js",
19
23
  "bin": {
20
24
  "dailycolor": "./bin/dailycolor.js"
package/.eslintrc.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "eslint-config-plus-prettier"
3
- }
@@ -1,29 +0,0 @@
1
- name: Code quality
2
-
3
- on:
4
- pull_request:
5
- branches: [main]
6
-
7
- jobs:
8
- code-quality:
9
- runs-on: ubuntu-latest
10
-
11
- steps:
12
- - uses: actions/checkout@v4
13
-
14
- - name: Use Node.js
15
- uses: actions/setup-node@v3
16
- with:
17
- node-version: node
18
-
19
- - name: Install dependencies
20
- run: npm install
21
-
22
- - name: Check package linting
23
- run: npm run package:lint
24
-
25
- - name: Check code linting
26
- run: npm run lint:check
27
-
28
- - name: Check formatting
29
- run: npm run format:check
@@ -1,26 +0,0 @@
1
- name: Publish please
2
-
3
- on:
4
- release:
5
- types: [created]
6
-
7
- jobs:
8
- build-and-publish:
9
- runs-on: ubuntu-latest
10
- steps:
11
- - name: Check out code
12
- uses: actions/checkout@v4
13
-
14
- - name: Set up Node.js
15
- uses: actions/setup-node@v3
16
- with:
17
- node-version: node
18
- registry-url: https://registry.npmjs.org
19
-
20
- - name: Install dependencies
21
- run: npm install
22
-
23
- - name: Publish to npm
24
- run: npm publish
25
- env:
26
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,21 +0,0 @@
1
- name: Release please
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- workflow_dispatch:
8
-
9
- permissions:
10
- contents: write
11
- pull-requests: write
12
-
13
- jobs:
14
- release-please:
15
- runs-on: ubuntu-latest
16
- steps:
17
- - uses: googleapis/release-please-action@v3
18
- with:
19
- token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
20
- release-type: node
21
- changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"deps","section":"Dependencies","hidden":false}]'
@@ -1,45 +0,0 @@
1
- name: Update please
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- target:
7
- type: choice
8
- description: Target versions to upgrade to
9
- required: true
10
- options:
11
- - latest
12
- - minor
13
- - patch
14
- schedule:
15
- - cron: "0 0 10 * *"
16
-
17
- jobs:
18
- update-please:
19
- runs-on: ubuntu-latest
20
-
21
- steps:
22
- - name: Checkout Repository
23
- uses: actions/checkout@v4
24
-
25
- - name: Setup Node.js Environment
26
- uses: actions/setup-node@v4
27
-
28
- - name: Install npm-check-updates
29
- run: npm install -g npm-check-updates
30
-
31
- - name: Update ${{ github.event.inputs.target || 'minor' }} dependencies
32
- run: ncu -t ${{ github.event.inputs.target || 'minor' }} -u --install always
33
-
34
- - name: Audit dependencies
35
- run: npm audit fix ${{ github.event.inputs.target == 'latest' && '--force' || ''}}
36
-
37
- - name: Create Pull Request
38
- uses: peter-evans/create-pull-request@v6
39
- with:
40
- token: ${{ secrets.UPDATE_PLEASE_TOKEN }}
41
- commit-message: "deps: update dependencies"
42
- title: "deps: update dependencies"
43
- body: "Update Please has found one or more dependencies to be updated! 🚀"
44
- branch: update-please-${{ github.sha }}
45
- labels: chore
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "eslint-config-plus-prettier/.npmpackagejsonlintrc.json"
3
- }
package/.prettierignore DELETED
@@ -1,3 +0,0 @@
1
- dist
2
- package-lock.json
3
- CHANGELOG.md
package/CHANGELOG.md DELETED
@@ -1,65 +0,0 @@
1
- # Changelog
2
-
3
- ## [2.0.0](https://github.com/aimeerivers/daily-color/compare/v1.3.1...v2.0.0) (2024-11-09)
4
-
5
-
6
- ### ⚠ BREAKING CHANGES
7
-
8
- * Importing with `require` will no longer work. Instead use `import { getDailyColor } from "daily-color";`
9
-
10
- ### Features
11
-
12
- * Convert to ES module ([#15](https://github.com/aimeerivers/daily-color/issues/15)) ([0444973](https://github.com/aimeerivers/daily-color/commit/04449739647216ddda101b5fdd4b3c7be2e0a662))
13
-
14
- ## [1.3.1](https://github.com/aimeerivers/daily-color/compare/v1.3.0...v1.3.1) (2024-11-09)
15
-
16
-
17
- ### Bug Fixes
18
-
19
- * Make the text stand out slightly better on the demo page ([#13](https://github.com/aimeerivers/daily-color/issues/13)) ([f1a61bc](https://github.com/aimeerivers/daily-color/commit/f1a61bcadb0cab38d89a152b2886226e7c8e53cd))
20
-
21
- ## [1.3.0](https://github.com/aimeerivers/daily-color/compare/v1.2.0...v1.3.0) (2024-11-09)
22
-
23
-
24
- ### Features
25
-
26
- * Improve the demo display ([#10](https://github.com/aimeerivers/daily-color/issues/10)) ([ff95cd2](https://github.com/aimeerivers/daily-color/commit/ff95cd2b0afeca1d81f574b687e29d9015eb7c54))
27
-
28
- ## [1.2.0](https://github.com/aimeerivers/daily-color/compare/v1.1.0...v1.2.0) (2024-11-09)
29
-
30
-
31
- ### Features
32
-
33
- * Add an HTML page to show the current color of the day ([#8](https://github.com/aimeerivers/daily-color/issues/8)) ([e702363](https://github.com/aimeerivers/daily-color/commit/e702363cbb73e358742c2cb59874b9a2b55baa52))
34
-
35
- ## [1.1.0](https://github.com/aimeerivers/daily-color/compare/v1.0.1...v1.1.0) (2024-11-09)
36
-
37
-
38
- ### Features
39
-
40
- * Provide a webpack bundle, for projects that don't use NPM ([#6](https://github.com/aimeerivers/daily-color/issues/6)) ([6d53597](https://github.com/aimeerivers/daily-color/commit/6d535973e9f8f601bf4e908911665eb9fda5ee67))
41
-
42
- ## [1.0.1](https://github.com/aimeerivers/daily-color/compare/v1.0.0...v1.0.1) (2024-11-09)
43
-
44
-
45
- ### Dependencies
46
-
47
- * update dependencies ([#3](https://github.com/aimeerivers/daily-color/issues/3)) ([3fbbb9a](https://github.com/aimeerivers/daily-color/commit/3fbbb9a3428a046d34c7f9671d4a891dbd06972e))
48
-
49
- ## 1.0.0 (2024-11-09)
50
-
51
-
52
- ### Features
53
-
54
- * Add a bin script for CLI ([f81da29](https://github.com/aimeerivers/daily-color/commit/f81da29a370963f941b161992a79040b045d6b9a))
55
- * Start a new project ([a9f5689](https://github.com/aimeerivers/daily-color/commit/a9f56899a72d35c4168131bc9dfb2172f0238f97))
56
-
57
-
58
- ### Dependencies
59
-
60
- * Fix version ([0a1af33](https://github.com/aimeerivers/daily-color/commit/0a1af33525693ae8d5f7f5f186abb7a946ce70d8))
61
- * Install eslint-config-plus-prettier ([36e2f49](https://github.com/aimeerivers/daily-color/commit/36e2f49af188015a4736541e0412cb9580063c4c))
62
- * Install npm-package-json-lint ([6281541](https://github.com/aimeerivers/daily-color/commit/6281541c637d7b546dfc2a479ba76eb800ddb5ab))
63
- * Uninstall npm-package-json-lint ([9a330b1](https://github.com/aimeerivers/daily-color/commit/9a330b11f131d287cb51b8ac430393c49b94c1cb))
64
- * Update eslint-config-plus-prettier ([e08d8d4](https://github.com/aimeerivers/daily-color/commit/e08d8d47e47b55c04b4cb3f9411cadb924191761))
65
- * Update eslint-config-plus-prettier to v1.6.0 which limits the eslint version ([fd17ce9](https://github.com/aimeerivers/daily-color/commit/fd17ce9be58db5bdb726f1f363e1bae2cf2bc99f))
@@ -1 +0,0 @@
1
- var t={d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function r(){const t=function(t){const e=t.getDate(),r=t.getMonth()+1,o=`${t.getFullYear()}-${r}-${e}`;let a=0;for(let t=0;t<o.length;t++)a=(a<<5)-a+o.charCodeAt(t),a|=0;return Math.abs(a)}(new Date),e=t>>8&255,r=255&t;return`#${(t>>16&255).toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}t.d(e,{x:()=>r});var o=e.x;export{o as getDailyColor};
package/index.html DELETED
@@ -1,55 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Daily Color</title>
7
- <style>
8
- body,
9
- html {
10
- align-items: center;
11
- display: flex;
12
- font-family: sans-serif;
13
- height: 100%;
14
- justify-content: center;
15
- margin: 0;
16
- }
17
- #color {
18
- font-size: 4em;
19
- font-weight: bold;
20
- text-align: center;
21
- }
22
- #color.light {
23
- text-shadow: 0 0 0.4em rgba(0, 0, 0, 0.5);
24
- }
25
- #color.dark {
26
- text-shadow: 0 0 0.4em rgba(255, 255, 255, 0.5);
27
- }
28
- </style>
29
- </head>
30
-
31
- <body>
32
- <div id="color"></div>
33
- <script type="module">
34
- import { getDailyColor } from "https://www.aimeerivers.com/daily-color/dist/daily-color.js";
35
-
36
- const color = getDailyColor();
37
- const colorDiv = document.getElementById("color");
38
- document.body.style.backgroundColor = color;
39
- colorDiv.innerText = color;
40
- colorDiv.style.color = color;
41
-
42
- const brightness = getBrightness(color.substring(1));
43
- if (brightness < 128) {
44
- colorDiv.classList.add("dark");
45
- } else {
46
- colorDiv.classList.add("light");
47
- }
48
-
49
- function getBrightness(color) {
50
- const rgb = color.match(/\w\w/g).map((hex) => parseInt(hex, 16));
51
- return 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]; // Luminosity formula
52
- }
53
- </script>
54
- </body>
55
- </html>
package/test/index.js DELETED
@@ -1,3 +0,0 @@
1
- const getDailyColor = require("../index");
2
-
3
- console.log("Today's color is:", getDailyColor());
package/webpack.config.js DELETED
@@ -1,20 +0,0 @@
1
- import path from "path";
2
- import { fileURLToPath } from "url";
3
-
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = path.dirname(__filename);
6
-
7
- export default {
8
- entry: "./index.js",
9
- output: {
10
- path: path.resolve(__dirname, "dist"),
11
- filename: "daily-color.js",
12
- library: {
13
- type: "module",
14
- },
15
- },
16
- experiments: {
17
- outputModule: true,
18
- },
19
- mode: "production",
20
- };