mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-22 14:44:21 +00:00
Start building dates framework
This commit is contained in:
parent
f942a8e556
commit
deebefbc89
10 changed files with 114 additions and 9 deletions
28
components/FormDateRange.tsx
Normal file
28
components/FormDateRange.tsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import { ReactNode } from "react"
|
||||||
|
|
||||||
|
type FormDateRangeProps = {
|
||||||
|
icon: ReactNode,
|
||||||
|
start: ReactNode,
|
||||||
|
connector: ReactNode,
|
||||||
|
end: ReactNode,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function FormDateRange(props: FormDateRangeProps) {
|
||||||
|
return (
|
||||||
|
<div className="form-daterange">
|
||||||
|
<div className="form-daterange-icon">
|
||||||
|
{props.icon}
|
||||||
|
</div>
|
||||||
|
<div className="form-daterange-start">
|
||||||
|
{props.start}
|
||||||
|
</div>
|
||||||
|
<div className="form-daterange-connector">
|
||||||
|
{props.connector}
|
||||||
|
</div>
|
||||||
|
<div className="form-daterange-end">
|
||||||
|
{props.end}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
25
components/editable/EditableDateRange.tsx
Normal file
25
components/editable/EditableDateRange.tsx
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { faClock } from "@fortawesome/free-solid-svg-icons"
|
||||||
|
import { FestaIcon } from "../extensions/FestaIcon"
|
||||||
|
import { FormDateRange } from "../FormDateRange"
|
||||||
|
|
||||||
|
|
||||||
|
export function EditableDateRange() {
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormDateRange
|
||||||
|
icon={
|
||||||
|
<FestaIcon icon={faClock}/>
|
||||||
|
}
|
||||||
|
start={<>
|
||||||
|
|
||||||
|
</>}
|
||||||
|
connector={<>
|
||||||
|
→
|
||||||
|
</>}
|
||||||
|
end={<>
|
||||||
|
|
||||||
|
</>}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
import { ReactNode } from "react"
|
import { ReactNode } from "react"
|
||||||
|
import { FormDateRange } from "../FormDateRange"
|
||||||
|
|
||||||
type ViewEventProps = {
|
type ViewEventProps = {
|
||||||
title: ReactNode
|
title: ReactNode,
|
||||||
postcard: ReactNode
|
postcard: ReactNode,
|
||||||
description: ReactNode
|
description: ReactNode,
|
||||||
|
datetime: ReactNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +21,9 @@ export function ViewEvent(props: ViewEventProps) {
|
||||||
<div className="view-event-description">
|
<div className="view-event-description">
|
||||||
{props.description}
|
{props.description}
|
||||||
</div>
|
</div>
|
||||||
|
<FormDateRange
|
||||||
|
className="view-event-daterange"
|
||||||
|
/>
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -23,6 +23,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||||
const update = {
|
const update = {
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
postcard: req.body.postcard ?? null,
|
postcard: req.body.postcard ?? null,
|
||||||
|
description: req.body.description,
|
||||||
|
startingAt: req.body.startingAt,
|
||||||
|
endingAt: req.body.endingAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
await restInPeace(req, res, {
|
await restInPeace(req, res, {
|
||||||
|
|
|
@ -21,6 +21,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||||
creatorId: user.id,
|
creatorId: user.id,
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
postcard: req.body.postcard ?? null,
|
postcard: req.body.postcard ?? null,
|
||||||
|
description: req.body.description,
|
||||||
|
startingAt: req.body.startingAt,
|
||||||
|
endingAt: req.body.endingAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
await restInPeace(req, res, {
|
await restInPeace(req, res, {
|
||||||
|
|
|
@ -14,6 +14,8 @@ import { Postcard } from "../../components/postcard/Postcard";
|
||||||
import { ViewContent } from "../../components/view/ViewContent";
|
import { ViewContent } from "../../components/view/ViewContent";
|
||||||
import { EditablePostcard } from "../../components/editable/EditablePostcard";
|
import { EditablePostcard } from "../../components/editable/EditablePostcard";
|
||||||
import { ViewEvent } from "../../components/view/ViewEvent";
|
import { ViewEvent } from "../../components/view/ViewEvent";
|
||||||
|
import { EditableDateTime } from "../../components/editable/EditableDateTime";
|
||||||
|
import { FormDateRange } from "../../components/FormDateRange";
|
||||||
|
|
||||||
|
|
||||||
export async function getServerSideProps(context: NextPageContext) {
|
export async function getServerSideProps(context: NextPageContext) {
|
||||||
|
@ -50,6 +52,8 @@ export default function PageEventDetail({event}: PageEventDetailProps) {
|
||||||
const [title, setTitle] = useState<string>(event.name)
|
const [title, setTitle] = useState<string>(event.name)
|
||||||
const [description, setDescription] = useState<string>(event.description)
|
const [description, setDescription] = useState<string>(event.description)
|
||||||
const [postcard, setPostcard] = useState<string | null>(event.postcard)
|
const [postcard, setPostcard] = useState<string | null>(event.postcard)
|
||||||
|
const [startingAt, setStartingAt] = useState<string | null>(event.startingAt?.toISOString() ?? null)
|
||||||
|
const [endingAt, setEndingAt] = useState<string | null>(event.endingAt?.toISOString() ?? null)
|
||||||
|
|
||||||
const setPostcardBlob = useCallback(
|
const setPostcardBlob = useCallback(
|
||||||
(e: ChangeEvent<HTMLInputElement>) => {
|
(e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
@ -97,6 +101,18 @@ export default function PageEventDetail({event}: PageEventDetailProps) {
|
||||||
placeholder={t("eventDetailsDescriptionPlaceholder")}
|
placeholder={t("eventDetailsDescriptionPlaceholder")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
datetime={
|
||||||
|
<FormDateRange
|
||||||
|
startProps={{
|
||||||
|
value: startingAt ?? undefined,
|
||||||
|
onChange: (e: ChangeEvent<HTMLInputElement>) => setStartingAt(e.target.value),
|
||||||
|
}}
|
||||||
|
endProps={{
|
||||||
|
value: endingAt ?? undefined,
|
||||||
|
onChange: (e: ChangeEvent<HTMLInputElement>) => setEndingAt(e.target.value),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</EditingContext.Provider>
|
</EditingContext.Provider>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -87,4 +87,8 @@ model Event {
|
||||||
postcard String?
|
postcard String?
|
||||||
/// The description of the event. It will be parsed in Markdown!
|
/// The description of the event. It will be parsed in Markdown!
|
||||||
description String @default("")
|
description String @default("")
|
||||||
|
/// The time when the event will start at.
|
||||||
|
startingAt DateTime?
|
||||||
|
/// The time when the even will end at.
|
||||||
|
endingAt DateTime?
|
||||||
}
|
}
|
||||||
|
|
15
styles/components/form-daterange.css
Normal file
15
styles/components/form-daterange.css
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
.form-daterange {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-daterange-start, .form-daterange-end {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-daterange-icon, .form-daterange-connector {
|
||||||
|
flex-grow: 0;
|
||||||
|
}
|
|
@ -4,9 +4,10 @@
|
||||||
"x1 ti ti ti x4"
|
"x1 ti ti ti x4"
|
||||||
"x1 x2 po x3 x4"
|
"x1 x2 po x3 x4"
|
||||||
"x1 x2 de x3 x4"
|
"x1 x2 de x3 x4"
|
||||||
|
"x1 x2 dr x3 x4"
|
||||||
;
|
;
|
||||||
grid-template-columns: 3fr 1fr 800px 1fr 3fr;
|
grid-template-columns: 3fr 1fr 800px 1fr 3fr;
|
||||||
grid-template-rows: auto auto 1fr;
|
grid-template-rows: auto auto 1fr auto;
|
||||||
|
|
||||||
row-gap: 4px;
|
row-gap: 4px;
|
||||||
|
|
||||||
|
@ -25,3 +26,7 @@
|
||||||
.view-event-description {
|
.view-event-description {
|
||||||
grid-area: de;
|
grid-area: de;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.view-event-daterange {
|
||||||
|
grid-area: dr;
|
||||||
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
@import "components/toolbar.css";
|
@import "components/toolbar.css";
|
||||||
@import "components/form-monorow.css";
|
@import "components/form-monorow.css";
|
||||||
@import "components/error.css";
|
@import "components/error.css";
|
||||||
|
@import "components/form-daterange.css";
|
||||||
|
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
*[disabled] {
|
*[disabled], .disabled {
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue