generated from imperial/impaas-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #58 from imperial/style-responsiveness
style: responsiveness
- Loading branch information
Showing
11 changed files
with
115 additions
and
80 deletions.
There are no files selected for viewing
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
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,89 @@ | ||
"use client" | ||
|
||
import { Flex, Spinner, Text } from "@radix-ui/themes" | ||
import { format, formatDistanceStrict, isSameDay } from "date-fns" | ||
import React, { useEffect, useState } from "react" | ||
import { BsCalendar } from "react-icons/bs" | ||
|
||
/** | ||
* Format an event's date to JSX | ||
* @param dateStart The start date time | ||
* @param dateEnd The end date time | ||
* @example | ||
* formatEventDateTime( | ||
* new Date("2022-01-01T12:00:00Z"), | ||
* new Date("2022-01-01T14:00:00Z") | ||
* ) => | ||
* <> | ||
* <b><time>Sat, 01 Jan 12:00</time></b>-<b><time>14:00</time></b> GMT+0 (2 hours) | ||
* </> | ||
* @example | ||
* formatEventDateTime( | ||
* new Date("2022-01-01T12:00:00Z"), | ||
* new Date("2022-01-02T14:00:00Z") | ||
* ) => | ||
* <> | ||
* <b><time>Sat, 01 Jan 12:00</time></b> to <b><time>Sun, 02 Jan 14:00</time></b> GMT+0 (1 day) | ||
* </> | ||
*/ | ||
const formatEventDateTime = (dateStart: Date, dateEnd: Date | null) => { | ||
const formattedStart = ( | ||
<b> | ||
<time>{format(dateStart, "E, dd MMM kk:mm")}</time> | ||
</b> | ||
) | ||
const formattedEnd = dateEnd ? ( | ||
isSameDay(dateStart, dateEnd) ? ( | ||
<> | ||
- | ||
<b> | ||
<time>{format(dateEnd, "kk:mm")}</time> | ||
</b> | ||
</> | ||
) : ( | ||
<> | ||
{" "} | ||
to{" "} | ||
<b> | ||
<time>{format(dateEnd, "E, dd MMM kk:mm")}</time> | ||
</b> | ||
</> | ||
) | ||
) : ( | ||
"" | ||
) | ||
const timezone = format(dateStart, "O") | ||
const formattedDuration = dateEnd ? <>{formatDistanceStrict(dateStart, dateEnd)}</> : "" | ||
|
||
return ( | ||
<> | ||
{formattedStart} | ||
{formattedEnd} {timezone} ({formattedDuration}) | ||
</> | ||
) | ||
} | ||
|
||
const FormattedClientDateTime = ({ dateStart, dateEnd }: { dateStart: Date; dateEnd: Date | null }) => { | ||
const [isClient, setIsClient] = useState(false) | ||
|
||
useEffect(() => { | ||
setIsClient(true) | ||
}, []) | ||
|
||
if (!isClient) { | ||
return ( | ||
<Flex direction="row" gap="3"> | ||
<Spinner /> | ||
Loading | ||
</Flex> | ||
) | ||
} | ||
return ( | ||
<Flex align="center" gap="2"> | ||
<BsCalendar /> | ||
<Text>{formatEventDateTime(dateStart, dateEnd)}</Text> | ||
</Flex> | ||
) | ||
} | ||
|
||
export default FormattedClientDateTime |
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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
.inputBox { | ||
color-scheme: light; | ||
display: inline-block; | ||
input { | ||
height: 100%; | ||
} | ||
display: inline-flex; | ||
align-items: center; | ||
} |