Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/calblueprint/phs into phs-s…
Browse files Browse the repository at this point in the history
…itemap-fix
  • Loading branch information
miha-bhaskaran committed May 22, 2024
2 parents 7ab6431 + bf76b4c commit 6a61b0d
Show file tree
Hide file tree
Showing 27 changed files with 489 additions and 503 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Lint

#############################
# Start the job on push #
#############################
on:
push:
branches-ignore: [main]
pull_request:
branches: [main]

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Run ESLint, Prettier, and TypeScript compiler
# Set the agent to run on
runs-on: ubuntu-latest

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper
# list of changed files within `super-linter`
fetch-depth: 0

################################
# Install packages #
################################
- name: Install packages
run: npm ci
################################
# Lint codebase #
################################
- name: Run ESLint
run: npx lint-staged
################################
# Check Prettier on codebase #
################################
- name: Run Prettier
run: npx prettier --check .
################################
# Check for TypeScript errors #
# TODO: Add this back once outstanding issues are resolved by all devs.
################################
# - name: Run TypeScript compiler (tsc) on staged files
# run: |
# # Get list of staged TypeScript files
# files=$(git diff --cached --name-only --diff-filter=d | grep '\.tsx\?$')

# # Run tsc on each file
# for file in $files
# do
# npx tsc --noEmit $file || exit 1
# done
6 changes: 0 additions & 6 deletions package-lock.json

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

142 changes: 142 additions & 0 deletions src/app/exhibitsPage/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
'use client';

import React, { useEffect, useState } from 'react';
import Link from 'next/link';
import NavBar from '../../components/userComponents/navBar/navBar';
import { CategoryRow } from '../../types/types';
import { fetchAllCategories } from '../../supabase/category/queries';
import Exhibit from '../../components/userComponents/Exhibit/Exhibit';
import BackButton from '../../components/userComponents/BackButton/page';
import { useWebDeviceDetection } from '../../context/WindowWidthContext/WindowWidthContext';

/**
* @returns exhibit page
*/
function App() {
const isWebDevice = useWebDeviceDetection();
const [exhibits, setExhibits] = useState<CategoryRow[]>([]);
// fetches all the exhibits to display on the page
useEffect(() => {
// Get exhibits
const getExhibits = async () => {
const fetchedExhibits: CategoryRow[] = await fetchAllCategories();
setExhibits(fetchedExhibits);
};
getExhibits();
// Detect the hash in URL and scroll to the element with the corresponding ID
}, [exhibits]);

// activates whenever the page opens.
// checks if there's a "hash" which is an id of one of the exhibits to scroll to.
// scrolls down to corresponding exhibit with slight offset
useEffect(() => {
const { hash } = window.location;
if (hash) {
setTimeout(() => {
const element = document.querySelector(hash);
const yOffset = -200;
if (element) {
const y =
element.getBoundingClientRect().top + window.scrollY + yOffset;
// check on this offset later
window.scrollTo({ top: y, behavior: 'instant' });
}
}, 1000);
}
}, []);
return (
<div>
{!isWebDevice && (
<div className="bg-ivory">
<NavBar />
<div className="p-4 m-auto">
<BackButton />
<div className="flex-col justify-start items-start mt-2">
<h1 className="text-night leading-9 font-['Lato'] mb-4">
Our Exhibits{' '}
</h1>
<p className="text-night leading-5 font-normal font-['Lato']">
The Bay Area is home to a wide variety of plant and animal life.
As you explore the exhibits, you will learn about threatened and
endangered species that are under careful monitoring by
biologists. Protective conservation efforts are in place for
these vulnerable plants and animals. We welcome you to learn
more about these important species throughout the exhibits. Scan
the QR codes on display for more information.
</p>
</div>
<Link href="/siteMapPage">
<div className="px-4 py-2 mb-2 mt-6 rounded-md border active:border-hunterGreen border-asparagus justify-start items-start inline-flex">
<p className="active:text-hunterGreen text-center text-asparagus font-bold font-['Lato'] leading-tight">
Go to Map
</p>
</div>
</Link>
<ul>
{exhibits.map(exhibit => (
<Exhibit
title={exhibit.category || ''}
description={exhibit.description || ''}
image={exhibit.image || ''}
key={exhibit.id}
id={exhibit.id}
web={false}
/>
))}
</ul>
</div>
</div>
)}
{isWebDevice && (
<div className="bg-ivory">
<NavBar />
<div className="pl-64 pr-64 pt-24 m-auto">
<p className="text-night font-['Lato']">
{' '}
<Link className="text-scary-forest hover:underline" href="/">
{' '}
Home{' '}
</Link>{' '}
/ Our Exhibits{' '}
</p>
<div className="flex-col justify-start items-start mt-6">
<h1 className="text-night leading-9 font-['Lato'] mb-4">
Our Exhibits{' '}
</h1>
<p className="text-night leading-5 font-normal font-['Lato']">
The Bay Area is home to a wide variety of plant and animal life.
As you explore the exhibits, you will learn about threatened and
endangered species that are under careful monitoring by
biologists. Protective conservation efforts are in place for
these vulnerable plants and animals. We welcome you to learn
more about these important species throughout the exhibits. Scan
the QR codes on display for more information.
</p>
</div>
<Link href="/siteMapPage">
<div className="px-4 py-2 mt-6 rounded-md border active:border-hunterGreen border-asparagus justify-start items-start inline-flex">
<p className="active:text-hunterGreen text-center text-asparagus font-bold font-['Lato'] leading-tight">
Go to Map
</p>
</div>
</Link>
<div className="mt-8 grid grid-cols-2 gap-16 pb-[6rem]">
{exhibits.map(exhibit => (
<Exhibit
title={exhibit.category || ''}
description={exhibit.description || ''}
image={exhibit.image || ''}
key={exhibit.id}
id={exhibit.id}
web
/>
))}
</div>
</div>
</div>
)}
</div>
);
}

export default App;
2 changes: 1 addition & 1 deletion src/app/hoursAdmissionPage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function HoursAdmissionPage() {
</div>
</div>
<p className="text-night font-normal font-lato pl-[1.31rem]">
If you've found a wild animal that appears to be sick, injured, or
If you&apos;ve found a wild animal that appears to be sick, injured, or
orphaned, safely contain it and either bring it to our nearest shelter
or contact us for guidance.
</p>
Expand Down
1 change: 0 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
};

/**
* @param root0 - Destructured object containing the properties.
* @param root0.children - The child elements to be rendered within the RootLayout component.
Expand Down
77 changes: 59 additions & 18 deletions src/app/newsFeedPage/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
'use client';

import React, { useEffect, useState } from 'react';
import Link from 'next/link';
import BackButton from '../../components/userComponents/BackButton/page';
import NavBar from '../../components/userComponents/navBar/navBar';
import { NewsRow } from '../../types/types';
import { fetchAllNewsByDate } from '../../supabase/news/queries';
import NewsDisplay from '../../components/userComponents/NewsDisplay/NewsDisplay';
import { useWebDeviceDetection } from '../../context/WindowWidthContext/WindowWidthContext';

/**
* @returns news feed page
* @description queries from the news table in supabase and fetches all the news rows to display
* @returns news feed page by querying from the news table in supabase
*/
export default function App() {
const isWebDevice = useWebDeviceDetection();
const [news, setNews] = useState<NewsRow[]>([]);
useEffect(() => {
// Get news
Expand All @@ -20,25 +24,62 @@ export default function App() {
};
getNews();
}, [news]);

return (
<div className="bg-ivory h-screen">
<div className="bg-ivory h-full">
<NavBar />
<div className="p-4">
<BackButton />
<h1 className="text-night text-3xl font-bold mt-2 -ml-[1.8px]">News</h1>
<ul>
{news.map(article => (
<NewsDisplay
key={article.updated_at}
id={article.id}
contentLink={article.content_link}
createdAt={article.created_at}
title={article.title}
/>
))}
</ul>
</div>
{!isWebDevice && (
<div>
<div className="p-4">
<BackButton />
<h1 className="text-night text-3xl font-bold mt-2 -ml-[.113rem]">
News
</h1>
<ul>
{news.map(article => (
<NewsDisplay
key={article.updated_at}
id={article.id}
contentLink={article.content_link}
createdAt={article.created_at}
title={article.title}
/>
))}
</ul>
</div>
</div>
)}
{isWebDevice && (
<div>
<div className="flex">
<div className="w-[50%] text-night px-[10rem] pt-[7.5rem] bg-mint-cream flex flex-col items-center">
<div>
<p className="text-night">
{' '}
<Link href="/" className="text-scary-forest hover:underline">
{' '}
Home{' '}
</Link>{' '}
/ News{' '}
</p>
<h1 className="text-night text-4xl font-bold pt-6">News</h1>
</div>
</div>
<div className="w-[50%] px-[10rem] pt-[7.5rem] flex justify-center">
<ul className="pt-[4rem] m-auto">
{news.map(article => (
<NewsDisplay
key={article.updated_at}
id={article.id}
contentLink={article.content_link}
createdAt={article.created_at}
title={article.title}
/>
))}
</ul>
</div>
</div>
</div>
)}
</div>
);
}
1 change: 0 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import VisitorResources from '../components/userComponents/HomePageComponents/Vi
import WelcomeGraphic from '../components/userComponents/HomePageComponents/WelcomeGraphic/WelcomeGraphic';
import HomeVirtualTours from '../components/userComponents/HomePageComponents/HomeVirtualTours/HomeVirtualTours';
import HomeNewsFeed from '../components/userComponents/HomePageComponents/HomeNewsFeed/HomeNewsFeed';
// import { useWebDeviceDetection } from '../../context/WindowWidthContext/WindowWidthContext';\
import { useWebDeviceDetection } from '../context/WindowWidthContext/WindowWidthContext';

/**
Expand Down
18 changes: 9 additions & 9 deletions src/app/spotlightPage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@ function App() {
className="w-[24.375rem] h-[13.375rem] rounded-lg"
key={
media.find(
m =>
m.id ===
allTourMedia.find(m => m.tour_id === spotlight.id)
mediaElement =>
mediaElement.id ===
allTourMedia.find(allTourMediaElement => allTourMediaElement.tour_id === spotlight.id)
?.media_id,
)?.id
}
src={
media.find(
m =>
m.id ===
allTourMedia.find(m => m.tour_id === spotlight.id)
mediaElement =>
mediaElement.id ===
allTourMedia.find(allTourMediaElement => allTourMediaElement.tour_id === spotlight.id)
?.media_id,
)?.url ?? ''
}
alt={
media.find(
m =>
m.id ===
allTourMedia.find(m => m.tour_id === spotlight.id)
mediaElement =>
mediaElement.id ===
allTourMedia.find(allTourMediaElement => allTourMediaElement.tour_id === spotlight.id)
?.media_id,
)?.text ?? ''
}
Expand Down
Loading

0 comments on commit 6a61b0d

Please sign in to comment.