diff --git a/src/components/Carousel.tsx b/src/components/Carousel.tsx index 5413205..22020f6 100644 --- a/src/components/Carousel.tsx +++ b/src/components/Carousel.tsx @@ -1,38 +1,31 @@ import { useState } from 'react'; import '../css/carousel.css'; -import Organization from './Organization'; -type CarouselProps = { - type: string; -}; +import EventPanel from './EventCarouselPanel.tsx'; +import OrganizationPanel from './OrganizationCarouselPanel.tsx'; -export default function Carousel({ type }: CarouselProps) { - const [active, setActive] = useState(0); +import type { Event } from '../types/Event.ts'; +import type { Organization } from '../types/Organization.ts'; + +type CarouselProps = + | { type: 'event'; title: string; data: Event[] } + | { type: 'organization'; title: string; data: Organization[] }; - const organizations = [ - { title: 'Math Club', desc: 'The RPI Math Faculty approved and Union affiliated math club!' }, - { title: 'Science Club', desc: 'The RPI Math Faculty approved and Union affiliated science club!' }, - { title: 'Gym Club', desc: 'The RPI Math Faculty approved and Union affiliated gym club!' }, - { title: 'Dance Club', desc: 'The RPI Math Faculty approved and Union affiliated dance club!' }, - { title: 'English Club', desc: 'The RPI Math Faculty approved and Union affiliated english club!' }, - { title: 'Coding Club', desc: 'The RPI Math Faculty approved and Union affiliated coding club!' }, - { title: 'Archery Club', desc: 'The RPI Math Faculty approved and Union affiliated archery club!' }, - { title: 'Golf Club', desc: 'The RPI Math Faculty approved and Union affiliated golf club!' }, - { title: 'Running Club', desc: 'The RPI Math Faculty approved and Union affiliated running club!' }, - { title: 'Study Club', desc: 'The RPI Math Faculty approved and Union affiliated study club!' }, - ]; +export default function Carousel({ type, title, data }: CarouselProps) { + console.log(data); + const [active, setActive] = useState(0); const moveLeft = () => { setActive((prev) => Math.max(prev - 1, 0)); }; const moveRight = () => { - setActive((prev) => Math.min(prev + 1, organizations.length - 1)); + setActive((prev) => Math.min(prev + 1, data.length - 1)); }; return (
- {type} + {title}
- {organizations.map((org, index) => { - const offset = index - active; - return ( - setActive(index)} - /> - ); - })} + {type === 'event' + ? data.map((event, index) => { + const offset = index - active; + + return ( + setActive(index)} + /> + ); + }) + : data.map((org, index) => { + const offset = index - active; + + return ( + setActive(index)} + /> + ); + })}
diff --git a/src/components/OrganizationCarouselPanel.tsx b/src/components/OrganizationCarouselPanel.tsx new file mode 100644 index 0000000..28d1a99 --- /dev/null +++ b/src/components/OrganizationCarouselPanel.tsx @@ -0,0 +1,26 @@ +import '../css/organizations.css'; +import '../css/carousel.css'; + +import type { Organization } from '../types/Organization.ts'; + +type OrganizationCarouselPanelProps = { + organization: Organization; + className: string; + onClick?: () => void; +}; + +export default function Organization({ organization, className, onClick }: OrganizationCarouselPanelProps) { + return ( +
+
+
+ {organization.name} + {organization.description} +
+
+ + +
+
+ ); +} diff --git a/src/css/carousel.css b/src/css/carousel.css index cfdd993..57d33bb 100644 --- a/src/css/carousel.css +++ b/src/css/carousel.css @@ -58,6 +58,7 @@ .offset-2 { transform: translate(90%, -50%) scale(0.75); opacity: 0.8; + z-index: 1; } .offset-1 { @@ -84,6 +85,7 @@ .offset--2 { transform: translate(-190%, -50%) scale(0.75); opacity: 0.8; + z-index: 1; } /* hide far cards */ @@ -91,6 +93,7 @@ [class*='offset--3'] { opacity: 0; pointer-events: none; + z-index: 0; } /* arrow buttons */ diff --git a/src/css/organizations.css b/src/css/organizations.css index 32e46e0..cce57f8 100644 --- a/src/css/organizations.css +++ b/src/css/organizations.css @@ -6,6 +6,8 @@ padding: 1.25rem; color: var(--standard-bw-text); cursor: pointer; + display: flex; + flex-direction: column; } .org-metadata { @@ -26,7 +28,7 @@ } .org-btns { - margin-top: 2rem; + margin: auto 0 0.5rem; display: flex; flex-direction: row; } diff --git a/src/pages/Events.tsx b/src/pages/Events.tsx index f9cc039..479e047 100644 --- a/src/pages/Events.tsx +++ b/src/pages/Events.tsx @@ -1,11 +1,87 @@ import Carousel from '../components/Carousel.tsx'; +import type { Event } from '../types/Event.ts'; + export default function Events() { + // 1. Fetch my_events and rec_events + // 2. Parse date/time types from string to date/time + // 3. Make it into variables below: + // 4. Propogate to carousel with type + + /* Current API response: + { + "date_created": "string", + "date_modified": "string", + "description": "string", + "eid": "string", + "event_time": "string", + "location": "string" + } + + Need: + - description + - organization + */ + + // SAMPLE DATA + const myEvents: Event[] = [ + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is event 1 This is event 1 This is event 1 This is event 1', + eid: '1', + event_time: new Date(), + location: 'Amos Eaton', + organization: 'Chorus', + title: 'Sing-along', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is event 2 This is event 2 This is event 2 This is event 2', + eid: '2', + event_time: new Date(), + location: 'VCC', + organization: 'Coding', + title: 'Hackathon', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is event 3 This is event 3 This is event 3 This is event 3', + eid: '3', + event_time: new Date(), + location: 'Sage', + organization: 'Dance', + title: 'Competition', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is event 4 This is event 4 This is event 4 This is event 4', + eid: '4', + event_time: new Date(), + location: 'Folsom', + organization: 'Math', + title: 'Review Session', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is event 5 This is event 5 This is event 5 This is event 5', + eid: '5', + event_time: new Date(), + location: 'EMPAC', + organization: 'AGT', + title: 'America Got Talent', + }, + ]; + return ( <>
- - + +
); diff --git a/src/pages/Organizations.tsx b/src/pages/Organizations.tsx index b2cf37a..371931a 100644 --- a/src/pages/Organizations.tsx +++ b/src/pages/Organizations.tsx @@ -1,11 +1,66 @@ import Carousel from '../components/Carousel.tsx'; +import type { Organization } from '../types/Organization.ts'; + export default function Organizations() { + /* Current API response: + { + "date_created": "string", + "date_modified": "string", + "description": "string", + "eid": "string", + "event_time": "string", + "location": "string" + } + + Need: + - description + - organization + */ + + const myOrgs: Organization[] = [ + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is organization 1 This is organization 1 This is organization 1', + name: 'CAPY', + oid: '1', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is organization 2 This is organization 2 This is organization 2', + name: 'LXA', + oid: '2', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is organization 3 This is organization 3 This is organization 3', + name: 'RPAI', + oid: '3', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is organization 4 This is organization 4 This is organization 4', + name: 'Robotics', + oid: '4', + }, + { + date_created: new Date(), + date_modified: new Date(), + description: 'This is organization 5 This is organization 5 This is organization 5', + name: 'RPISEC', + oid: '5', + }, + ]; + return ( <>
- - + +
); diff --git a/src/types/.gitkeep b/src/types/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/types/Event.ts b/src/types/Event.ts new file mode 100644 index 0000000..3d6c22e --- /dev/null +++ b/src/types/Event.ts @@ -0,0 +1,10 @@ +export type Event = { + date_created: Date; + date_modified: Date; + description: string; + eid: string; + event_time: Date; + location: string; + organization: string; + title: string; +}; diff --git a/src/types/Organization.ts b/src/types/Organization.ts new file mode 100644 index 0000000..bb56ed2 --- /dev/null +++ b/src/types/Organization.ts @@ -0,0 +1,7 @@ +export type Organization = { + date_created: Date; + date_modified: Date; + description: string; + name: string; + oid: string; +};