Added recent news, mission, etc

This commit is contained in:
Michael Fatemi 2020-11-25 20:43:15 -05:00
parent 53e2ef077d
commit 5d96744335
20 changed files with 137 additions and 66 deletions

File diff suppressed because one or more lines are too long

View File

@ -24,10 +24,6 @@
} }
} }
img {
max-width: 100%;
}
.space-2 { .space-2 {
margin: 1rem; margin: 1rem;
padding: 1rem; padding: 1rem;
@ -52,10 +48,19 @@ img {
.row { .row {
display: flex; display: flex;
flex-direction: row;
} }
.col { .col {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; align-items: center;
}
.flex-1 {
flex: 1;
}
.flex-2 {
flex: 2;
} }

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import ArticleRow from './ArticleRow'; import ArticleRow from './ArticleRow';
import sanity from '../sanity'; import sanity from '../sanity';
import '../css/article.css';
export default function ArticleList() { export default function ArticleList() {
let [articles, setArticles] = React.useState<SGA.ArticleDocument[]>([]); let [articles, setArticles] = React.useState<SGA.ArticleDocument[]>([]);
@ -40,7 +41,7 @@ export default function ArticleList() {
} }
return ( return (
<div style={{ display: 'flex', flexDirection: 'column' }}> <div>
{articles.map((article) => { {articles.map((article) => {
return <ArticleRow key={article._id} article={article} />; return <ArticleRow key={article._id} article={article} />;
})} })}
@ -48,7 +49,7 @@ export default function ArticleList() {
<div className='text-center'> <div className='text-center'>
{!reachedEnd ? ( {!reachedEnd ? (
<button <button
className='button' className='load-more-button'
onClick={() => { onClick={() => {
let lastArticle = articles[articles.length - 1]; let lastArticle = articles[articles.length - 1];
addArticles(lastArticle.publish_date, lastArticle.title); addArticles(lastArticle.publish_date, lastArticle.title);

View File

@ -18,15 +18,15 @@ export default function ArticleRow({
}; };
return ( return (
<div style={{ display: 'flex' }}> <div className='row'>
<div style={{ flex: 1, padding: '10px' }}> <div className='article-row-thumbnail'>
{thumbUrl ? ( {thumbUrl ? (
<img className='mb-4' src={thumbUrl} alt={article.title} /> <img className='mb-4' src={thumbUrl} alt={article.title} />
) : null} ) : null}
</div> </div>
<div style={{ flex: 3, padding: '10px' }}> <div className='article-row-content'>
<Link to={'/news/' + article._id + '/' + slug(article.title)}> <Link to={'/news/' + article._id + '/' + slug(article.title)}>
<h3 className='font-bold text-3xl'>{article.title}</h3> <h3>{article.title}</h3>
</Link> </Link>
<i className='text-sm'> <i className='text-sm'>
{article.publish_date} - {article.author || 'No author'} {article.publish_date} - {article.author || 'No author'}

View File

@ -11,7 +11,6 @@ export default function Footer() {
return ( return (
<section className='footer-wrapper'> <section className='footer-wrapper'>
<hr />
<img <img
className='footer-banner' className='footer-banner'
src='/images/footer-banner.png' src='/images/footer-banner.png'

View File

@ -1,4 +1,4 @@
import React from 'react'; import '../css/hero.css';
type HeroProps = { type HeroProps = {
imageURL?: string; imageURL?: string;
@ -10,23 +10,8 @@ export default function Hero({
heading = 'TJHSST SGA', heading = 'TJHSST SGA',
}: HeroProps) { }: HeroProps) {
return ( return (
<div className='hero relative'> <div className='hero'>
<span <span className='hero-heading'>{heading}</span>
style={{
display: 'flex',
fontSize: '4rem',
fontWeight: 'bold',
textShadow: '1px 1px rgba(48, 48, 48, 0.5)',
color: 'white',
position: 'absolute',
height: '100%',
width: '100%',
justifyContent: 'center',
alignItems: 'center',
}}
>
{heading}
</span>
<img <img
src={imageURL} src={imageURL}
alt='Background' alt='Background'

View File

@ -12,15 +12,16 @@ import Footer from './Footer';
export default function Layout({ children }: { children: React.ReactNode }) { export default function Layout({ children }: { children: React.ReactNode }) {
return ( return (
<> <div>
<div className='bg-light text-dark'> <Navbar />
<Navbar></Navbar>
<main>
{children}
<main id='page'>{children}</main>
<hr /> <hr />
<Footer /> <Footer />
</main>
</div> </div>
</>
); );
} }

View File

@ -1,4 +1,4 @@
import React from 'react'; import '../css/mission.css';
import useMission from '../hooks/useMission'; import useMission from '../hooks/useMission';
export default function Mission() { export default function Mission() {
@ -8,15 +8,11 @@ export default function Mission() {
} }
return ( return (
<section className='text-center bg-secondary text-light'> <section className='text-center'>
<div className='container mx-auto px-8 py-8'> <div className='mission-box'>
<h3 className='text-center font-bold text-3xl text-secondary mb-6'> <h3 className='header text-center'>Mission</h3>
Mission
</h3>
<p>{mission.mission}</p> <p>{mission.mission}</p>
<h3 className='text-center font-bold text-3xl text-secondary mb-6'> <h3 className='header text-center'>Vision</h3>
Vision
</h3>
<p>{mission.vision}</p> <p>{mission.vision}</p>
<blockquote>{mission.quote_text}</blockquote> <blockquote>{mission.quote_text}</blockquote>
</div> </div>

View File

@ -21,15 +21,7 @@ export default function Navbar() {
return ( return (
<div className='nav'> <div className='nav'>
<Link to='/'> <Link to='/'>
<img <img src='/images/banner.png' alt='TJ SGA' className='nav-logo' />
src='/images/banner.png'
alt='TJ SGA'
style={{
height: '2rem',
alignSelf: 'center',
margin: '1rem',
}}
/>
</Link> </Link>
{pages.map((page) => { {pages.map((page) => {
return ( return (

View File

@ -0,0 +1,16 @@
import Mission from './Mission';
import RecentNews from './RecentNews';
export default function NewsAndMission() {
return (
<div className='row'>
<div className='col flex-2'>
<RecentNews />
</div>
<div className='col flex-1'>
<Mission />
</div>
</div>
);
}

View File

@ -0,0 +1,21 @@
import useQuery from '../hooks/useInitiatives';
import ArticleRow from './ArticleRow';
export default function RecentNews() {
let news = useQuery<SGA.ArticleDocument[]>(
`*[_type == 'article'] | order (publish_date desc, title) [0...3]`
);
if (!news) {
return null;
}
return (
<div>
<h3 className='header'>Recent News</h3>
{news.map((article) => {
return <ArticleRow article={article} />;
})}
</div>
);
}

24
src/css/article.css Normal file
View File

@ -0,0 +1,24 @@
.load-more-button {
font-weight: 300;
text-transform: uppercase;
}
.article-list {
display: flex;
flex-direction: column;
}
.article-row-thumbnail {
flex: 1;
padding: 10px;
/*
To center the image
*/
display: flex;
align-items: center;
}
.article-row-content {
flex: 3;
padding: 10px;
}

View File

@ -1,6 +1,5 @@
.footer-wrapper { .footer-wrapper {
width: 100%; width: 100%;
padding: 0rem 2rem;
margin: 2rem 0rem; margin: 2rem 0rem;
} }

16
src/css/hero.css Normal file
View File

@ -0,0 +1,16 @@
.hero {
position: relative;
}
.hero-heading {
display: flex;
font-size: 4rem;
font-weight: bold;
text-shadow: 1px 1px rgba(48, 48, 48, 0.5);
color: white;
position: absolute;
height: 100%;
width: 100%;
justify-content: center;
align-items: center;
}

3
src/css/mission.css Normal file
View File

@ -0,0 +1,3 @@
.mission-box {
padding: 0px 20px;
}

View File

@ -17,3 +17,9 @@
.nav-link:hover { .nav-link:hover {
background-color: #ccc; background-color: #ccc;
} }
.nav-logo {
height: 4rem;
align-self: center;
margin: 1rem;
}

View File

@ -17,4 +17,5 @@
border-style: solid; border-style: solid;
border-color: #38A3BD; border-color: #38A3BD;
color: #38A3BD; color: #38A3BD;
display: inline-block;
} }

View File

@ -25,3 +25,12 @@ a:visited {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
} }
img {
max-width: 100%;
}
main {
width: 1200px;
margin: 0px auto;
}

View File

@ -1,26 +1,23 @@
import React from 'react'; import React from 'react';
import Hero from '../components/Hero'; import Hero from '../components/Hero';
import NewsAndMission from '../components/NewsAndMission';
import SegmentGroup from '../components/SegmentGroup'; import SegmentGroup from '../components/SegmentGroup';
import Mission from '../components/Mission';
const IndexPage = () => { const IndexPage = () => {
return ( return (
<> <>
{/* Hero image */} {/* Hero image */}
<Hero /> <Hero />
<hr />
{/* Info columns */} {/* Info columns */}
<SegmentGroup /> <SegmentGroup />
{/* Initiatives section */} <hr />
{/* <InitiativeList /> */}
{/* Mission */} {/* Mission */}
<Mission /> <NewsAndMission />
{/* News articles section */}
<section className='container mx-auto px-8 my-8'></section>
</> </>
); );
}; };

View File

@ -5,8 +5,8 @@ import Hero from '../components/Hero';
export default function News() { export default function News() {
return ( return (
<> <>
<Hero heading='News'></Hero> <Hero heading='News' />
<ArticleList></ArticleList> <ArticleList />
</> </>
); );
} }