-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from Strong-Potato/70-feat-create-before-days-…
…function #70 feat create before days function
- Loading branch information
Showing
5 changed files
with
79 additions
and
36 deletions.
There are no files selected for viewing
56 changes: 33 additions & 23 deletions
56
src/components/Alarm/TabCapsule/Content/Content.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,45 @@ | ||
@use "@/sass" as *; | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: flex-start; | ||
align-items: center; | ||
gap: 12px; | ||
padding: 16px 20px; | ||
width: 100%; | ||
border-bottom: 1px solid $neutral100; | ||
|
||
&__thumbnail { | ||
width: 4rem; | ||
height: 4rem; | ||
border-radius: 50%; | ||
.page { | ||
height: calc(100vh - 86px); | ||
overflow: auto; | ||
&::-webkit-scrollbar { | ||
display: none; | ||
} | ||
-ms-overflow-style: none; | ||
scrollbar-width: none; | ||
|
||
&__wrapper { | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
flex-direction: row; | ||
align-items: flex-start; | ||
align-items: center; | ||
gap: 12px; | ||
padding: 16px 20px; | ||
width: 100%; | ||
border-bottom: 1px solid $neutral100; | ||
|
||
&__title { | ||
@include typography(tabLabel); | ||
text-align: left; | ||
&__thumbnail { | ||
width: 4rem; | ||
height: 4rem; | ||
border-radius: 50%; | ||
} | ||
|
||
&__time { | ||
color: $neutral400; | ||
@include typography(captionSmall); | ||
letter-spacing: -0.12px; | ||
&__wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
|
||
&__title { | ||
@include typography(tabLabel); | ||
text-align: left; | ||
} | ||
|
||
&__time { | ||
color: $neutral400; | ||
@include typography(captionSmall); | ||
letter-spacing: -0.12px; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
differenceInDays, | ||
differenceInHours, | ||
differenceInMinutes, | ||
differenceInSeconds, | ||
format, | ||
} from "date-fns"; | ||
|
||
function formatTimeAgo(date: Date) { | ||
const now = new Date(); | ||
const secondsAgo = differenceInSeconds(now, date); | ||
const minutesAgo = differenceInMinutes(now, date); | ||
const hoursAgo = differenceInHours(now, date); | ||
const daysAgo = differenceInDays(now, date); | ||
|
||
if (secondsAgo < 60) { | ||
return `${secondsAgo}초 전`; | ||
} else if (minutesAgo < 60) { | ||
return `${minutesAgo}분 전`; | ||
} else if (hoursAgo < 24) { | ||
return `${hoursAgo}시간 전`; | ||
} else if (daysAgo < 7) { | ||
return `${daysAgo}일 전`; | ||
} else { | ||
return format(date, "yy.MM.dd"); | ||
} | ||
} | ||
|
||
export default formatTimeAgo; |
Empty file.