Skip to content

Commit

Permalink
Merge pull request #190 from HKN-UCSD/revert-188-ui-table
Browse files Browse the repository at this point in the history
Revert "UI table"
  • Loading branch information
greyluo authored Feb 19, 2025
2 parents 9a207ad + e6fbfb4 commit 7b2f09f
Show file tree
Hide file tree
Showing 46 changed files with 1,944 additions and 4,044 deletions.
3 changes: 0 additions & 3 deletions frontend/main.css

This file was deleted.

2,801 changes: 239 additions & 2,562 deletions frontend/package-lock.json

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-terser": "^0.4.0",
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
"rollup": "^3.29.5",
"rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.1.6",
"svelte": "^3.55.0",
"tailwindcss": "^3.4.17"
"svelte": "^3.55.0"
},
"dependencies": {
"@fullcalendar/core": "^6.1.9",
Expand All @@ -31,7 +28,6 @@
"dompurify": "^3.0.11",
"marked": "^9.0.0",
"requirements": "^1.4.1",
"rollup-plugin-postcss": "^4.0.2",
"sirv-cli": "^2.0.0",
"svelte-device-info": "^1.0.0",
"svelte-routing": "^2.1.0"
Expand Down
6 changes: 0 additions & 6 deletions frontend/postcss.config.cjs

This file was deleted.

23 changes: 4 additions & 19 deletions frontend/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import postcss from 'rollup-plugin-postcss';
import css from 'rollup-plugin-css-only';

const production = !process.env.ROLLUP_WATCH;

function serve() {
Expand Down Expand Up @@ -41,29 +42,14 @@ export default {
compilerOptions: {
// enable run-time checks when not in production
dev: !production

},

}
}),
postcss({
config: {
path: './postcss.config.js',
},
extensions: ['.css'],
minimize: true,
less: { javascriptEnabled: true },
inject: {
insertAt: 'top',
},
extract: 'bundle.css', // This will create 'bundle.css'
}),


!production && livereload('../myapp/static/frontend'),

// we'll extract any component CSS out into
// a separate file - better for performance

css({ output: 'bundle.css' }),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
Expand Down Expand Up @@ -93,4 +79,3 @@ export default {
clearScreen: false
}
};

18 changes: 16 additions & 2 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import EventCreate from "./Pages/Events/EventCreate.svelte";
import EventRides from "./Pages/Events/EventRides.svelte"
import Profile from "./Pages/Profile.svelte";
import ProfileEdit from "./Pages/ProfileEdit.svelte";
import Inductees from "./Pages/Inductees.svelte";
import Outreach from "./Pages/Outreach.svelte";
import House from "./Pages/House.svelte";
Expand All @@ -21,15 +22,18 @@
<Route path="/profile/self">
<Profile id={null}/>
</Route>

<Route path="/profile/edit">
<ProfileEdit />
</Route>

{#if $adminStatus !== null}
<Route path="/profile/:id" let:params>
<Profile id={params.id}/>
</Route>
<Route path="/events/:id" let:params>
<EventDetail id={params.id}/>
</Route>

{#if $adminStatus === true}
<Route path="/inductees" component={Inductees} />
<Route path="/outreach" component={Outreach} />
Expand All @@ -54,6 +58,16 @@



<style>
:global(:root) {
--primary-color: #4350AF;
}
:global(body) {
margin: 0px;
padding: 0px;
}
</style>


6 changes: 3 additions & 3 deletions frontend/src/Components/Events/EventActionBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</script>
{#await getAvailableSelfActions()}
<p>Loading...</p>
{:then selfActions}
{:then selfActions}
<div class="selfactions">
{#each selfActions as selfAction}
{@const record = user.records.find((record) => record.action == selfAction)}
<!-- If a record was found, provide a delete option; otherwise allow user
<!-- If a record was found, provide a delete option; otherwise allow user
to take the action -->
{#if record == undefined}
<div>
Expand All @@ -31,5 +31,5 @@
{/if}
{/each}
</div>

{/await}
223 changes: 167 additions & 56 deletions frontend/src/Components/Events/EventCard.svelte
Original file line number Diff line number Diff line change
@@ -1,60 +1,171 @@

<script>
import { navigate } from 'svelte-routing';
export let event;
export let toggleRSVP;
export let RSVP;
export let RSVPEnabled = true;
function getFormattedDateTime(startDateTimeString, endDateTimeString) {
const startEventTime = new Date(startDateTimeString);
const endEventTime = new Date(endDateTimeString);
const options = {
month: 'short', // Month abbreviation (e.g., Oct)
day: 'numeric', // Day of the month (e.g., 22)
hour: 'numeric', // Hour in 12-hour format (e.g., 6)
minute: '2-digit', // Minutes (e.g., 00)
hour12: true // Use 12-hour clock (e.g., AM/PM)
};
if (startEventTime.toLocaleString('en-US', options).split(',')[0] == endEventTime.toLocaleString('en-US', options).split(',')[0]){
return startEventTime.toLocaleString('en-US', options).concat(" -", endEventTime.toLocaleString('en-US', options).split(',')[1])
}else{
return startEventTime.toLocaleString('en-US', options).concat(" - ", endEventTime.toLocaleString('en-US', options))
}
}
import { onMount } from 'svelte';
import { getEvents } from "./eventstore";
import { embedCode } from "./canvaEmbed.js";
</script>
let events = [];
let logo = "/static/Default_card_banner.png";
//Filter and sort events(Only keep Upcoming Events in ascending order)
function filterEvents(allEvents) {
const currentDate = new Date();
//Does not compare time other than the date(Event list last until the day end)
currentDate.setHours(0,0,0,0);
const filteredEvents = allEvents
.filter(event => {
const eventStartTime = new Date(event.start_time);
eventStartTime.setHours(0,0,0,0)
return eventStartTime >= currentDate;
})
//Sort event in start time
.sort((a, b) => {
const startTimeA = new Date(a.start_time);
const startTimeB = new Date(b.start_time);
return startTimeA - startTimeB;
});
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="flex-none md:basis-1/2 lg:basis-1/3 border border-gray-300 rounded-lg min-h-10 m-2 bg-white rounded-lg shadow-md overflow-hidden hover:bg-gray-100 transition duration-300 flex flex-col" on:click={() => navigate(event.url)}>
<div class="canva-embed-code max-h-[200px] overflow-hidden">
{@html event.embed_code}
</div>
<!-- Content Section -->
<div class="flex-grow p-6 flex flex-col overflow-x-auto">
<h2 class="text-xl font-semibold text-gray-900 mb-2">{event.title}</h2>
<p class="text-gray-600 flex items-center gap-2 mb-2">
📍 {event.location}
</p>
<p class="text-gray-600 flex items-center gap-2">
🕒 {getFormattedDateTime(event.start_time, event.end_time)}
</p>
</div>

<!-- Button Section -->

{#if RSVPEnabled}

<div class="p-6">
<button
class="w-full py-3 px-6 rounded-lg font-semibold text-white transition-all duration-300 transform hover:scale-105 focus:outline-none shadow-lg
{RSVP.find((record) => record.event == event.pk)
? 'bg-primary hover:bg-primary-dark focus:ring-primary'
: 'bg-secondary hover:bg-secondary-dark focus:ring-secondary'
}"
on:click={(e) => toggleRSVP(event, e)}
>
{RSVP.find((record) => record.event == event.pk) ? "RSVP'd ★" : "RSVP"}
</button>
return filteredEvents;
}
function getFormattedDateTime(startDateTimeString, endDateTimeString) {
const startEventTime = new Date(startDateTimeString);
const endEventTime = new Date(endDateTimeString);
const options = {
month: 'short', // Month abbreviation (e.g., Oct)
day: 'numeric', // Day of the month (e.g., 22)
hour: 'numeric', // Hour in 12-hour format (e.g., 6)
minute: '2-digit', // Minutes (e.g., 00)
hour12: true // Use 12-hour clock (e.g., AM/PM)
};
if (startEventTime.toLocaleString('en-US', options).split(',')[0] == endEventTime.toLocaleString('en-US', options).split(',')[0]){
return startEventTime.toLocaleString('en-US', options).concat(" -", endEventTime.toLocaleString('en-US', options).split(',')[1])
}else{
return startEventTime.toLocaleString('en-US', options).concat(" - ", endEventTime.toLocaleString('en-US', options))
}
}
onMount(async () => {
// Fetch events from the API and wait for the promise to resolve
const allEvents = await getEvents();
events = filterEvents(allEvents).slice(0,10);
});
</script>

<div class="event-list">
{#each events as event}
<div class="event-card">
{#if event.embed_code}
<div class="embed-code">
{@html event.embed_code}
</div>
{:else if Object.keys(embedCode).includes(event.event_type)}
<div class="embed-code">
{@html embedCode[event.event_type]}
</div>
{:else}
<img class="default-image" src={logo} alt="{event.title}">
{/if}
<div class={event.is_draft ? "draft-content" : "card-content"}>
<h2 class="title"><a href={`/events/${event.pk}`}>{event.name}</a></h2>
<p class="eventtime">{getFormattedDateTime(event.start_time, event.end_time)}</p>
<p class="location">{event.location}</p>
</div>
</div>
{/each}
</div>
{/if}
</div>

<style>
.event-list {
display: flex;
flex-direction: column;
align-items: center;
}
.embed-code :global(div) {
margin:0 !important;
}
.event-card {
border: 2px solid;
border-color: #333;
border-radius: 10px;
overflow-x: hidden;
overflow-y: hidden;
padding: 0px;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
border: 2px solid black;
height: 280px;
width: 300px;
margin: 20px;
scrollbar-width: none;
}
.embed-code{
height:160px;
object-fit: cover;
object-position: top;
width: 100%;
vertical-align: middle;
overflow: hidden;
margin: 0;
padding: 0;
}
.default-image {
height:160px;
object-position: top;
max-width: 100%;
vertical-align: middle;
overflow: hidden;
margin: 0;
padding: 0;
}
.title a {
color: black;
font-size: 25px;
text-decoration: none;
margin: 0px 0px 0px 20px;
display: inline-block;
}
.title a:hover {
text-decoration: underline; /* Add underline on hover for links */
}
.card-content {
margin: 0px;
padding-bottom: 2em;
width: 100%;
text-align: left;
}
.draft-content{
margin: 0px;
padding-bottom: 2em;
background-color: #dcdcdc;
width: 100%;
text-align: left;
}
.eventtime{
color: black;
font-size: 14px;
text-decoration: none;
margin: 5px 0px 0px 20px;
}
.location{
color: black;
font-size: 14px;
text-decoration: none;
margin: 5px 0px 0px 20px;
float: left;
}
h2{
margin:12px 0px;
}
</style>

Loading

0 comments on commit 7b2f09f

Please sign in to comment.