Skip to content

Commit a6c0180

Browse files
committed
💕 FEAT: 一旦オブジェクト指向、classを使ってのプログラム終了
1 parent f0ccc3d commit a6c0180

File tree

9 files changed

+327
-36
lines changed

9 files changed

+327
-36
lines changed

README.md

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
# Commit Easily
44
Commit Easilyはコミットメッセージを簡単に何も考えずに作成できるWebアプリです。
5-
6-
[Version 2.0.0]からforkして、ご自身に合ったprefixを簡単に作成することができます。
5+
[Version 3.0.0]からforkして、ご自身に合ったprefixを簡単に作成することができます。
76

87

98
## 概要
@@ -33,7 +32,8 @@ URL: https://pss-aileen.github.io/project-github-commit-message/
3332
- HTML/CSS
3433
- JavaScript
3534
- Tailwind CSS
36-
35+
- その他
36+
- jsonにprefixを保管し、オブジェクト指向をでプログラムを書きました(Version 3から)
3737

3838
## 制作について
3939
- 制作期間
@@ -42,36 +42,49 @@ URL: https://pss-aileen.github.io/project-github-commit-message/
4242
- 気分が上がるように可愛いアイコンを使ってデザインをまとめました
4343

4444
---
45-
#### [Version 2.0.5] 2024/01/03
46-
- 新機能
47-
- ダークモードに対応
48-
- 修正
49-
- RELEASE、NEWの時、SUBJECTを自動的に出力
50-
51-
#### [Version 2.0.4] 2024/01/01
52-
- 修正
53-
- UPDATEの日付を2411→240101になるよう変更
54-
55-
#### [Version 2.0.3] 2023/12/23
56-
- 修正
57-
- UPDATEの自動日付を20231223から231223になるように変更
58-
59-
#### [Version 2.0.2] 2023/12/22
60-
- 新機能
61-
- prefixでUPDATEを選んだ時、日付が自動でSUBJECTに入るようにした
62-
63-
#### [Version 2.0.1] 2023/12/17
64-
- 新機能
65-
- リセットボタン: 自分のインターネット回線が遅くでリロードして書いた内容を消していると面倒だったので、リセットボタンを作成
66-
- practice-project用のprefixの追加
6745

68-
#### [Version 2.0.0] 2023/12/13
69-
- 新機能
70-
- プロジェクトごとにprefixを切り替えられる機能を追加
71-
- 修正
72-
- prefixが複数選択できる問題を解決(HTMLのSelectからmultipleを削除)
73-
74-
#### [Version 1.0.0] 2023/12/03
46+
## Release
47+
48+
<details>
49+
50+
<summary>show detail</summary>
51+
52+
- **[Version 3.0.0] 2024/02/24**
53+
- 内部構造作り替え
54+
- オブジェクト指向でプログラムを組み直し
55+
- prefixの情報をjsonで管理するように変更
56+
- **[Version 2.0.7] 2024/01/30**
57+
- 修正
58+
- 選択肢にアイコン追加
59+
- PAIZAの選択肢の順番変更
60+
- **[Version 2.0.6]**
61+
- skip
62+
- **[Version 2.0.5] 2024/01/03**
63+
- 新機能
64+
- ダークモードに対応
65+
- 修正
66+
- RELEASE、NEWの時、SUBJECTを自動的に出力
67+
- **[Version 2.0.4] 2024/01/01**
68+
- 修正
69+
- UPDATEの日付を2411→240101になるよう変更
70+
- **[Version 2.0.3] 2023/12/23**
71+
- 修正
72+
- UPDATEの自動日付を20231223から231223になるように変更
73+
- **[Version 2.0.2] 2023/12/22**
74+
- 新機能
75+
- prefixでUPDATEを選んだ時、日付が自動でSUBJECTに入るようにした
76+
- **[Version 2.0.1] 2023/12/17**
77+
- 新機能
78+
- リセットボタン: 自分のインターネット回線が遅くでリロードして書いた内容を消していると面倒だったので、リセットボタンを作成
79+
- practice-project用のprefixの追加
80+
- **[Version 2.0.0] 2023/12/13**
81+
- 新機能
82+
- プロジェクトごとにprefixを切り替えられる機能を追加
83+
- 修正
84+
- prefixが複数選択できる問題を解決(HTMLのSelectからmultipleを削除)
85+
- **[Version 1.0.0] 2023/12/03**
86+
87+
</details>
7588

7689
---
7790

_project/images/image-screen.jpg

51.7 KB
Loading
142 KB
Loading

dist/css/style.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,13 @@ input[type="number"]::-webkit-inner-spin-button {
677677
transition-duration: 150ms;
678678
}
679679

680+
.body.darkmode {
681+
--tw-bg-opacity: 1;
682+
background-color: rgb(15 23 42 / var(--tw-bg-opacity));
683+
--tw-text-opacity: 1;
684+
color: rgb(209 213 219 / var(--tw-text-opacity));
685+
}
686+
680687
.btn-mode {
681688
position: fixed;
682689
bottom: 0.75rem;
@@ -756,6 +763,13 @@ input[type="number"]::-webkit-inner-spin-button {
756763
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
757764
}
758765

766+
.btn-reset.darkmode {
767+
--tw-border-opacity: 1;
768+
border-color: rgb(71 85 105 / var(--tw-border-opacity));
769+
--tw-bg-opacity: 1;
770+
background-color: rgb(30 41 59 / var(--tw-bg-opacity));
771+
}
772+
759773
.form-wrapper {
760774
margin-top: 2rem;
761775

@@ -856,6 +870,20 @@ input[type="number"]::-webkit-inner-spin-button {
856870
padding-bottom: 0.25rem;
857871
}
858872

873+
input.darkmode,
874+
select.darkmode,
875+
.input-textarea.darkmode {
876+
--tw-border-opacity: 1;
877+
border-color: rgb(71 85 105 / var(--tw-border-opacity));
878+
}
879+
880+
input.darkmode,
881+
select.darkmode,
882+
.input-textarea.darkmode {
883+
--tw-bg-opacity: 1;
884+
background-color: rgb(30 41 59 / var(--tw-bg-opacity));
885+
}
886+
859887
.output-textarea {
860888
margin-top: 0.5rem;
861889
}
@@ -899,6 +927,16 @@ input[type="number"]::-webkit-inner-spin-button {
899927
padding-bottom: 0.25rem;
900928
}
901929

930+
.output-textarea.darkmode {
931+
--tw-border-opacity: 1;
932+
border-color: rgb(71 85 105 / var(--tw-border-opacity));
933+
}
934+
935+
.output-textarea.darkmode {
936+
--tw-bg-opacity: 1;
937+
background-color: rgb(51 65 85 / var(--tw-bg-opacity));
938+
}
939+
902940
.description {
903941
margin-top: 0.5rem;
904942
}

dist/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Commit Easily</title>
8-
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
98
<link rel="stylesheet" href="css/style.css" />
109
</head>
1110

12-
<body class="body">
11+
<body class="body" id="body">
1312

1413
<div class="btn-mode" id="btn-mode">
1514
🌞

dist/js/main.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
'use strict';
22
{
33

4+
/*
5+
TYPEとPREFIXを追加したい場合はdata/data.jsonを追加すること
6+
*/
7+
48
class JsonData {
59
constructor(url) {
610
this.url = url;
@@ -229,6 +233,107 @@
229233
}
230234
}
231235

236+
237+
238+
class DarkMode {
239+
constructor() {
240+
241+
}
242+
243+
getDOMElements() {
244+
const body = document.getElementById("body");
245+
const resetBtn = document.getElementById("btn-reset");
246+
const input = document.querySelectorAll("input");
247+
const select = document.querySelectorAll("select");
248+
const comment = document.getElementById("comment");
249+
const generatedMessage = document.getElementById("message-output");
250+
const modeBtn = document.getElementById("btn-mode");
251+
const elements = [body, resetBtn, input, select, comment, generatedMessage];
252+
return { elements, modeBtn };
253+
}
254+
255+
getLocalStorage() {
256+
const monitorMode = JSON.parse(localStorage.getItem("displayMode"));
257+
return monitorMode;
258+
}
259+
260+
setLocalStorageLightMode() {
261+
localStorage.setItem("displayMode", JSON.stringify("lightmode"));
262+
}
263+
264+
setLocalStorageDarkMode() {
265+
localStorage.setItem("displayMode", JSON.stringify("darkmode"));
266+
}
267+
268+
judgeInitMode() {
269+
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
270+
const monitorMode = this.getLocalStorage();
271+
272+
if (darkModeMediaQuery.matches) {
273+
console.log("judge: system dark");
274+
this.switchToDarkMode();
275+
} else if (!darkModeMediaQuery.matches) {
276+
console.log("judge: system light");
277+
this.switchToLightMode();
278+
} else if (monitorMode === "darkmode") {
279+
console.log("localStorage DARK");
280+
this.switchToDarkMode();
281+
} else {
282+
console.log("localStorage LIGHT");
283+
this.switchToLightMode();
284+
}
285+
}
286+
287+
judgeEvent() {
288+
const { modeBtn } = this.getDOMElements();
289+
if (modeBtn.textContent === "🌞") {
290+
this.switchToDarkMode();
291+
} else {
292+
this.switchToLightMode();
293+
}
294+
295+
}
296+
297+
switchToDarkMode() {
298+
const {elements, modeBtn} = this.getDOMElements();
299+
this.setLocalStorageDarkMode();
300+
301+
modeBtn.textContent = "🌛";
302+
303+
for (let i = 0; i < elements.length; i++) {
304+
if (elements[i].length > 0) {
305+
for (const element of elements[i]) {
306+
element.classList.add("darkmode");
307+
}
308+
} else {
309+
elements[i].classList.add("darkmode");
310+
}
311+
}
312+
}
313+
314+
switchToLightMode() {
315+
const {elements, modeBtn} = this.getDOMElements();
316+
this.setLocalStorageLightMode();
317+
318+
modeBtn.textContent = "🌞";
319+
320+
for (let i = 0; i < elements.length; i++) {
321+
if (elements[i].length > 0) {
322+
for (const element of elements[i]) {
323+
element.classList.remove("darkmode");
324+
}
325+
} else {
326+
elements[i].classList.remove("darkmode");
327+
}
328+
}
329+
}
330+
}
331+
332+
333+
/*************************************************
334+
*************************************************/
335+
336+
232337
const url = "./data/data.json";
233338
const jsonData = new JsonData(url);
234339

@@ -239,6 +344,8 @@
239344
createDom.createPrefix();
240345
const setSpecificSubject = new SetSpecificSubject(prefixDom.value);
241346
setSpecificSubject.checkType();
347+
const darkmode = new DarkMode();
348+
darkmode.judgeInitMode();
242349
}
243350

244351
initialize();
@@ -287,6 +394,11 @@
287394
copy.setClipboard();
288395
});
289396

397+
const modeBtn = document.getElementById("btn-mode");
290398

399+
modeBtn.addEventListener("click", () => {
400+
const darkmode = new DarkMode();
401+
darkmode.judgeEvent();
402+
});
291403

292404
} // end

src/css/style.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ input[type="number"]::-webkit-inner-spin-button {
1313
@apply font-mono text-gray-700 transition;
1414
}
1515

16+
.body.darkmode {
17+
@apply text-gray-300 bg-slate-900;
18+
}
19+
1620
.btn-mode {
1721
@apply fixed bottom-3 right-3 text-3xl cursor-pointer hover:opacity-70 active:translate-y-0.5 select-none transition;
1822
}
@@ -33,6 +37,10 @@ input[type="number"]::-webkit-inner-spin-button {
3337
@apply block w-1/4 rounded-md border-2 border-solid border-gray-300 bg-gray-100 px-1 py-1 text-lg tracking-widest transition hover:opacity-70 active:translate-y-0.5 select-none;
3438
}
3539

40+
.btn-reset.darkmode {
41+
@apply bg-slate-800 border-slate-600;
42+
}
43+
3644
.form-wrapper {
3745
@apply mt-8;
3846

@@ -53,10 +61,20 @@ input[type="number"]::-webkit-inner-spin-button {
5361
@apply mt-2 block w-full resize-none rounded-md border-2 border-solid px-2 py-1;
5462
}
5563

64+
input.darkmode,
65+
select.darkmode,
66+
.input-textarea.darkmode {
67+
@apply border-slate-600 bg-slate-800;
68+
}
69+
5670
.output-textarea {
5771
@apply mt-2 block w-full resize-none rounded-md border-2 border-solid bg-gray-100 px-2 py-1;
5872
}
5973

74+
.output-textarea.darkmode {
75+
@apply border-slate-600 bg-slate-700;
76+
}
77+
6078
.description {
6179
@apply mt-2 text-sm opacity-60;
6280
}

src/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Commit Easily</title>
8-
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
98
<link rel="stylesheet" href="css/style.css" />
109
</head>
1110

12-
<body class="body">
11+
<body class="body" id="body">
1312

1413
<div class="btn-mode" id="btn-mode">
1514
🌞

0 commit comments

Comments
 (0)