daily-color 1.1.0 → 1.2.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/CHANGELOG.md +7 -0
- package/README.md +10 -1
- package/index.html +59 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.2.0](https://github.com/aimeerivers/daily-color/compare/v1.1.0...v1.2.0) (2024-11-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* 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))
|
|
9
|
+
|
|
3
10
|
## [1.1.0](https://github.com/aimeerivers/daily-color/compare/v1.0.1...v1.1.0) (2024-11-09)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npm install daily-color
|
|
|
10
10
|
|
|
11
11
|
## Use
|
|
12
12
|
|
|
13
|
-
In a JavaScript/TypeScript project:
|
|
13
|
+
In a JavaScript/TypeScript project, using NPM:
|
|
14
14
|
|
|
15
15
|
```javascript
|
|
16
16
|
const getDailyColor = require("daily-color");
|
|
@@ -18,6 +18,15 @@ const getDailyColor = require("daily-color");
|
|
|
18
18
|
console.log("Today's color is:", getDailyColor());
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
Directly loading the bundled JavaScript, for static projects not using NPM:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script src="https://www.aimeerivers.com/daily-color/dist/daily-color.js"></script>
|
|
25
|
+
<script>
|
|
26
|
+
console.log("Today's color is:", getDailyColor());
|
|
27
|
+
</script>
|
|
28
|
+
```
|
|
29
|
+
|
|
21
30
|
Using the CLI:
|
|
22
31
|
|
|
23
32
|
```bash
|
package/index.html
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
border-radius: 0.2em;
|
|
19
|
+
color: #fff;
|
|
20
|
+
font-size: 4em;
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
padding: 0.5em;
|
|
23
|
+
text-align: center;
|
|
24
|
+
}
|
|
25
|
+
#color.light {
|
|
26
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
27
|
+
box-shadow: 0 0 1em rgba(0, 0, 0, 0.3);
|
|
28
|
+
}
|
|
29
|
+
#color.dark {
|
|
30
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
31
|
+
box-shadow: 0 0 1em rgba(255, 255, 255, 0.3);
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
34
|
+
</head>
|
|
35
|
+
|
|
36
|
+
<body>
|
|
37
|
+
<div id="color"></div>
|
|
38
|
+
<script src="https://www.aimeerivers.com/daily-color/dist/daily-color.js"></script>
|
|
39
|
+
<script>
|
|
40
|
+
const color = getDailyColor();
|
|
41
|
+
const colorDiv = document.getElementById("color");
|
|
42
|
+
document.body.style.backgroundColor = color;
|
|
43
|
+
colorDiv.innerText = color;
|
|
44
|
+
colorDiv.style.color = color;
|
|
45
|
+
|
|
46
|
+
const brightness = getBrightness(color.substring(1));
|
|
47
|
+
if (brightness < 128) {
|
|
48
|
+
colorDiv.classList.add("dark");
|
|
49
|
+
} else {
|
|
50
|
+
colorDiv.classList.add("light");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getBrightness(color) {
|
|
54
|
+
const rgb = color.match(/\w\w/g).map((hex) => parseInt(hex, 16));
|
|
55
|
+
return 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]; // Luminosity formula
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
</body>
|
|
59
|
+
</html>
|