Skip to content

Commit

Permalink
Adds MonthCalendar.tsx using Fullcalendar with localizaiton integrat…
Browse files Browse the repository at this point in the history
…ion. Still working on G cloud CalendarAPI integration.
  • Loading branch information
Stephen Swanson authored and Stephen Swanson committed Aug 26, 2024
1 parent 455bb23 commit b55f0f8
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 1 deletion.
34 changes: 34 additions & 0 deletions components/MonthCalendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
// remove this later^
import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
import resourceTimelinePlugin from "@fullcalendar/resource-timeline";
import resourceTimeGridPlugin from "@fullcalendar/resource-timegrid";
import interactionPlugin from "@fullcalendar/interaction";
import { useLanguage } from "@/lib/LanguageContext";
import fiLocale from "@fullcalendar/core/locales/fi";
import svLocale from "@fullcalendar/core/locales/sv";
import enLocale from "@fullcalendar/core/locales/en-gb";

const MonthCalendar = () => {
const { language } = useLanguage();
const localeMap = {
fi: fiLocale,
sv: svLocale,
en: enLocale,
};
const currentLocale = localeMap[language] || enLocale;
return (
<>
<FullCalendar
schedulerLicenseKey={process.env.FULL_CALENDAR_KEY}
plugins={[dayGridPlugin]}
initialView="dayGridMonth"
locale={currentLocale}
/>
<div />
</>
);
};

export default MonthCalendar;
1 change: 1 addition & 0 deletions hooks/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"en": "Satakunta Nation",
"sv": "Satakunta Nation"
},
"nav:calendar": { "fi": "Kalenteri", "en": "Calendar", "sv": "Kalender" },
"nav:forMembers": {
"fi": "Jäsenille",
"en": "For Members",
Expand Down
157 changes: 157 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
"@directus/sdk": "^17.0.0",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@fullcalendar/core": "^6.1.15",
"@fullcalendar/daygrid": "^6.1.15",
"@fullcalendar/interaction": "^6.1.15",
"@fullcalendar/react": "^6.1.15",
"@fullcalendar/resource": "^6.1.15",
"@fullcalendar/resource-timegrid": "^6.1.15",
"@fullcalendar/resource-timeline": "^6.1.15",
"@mui/material": "^5.15.20",
"dotenv": "^16.4.5",
"embla-carousel": "^8.1.6",
Expand Down
55 changes: 55 additions & 0 deletions pages/calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Navbar, { NavbarProps } from "@/components/Navbar";
import createClient from "@/lib/cmsClient";
import styles from "@/styles/calendar.module.css";
import { readItems } from "@directus/sdk";
import { GetStaticProps } from "next";
import Head from "next/head";
import MonthCalendar from "@/components/MonthCalendar";

export const getStaticProps: GetStaticProps<CalendarPageProps> = async () => {
const client = createClient();
const links = await client.request(readItems("NavigationLink"));
return {
props: {
navBar: {
links,
},
},
};
};

type CalendarPageProps = {
navBar: NavbarProps;
};

export default function News({ navBar }: CalendarPageProps) {
return (
<>
<Head>
<title>Satakuntalainen Osakunta</title>
<link
rel="icon"
href="/new-sato-website/public/favicon.ico"
type="image/x-icon"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</Head>
<Navbar links={navBar.links} />
<header className={styles.header}>
<div className={styles.headerContainer}>
<h1 className={styles.h1}>Kalenteri</h1>
<p className={styles.headerText}>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quidem odit
distinctio, ullam doloremque provident voluptas illo quaerat ex
saepe voluptate reiciendis rerum fuga obcaecati esse sit cum maxime,
dolorem facilis?
</p>
</div>
</header>
<main className={styles.main}>
<MonthCalendar />
</main>
<footer className={styles.footer} />
</>
);
}
2 changes: 1 addition & 1 deletion pages/news.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function News({ navBar }: NewsPageProps) {
</div>
</header>
<main className={styles.main}>
<Paper elevation={3} className={styles.newsContainer}>
<Paper elevation={0} className={styles.newsContainer}>
<div className={styles.listContainer}>
<List className={styles.articleList}>
<Tooltip
Expand Down
43 changes: 43 additions & 0 deletions styles/calendar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.main {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}

.h3 {
font-size: 2rem;
font-weight: 600;
margin: 0.5rem 0;
color: var(--blue300);
font-family: "Raleway", sans-serif;
}

.header {
display: flex;
justify-content: center;
align-items: center;
padding: 5rem 0;
width: 100%;
background-color: var(--blue100);
margin-bottom: 5rem;
}

.headerContainer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 70%;
}

.headerText {
width: 70%;
}

.footer {
width: 100%;
height: 20rem;
background-color: var(--blue300);
margin-top: 5rem;
}
40 changes: 40 additions & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,40 @@

scroll-behavior: smooth;
transition: 0.3s ease;

/* Full Calendar */
--fc-small-font-size: 0.85em;
--fc-page-bg-color: #fff;
--fc-neutral-bg-color: rgba(208, 208, 208, 0.3);
--fc-neutral-text-color: #808080;
--fc-border-color: #ddd;

--fc-button-text-color: #fff;
--fc-button-bg-color: #2c3e50;
--fc-button-border-color: #2c3e50;
--fc-button-hover-bg-color: #1e2b37;
--fc-button-hover-border-color: #1a252f;
--fc-button-active-bg-color: #1a252f;
--fc-button-active-border-color: #151e27;

--fc-event-bg-color: #3788d8;
--fc-event-border-color: #3788d8;
--fc-event-text-color: #fff;
--fc-event-selected-overlay-color: rgba(0, 0, 0, 0.25);

--fc-more-link-bg-color: #d0d0d0;
--fc-more-link-text-color: inherit;

--fc-event-resizer-thickness: 8px;
--fc-event-resizer-dot-total-width: 8px;
--fc-event-resizer-dot-border-width: 1px;

--fc-non-business-color: rgba(215, 215, 215, 0.3);
--fc-bg-event-color: rgb(143, 223, 130);
--fc-bg-event-opacity: 0.3;
--fc-highlight-color: rgba(188, 232, 241, 0.3);
--fc-today-bg-color: var(--blue100);
--fc-now-indicator-color: red;
}

List,
Expand Down Expand Up @@ -116,6 +150,12 @@ dd {
font-weight: 700;
}

/* Month calendar */
.fc {
width: 70%;
height: auto;
}

@media (max-width: 1050px) {
.embla {
--slide-size: 40%;
Expand Down

0 comments on commit b55f0f8

Please sign in to comment.