Skip to content

Commit

Permalink
๐Ÿ”€ Merge pull request #66 from alittlekitten/design-v1.6.1
Browse files Browse the repository at this point in the history
Feature/v1.6.1 D-Day ํƒญ ์ค‘์‹ฌ ๋กœ์ง ๋ฐ ๋””์ž์ธ ํŒจ์น˜ (๊ธฐํƒ€ ๋””์ž์ธ ํŒจ์น˜ ํฌํ•จ)
  • Loading branch information
alittlekitten authored Jun 4, 2022
2 parents 7d69e96 + fe4712b commit 3d28a4c
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 56 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

**๐Ÿ‘‰ ๋ฐฐํฌ ํŽ˜์ด์ง€ : https://alittlekitten.github.io/SsocoTimer/**

**์ตœ์‹  ์—…๋ฐ์ดํŠธ ๋‚ ์งœ : `2022.04.29`**
**์ตœ์‹  ์—…๋ฐ์ดํŠธ ๋‚ ์งœ : `2022.06.05`**

**์ตœ์‹  ๋ฆด๋ฆฌ์ฆˆ ๋ฒ„์ „ : `ver 1.6.0`**
**์ตœ์‹  ๋ฆด๋ฆฌ์ฆˆ ๋ฒ„์ „ : `ver 1.6.1`**

![Honeycam 2022-04-29 04-29-39](https://user-images.githubusercontent.com/14370441/165831202-631f382a-96a9-40f1-aaab-65316f97f678.gif)
![Honeycam 2022-06-05 01-07-53](https://user-images.githubusercontent.com/14370441/172014867-12fedd62-705a-4e09-865a-c5586d77bbd6.gif)

- `React`์™€ `CRA`๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐ„๋‹จํ•œ ์Šคํ†ฑ์›Œ์น˜์™€ ํƒ€์ด๋จธ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋งŒ๋“ค์–ด๋ณด๋Š” ์—ฐ์Šต์šฉ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์ž…๋‹ˆ๋‹ค.
- React์˜ ๊ธฐ๋ณธ์ ์ธ ๋™์ž‘ ๋ฐฉ์‹์„ ์ตํžˆ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
Expand Down Expand Up @@ -199,6 +199,14 @@
- [x] svg ์‚ฌ์ง„์— ์„ค๋ช…(alt) ์ถ”๊ฐ€ - svg ํŒŒ์ผ์— alt์†์„ฑ์„ ์ง์ ‘ ์ค„ ์ˆ˜ ์—†์–ด ์šฐํšŒ์ ์œผ๋กœ title ์ ์šฉ
- [x] ํƒญ์— ๋“ค์–ด๊ฐ€๋Š” ์ด๋ฆ„์— ๋„์–ด์“ฐ๊ธฐ ์ถ”๊ฐ€

### `22.06.05` - `v1.6.1`

- [x] ํ™”๋ฉด์ด ์ž‘์€ ๊ฒฝ์šฐ ์Šคํฌ๋กค์ด ์ƒ๊ธฐ๋Š” ๋ถ€๋ถ„ ์ œ๊ฑฐ
- [x] ํ•ด๋‹น ์›”์— ์—†๋Š” ๋‚ ์งœ๊ฐ€ ํ™”๋ฉด์— ๋‚จ์•„์žˆ๋Š” ํ˜„์ƒ ์ œ๊ฑฐ
- [x] useDday ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ๋ณ„๋„๋กœ ๋ถ„๋ฆฌ
- [x] ๋‹คํฌ๋ชจ๋“œ์ผ ๋•Œ nav๋ฐ”์— ํฐ์ƒ‰ ๊ทธ๋ฆผ์ž ์ถ”๊ฐ€
- [x] D-day๋ถ€๋ถ„ ๊ฒฐ๊ณผ ๋ฉ”์‹œ์ง€์ฐฝ ์ปฌ๋Ÿฌ ํ•˜์ด๋ผ์ดํŒ…์œผ๋กœ ๊ฐ€๋…์„ฑ ํ–ฅ์ƒ

<br />

## ๐Ÿ— ๊ณ ๋ฏผํ•œ ์ 
Expand Down Expand Up @@ -303,7 +311,7 @@
- ์ด ๊ณผ์ •์„ ํ†ตํ•ด ์ปดํฌ๋„ŒํŠธ๋Š” ์ถœ๋ ฅ ๋ถ€๋ถ„, ์ปค์Šคํ…€ ํ›…์€ ๋กœ์ง ๋ถ€๋ถ„์„ ๋‹ด๋‹นํ•˜๋Š” ๊ด€์‹ฌ์‚ฌ ๋ถ„๋ฆฌ๊ฐ€ ๋ณด๋‹ค ๋ช…ํ™•ํ•˜๊ฒŒ ์ด๋ฃจ์–ด์งˆ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
- ๋˜ํ•œ ์žฌ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•œ Time Management์™€ ๊ด€๋ จ๋œ ๋ถ€๋ถ„์„ ๋ณ„๋„๋กœ ์ปค์Šคํ…€ ํ›…์œผ๋กœ ๋ฝ‘์•„๋‚ด์„œ hooks ํด๋”์˜ utils ํด๋” ์•ˆ์— ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค. (์ปค์Šคํ…€ ํ›… 2๋‹จ ๋ถ„๋ฆฌ)
- ๊ทธ๋ ‡๊ฒŒ ๋นผ๋‚ธ useTimeManage ์ปค์Šคํ…€ ํ›…์€ ๊ฐ๊ฐ์˜ ์ปดํฌ๋„ŒํŠธ ๋‹ด๋‹น ์ปค์Šคํ…€ ํ›…์—์„œ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
- ํ˜„์žฌ๊นŒ์ง€ ๊ฐ€์žฅ ํฐ 3๊ฐœ์˜ ๊ธฐ๋Šฅ๋‹จ์œ„์ธ Timer, Stopwatch, Clock์— ๋Œ€ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง ๋ถ„๋ฆฌ๋ฅผ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค.
- ํ˜„์žฌ๊นŒ์ง€ ๊ฐ€์žฅ ํฐ 4๊ฐœ์˜ ๊ธฐ๋Šฅ๋‹จ์œ„์ธ Timer, Stopwatch, Clock, Dday์— ๋Œ€ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง ๋ถ„๋ฆฌ๋ฅผ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค.
- ๋‹ค๋งŒ ๊ฐ๊ฐ์˜ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง ๋‹จ์œ„๋„ ๋‹ค์†Œ ํฐ ๋ถ€๋ถ„์ด ์žˆ์–ด์„œ ์กฐ๊ธˆ ๋” ์„ธ์„ธํ•˜๊ฒŒ ๋‚˜๋ˆŒ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.
- ์ถ”๊ฐ€๋กœ ์ „์—ญ store์—์„œ useSelector๋กœ ๊ฐ€์ ธ์˜ค๋Š” ์ƒํƒœ๋ฅผ ๋ž˜ํ•‘ํ•˜๋Š” ์ปค์Šคํ…€ ํ›…์„ ์ƒ์„ฑํ•ด์„œ ์‚ฌ์šฉํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

Expand Down Expand Up @@ -376,6 +384,10 @@

## ๐ŸŽž ์›€์งค

### ver 1.6.1

![Honeycam 2022-06-05 01-07-53](https://user-images.githubusercontent.com/14370441/172014867-12fedd62-705a-4e09-865a-c5586d77bbd6.gif)

### ver 1.6.0

![Honeycam 2022-04-29 04-29-39](https://user-images.githubusercontent.com/14370441/165831202-631f382a-96a9-40f1-aaab-65316f97f678.gif)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ssocotimer",
"version": "1.6.0",
"version": "1.6.1",
"private": true,
"dependencies": {
"@babel/preset-react": "^7.16.7",
Expand Down
76 changes: 29 additions & 47 deletions src/components/Dday.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,20 @@
import { css, useTheme } from "@emotion/react";
import React, { useEffect, useState } from "react";
import useDday from "@hooks/useDday";
import { ThemeVariables } from "@styles/palette";
import { Helmet } from "react-helmet-async";

const Dday = () => {
const nowTime = new Date();
const [year, setYear] = useState<number>(nowTime.getFullYear());
const [month, setMonth] = useState<number>(nowTime.getMonth() + 1);
const [day, setDay] = useState<number>(nowTime.getDate());
const [msg, setMsg] = useState<string>("");
const {
year,
month,
day,
ddayCal,
yearOnChange,
monthOnChange,
dayOnChange,
} = useDday();
const theme = useTheme() as ThemeVariables;

const yearOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const nowYear = new Date().getFullYear();
const originalValue = e.target.value;
const onlyNumber = originalValue.replace(/[^0-9]/g, "");
if (!onlyNumber) setYear(0);
else if (+onlyNumber > 2099) setYear(nowYear);
else setYear(+onlyNumber);
};

const monthOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const originalValue = e.target.value;
const onlyNumber = originalValue.replace(/[^0-9]/g, "");
if (!onlyNumber) setMonth(0);
else if (+onlyNumber > 12) return;
else setMonth(+onlyNumber);
};

const dayOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const maxDay = new Date(year, month, 0).getDate();
const originalValue = e.target.value;
const onlyNumber = originalValue.replace(/[^0-9]/g, "");
if (!onlyNumber) setDay(0);
else if (+onlyNumber > maxDay) return;
else setDay(+onlyNumber);
};

useEffect(() => {
const today = new Date();
const dday = new Date(year, month - 1, day);
const calGetTime = today.getTime() - dday.getTime();
const result = Math.floor(calGetTime / (1000 * 60 * 60 * 24));
if (year < 1970 || year > 2099 || month === 0 || day === 0) {
setMsg("์œ ํšจํ•˜์ง€ ์•Š์€ ๋‚ ์งœ์ž…๋‹ˆ๋‹ค!");
} else {
if (result === 0) setMsg(`์˜ค๋Š˜์ด ๋ฐ”๋กœ D-Day!`);
else if (result > 0) setMsg(`์˜ค๋Š˜๋กœ๋ถ€ํ„ฐ ${result}์ผ ์ง€๋‚ฌ์Šต๋‹ˆ๋‹ค!!`);
else setMsg(`์•ž์œผ๋กœ ${Math.abs(result)}์ผ ๋‚จ์•˜์Šต๋‹ˆ๋‹ค!!!`);
}
}, [year, month, day]);

return (
<>
<Helmet>
Expand Down Expand Up @@ -82,7 +46,21 @@ const Dday = () => {
</p>
</div>
<div css={resultContainer(theme)}>
<p>{msg}</p>
{ddayCal === null ? (
<p>์œ ํšจํ•˜์ง€ ์•Š์€ ๋‚ ์งœ์ž…๋‹ˆ๋‹ค!</p>
) : ddayCal === 0 ? (
<p>
์˜ค๋Š˜์ด ๋ฐ”๋กœ <span>D-day</span>!!
</p>
) : ddayCal > 0 ? (
<p>
์˜ค๋Š˜๋กœ๋ถ€ํ„ฐ <span>{ddayCal}</span>์ผ ์ง€๋‚ฌ์Šต๋‹ˆ๋‹ค!!
</p>
) : (
<p>
์•ž์œผ๋กœ <span>{Math.abs(ddayCal)}</span>์ผ ๋‚จ์•˜์Šต๋‹ˆ๋‹ค!!
</p>
)}
</div>
</>
);
Expand Down Expand Up @@ -135,6 +113,10 @@ const resultContainer = (theme: ThemeVariables) => css`
line-height: 50px;
vertical-align: middle;
color: ${theme.text1};
span {
color: ${theme.highlightText};
}
}
`;

Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Header = () => {
return (
<div>
<div css={main(theme)}>
<span className="version">Ssoco Timer v1.6.0 </span>
<span className="version">Ssoco Timer v1.6.1 </span>

<div className="icons">
<span className="copyright">
Expand Down
13 changes: 10 additions & 3 deletions src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ const Nav = () => {
const { tap } = useSelector((state: RootState) => state.tapReducer);
const dispatch = useDispatch(); // store์˜ reducer๋ฅผ ๋ถ€๋ฆ„ -> reducer๋ฅผ ํ†ตํ•ด ์ƒˆ๋กœ์šด action์„ ๋„˜๊ฒจ์คŒ์œผ๋กœ์จ state๋ฅผ ๋ณ€๊ฒฝํ•จ
const theme = useTheme() as ThemeVariables;
const { themeStatus } = useSelector(
(state: RootState) => state.optionReducer
);

const onClickTimer = () => dispatch({ type: "Timer" });
const onClickStopwatch = () => dispatch({ type: "Stopwatch" });
const onClickClock = () => dispatch({ type: "Clock" });
const onClickDday = () => dispatch({ type: "Dday" });

return (
<div css={Buttons({ tap, theme })}>
<div css={Buttons({ tap, theme, themeStatus })}>
<Link to="/">
<button className="timer" onClick={onClickTimer}>
ํƒ€์ด๋จธ
Expand Down Expand Up @@ -43,6 +46,7 @@ const Nav = () => {
interface ButtonsProps {
tap: String;
theme: ThemeVariables;
themeStatus: String;
}

const Buttons = (props: ButtonsProps) => css`
Expand All @@ -64,8 +68,11 @@ const Buttons = (props: ButtonsProps) => css`
border: none;
border-radius: 4px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
box-shadow: ${props.themeStatus === "light"
? `0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);`
: `0 4px 6px -1px rgba(255, 255, 255, 0.5),
0 2px 4px -1px rgba(255, 255, 255, 0.3);`};
cursor: pointer;
Expand Down
61 changes: 61 additions & 0 deletions src/hooks/useDday.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, { useState, useEffect } from "react";

const useDday = () => {
const nowTime = new Date();
const [year, setYear] = useState<number>(nowTime.getFullYear());
const [month, setMonth] = useState<number>(nowTime.getMonth() + 1);
const [day, setDay] = useState<number>(nowTime.getDate());
const [ddayCal, setDdayCal] = useState<number | null>(0);

const yearOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const nowYear = new Date().getFullYear();
const originalValue = e.target.value;
const onlyNumber = originalValue.replace(/[^0-9]/g, "");
if (!onlyNumber) setYear(0);
else if (+onlyNumber > 2099) setYear(nowYear);
else setYear(+onlyNumber);
};

const monthOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const originalValue = e.target.value;
const onlyNumber = originalValue.replace(/[^0-9]/g, "");
if (!onlyNumber) setMonth(0);
else if (+onlyNumber > 12) return;
else setMonth(+onlyNumber);
};

const dayOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const maxDay = new Date(year, month, 0).getDate();
const originalValue = e.target.value;
const onlyNumber = originalValue.replace(/[^0-9]/g, "");
if (!onlyNumber) setDay(0);
else if (+onlyNumber > maxDay) return;
else setDay(+onlyNumber);
};

useEffect(() => {
const today = new Date();
const dday = new Date(year, month - 1, day);
const maxDay = new Date(year, month, 0).getDate();
if (day > maxDay) setDay(maxDay);
const calGetTime = today.getTime() - dday.getTime();
const result = Math.floor(calGetTime / (1000 * 60 * 60 * 24));
if (year < 1970 || year > 2099 || month === 0 || day === 0) {
setDdayCal(null);
} else {
setDdayCal(result);
}
}, [year, month, day]);

return {
year,
month,
day,
ddayCal,
yearOnChange,
monthOnChange,
dayOnChange,
};
};

export default useDday;
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ html {
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
overflow: hidden;
}

code {
Expand Down
2 changes: 2 additions & 0 deletions src/styles/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const themeVariableSets: Record<Theme, ThemeVariables> = {
hrLine: "#F9EDED",
text1: "#000000",
text2: "#282828",
highlightText: "#CF393E",
hour12am: "#FF6B6B",
hour12pm: "#0083FF",
alert1: "#FFD3D3",
Expand Down Expand Up @@ -54,6 +55,7 @@ const themeVariableSets: Record<Theme, ThemeVariables> = {
hrLine: "#F9EDED",
text1: "#FFFFFF",
text2: "#E0E0E0",
highlightText: "#FFFCA5",
hour12am: "#FF6B6B",
hour12pm: "#0083FF",
alert1: "#FFD3D3",
Expand Down

0 comments on commit 3d28a4c

Please sign in to comment.