Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(HomePage): Create Home Page #18

Merged
merged 83 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
4672a5f
Chore: add small commit to be able to turn this into draft pr
Kara-Zor-El Jul 17, 2024
3d27d52
Feat(Section Header): Make section header
Kara-Zor-El Jul 19, 2024
3c7ab6c
Merge branch 'KaraZorEl-HomePage' into KaraZorEl-SectionHeader
Kara-Zor-El Jul 19, 2024
7a37458
Feat(Section Header): Make section header (#20)
Kara-Zor-El Jul 19, 2024
db14c05
Chore(AboutUs): upload image
Kara-Zor-El Jul 19, 2024
03bfb93
Chore(Readme): Fix Readme
Kara-Zor-El Jul 19, 2024
f6afc77
Feat(Config): Add new interface to config for about us
Kara-Zor-El Jul 19, 2024
6e9811b
Feat(AboutUs): add about us page
Kara-Zor-El Jul 19, 2024
fef7668
Feat(Contact Us): Contact us section
Kara-Zor-El Jul 21, 2024
3d5e2ee
Feat(ContactUs): make email unkderline and stylize
Kara-Zor-El Jul 21, 2024
3db2c2b
Feat(ContactUs): Create Contact us component for main page (#21)
Kara-Zor-El Jul 21, 2024
1a6e114
Fix(ContactUs): Formatting
Kara-Zor-El Jul 21, 2024
ef1bce8
Fix(ContactUs): Add new text
Kara-Zor-El Jul 21, 2024
0d0ace4
Fix(HeroBanner): Change text
Kara-Zor-El Jul 21, 2024
f65413f
Fix(ContactUs): Minor adjustments
Kara-Zor-El Jul 22, 2024
fa1ede0
Fix(SectionHeader): use enum for where to align it
Kara-Zor-El Jul 22, 2024
befae66
Fix(TextSection): Change AboutUs to be a TextSection
Kara-Zor-El Jul 22, 2024
8276e85
Fix(SectionHeader): Add enum for styling
Kara-Zor-El Jul 23, 2024
24e2026
Feat(TextSection): allow HomeSection to produce multiple TextSections
Kara-Zor-El Jul 23, 2024
cf2f83b
Feat(Footer): Added footer
Kara-Zor-El Jul 23, 2024
9e8587a
Feat(Footer): Added footer (#22)
Kara-Zor-El Jul 23, 2024
e66b5f1
FIx(TextSection): Fix CSS naming
Kara-Zor-El Jul 24, 2024
83e1cb6
Feat(LatestNews): Add Latest News section to homepage
Kara-Zor-El Jul 26, 2024
faf7082
Feat(LatestNews): Add Latest News section to homepage (#23)
Kara-Zor-El Jul 26, 2024
66a0d63
Merge branch 'main' into KaraZorEl-HomePage
Kara-Zor-El Jul 27, 2024
1b90f43
Fix(SocialButton): Align center and change padding
Kara-Zor-El Jul 27, 2024
6c5083b
Merge branch 'KaraZorEl-HomePage' of https://github.com/Trent-Compute…
Kara-Zor-El Jul 27, 2024
1487255
Fix(Footer): Remove Contact us and moved to footer
Kara-Zor-El Jul 29, 2024
e67cdf5
Fix(Button): Allow button to take in an Icon
Kara-Zor-El Jul 30, 2024
85a3ff8
Fix(Button): Formatting
Kara-Zor-El Jul 30, 2024
ae0a997
Fix(Footer): Use logo component
Kara-Zor-El Jul 30, 2024
12d8310
Fix(heroBanner): Add tagline to config
Kara-Zor-El Jul 30, 2024
38e0ad7
Fix(Formatting)
Kara-Zor-El Jul 30, 2024
a157ee2
Fix(TextSection): spelling mistake
Kara-Zor-El Jul 30, 2024
75282e1
Fix(Link): Don't override global behavior
Kara-Zor-El Jul 30, 2024
c99a44c
Fix(News): Change news to be layout and make it proper
Kara-Zor-El Jul 30, 2024
ad03d54
Fix(Footer): Make buttons clickable
Kara-Zor-El Jul 30, 2024
8507cfd
FIx(SectionHeader): moving logic and changing div to span
Kara-Zor-El Jul 30, 2024
1f9e8ad
Fix(SectionHeader): Formatting
Kara-Zor-El Jul 30, 2024
26bbdd5
Fix(SectionHeader): Move to style logic
Kara-Zor-El Jul 30, 2024
dbb2636
Fix(index): change component to layout
Kara-Zor-El Jul 30, 2024
16bfb82
Fix(TextSection): Change logic to style
Kara-Zor-El Jul 30, 2024
fdb6433
FIx(LayoutNews): Fix some styling
Kara-Zor-El Jul 30, 2024
da2c84e
Fix(TextSection): remove unnecessary commented out area
Kara-Zor-El Jul 30, 2024
df93a29
Fix(Button): remove unnecessary commented out area
Kara-Zor-El Jul 30, 2024
f3e2120
Fix(TextSection): Chnage # of lines in styling
Kara-Zor-El Jul 31, 2024
7ed19f4
FIx(TextSection): reduce classname usage
Kara-Zor-El Jul 31, 2024
d3370b5
Fix(Footer): Outside of main
Kara-Zor-El Jul 31, 2024
73ba571
Fix(Index): Im just a silly girl who makes mistakes
Kara-Zor-El Jul 31, 2024
cfd14aa
Fix(NavBar): Make NavBar button have no hover
Kara-Zor-El Jul 31, 2024
c0ed316
Fix(Color-4): Change to color-3
Kara-Zor-El Jul 31, 2024
ba70510
Fix(Color): in section headers
Kara-Zor-El Jul 31, 2024
860ab59
Update config.yaml
Kara-Zor-El Jul 31, 2024
df5bbd3
Fix(TextSection): Make a Layout
Kara-Zor-El Jul 31, 2024
9281bd6
chore(home): Some quick cleanup
spotandjake Jul 31, 2024
63104c2
Fix(TextSection): Fix theming
Kara-Zor-El Aug 3, 2024
1743133
Fix(SectionHeader): Set Alignment via scss
Kara-Zor-El Aug 3, 2024
4ef9b8d
Fix(SectionHeader): formatting
Kara-Zor-El Aug 3, 2024
cdb83c7
Feat(Section): Add Section Component
Kara-Zor-El Aug 3, 2024
0f4cdc1
Fix(TextSection): Make Image size responsive
Kara-Zor-El Aug 4, 2024
0fa58e4
Fix(Button): Make image button take image
Kara-Zor-El Aug 5, 2024
771f28b
Fix(Button): Remove children props
Kara-Zor-El Aug 5, 2024
5dc6dc9
Fix(HeroBanner): Formatting
Kara-Zor-El Aug 5, 2024
14adf38
Fix(Button): Remove unneccary variable
Kara-Zor-El Aug 5, 2024
cbcb7d1
Feat(LatestNews): Refactor news section
Kara-Zor-El Aug 5, 2024
41a5722
Fix(Section): Update style logic
Kara-Zor-El Aug 5, 2024
df1deba
Chore(Section): Formatting
Kara-Zor-El Aug 5, 2024
d5ab1a9
Fix(Section): Turn turinaries into if's
Kara-Zor-El Aug 5, 2024
c8d5b3a
Chore(TextSection): Document code
Kara-Zor-El Aug 5, 2024
8a19554
Chore(Index): Add comments
Kara-Zor-El Aug 5, 2024
bc535d6
Fix(Button): Change CSS
Kara-Zor-El Aug 5, 2024
0d9baf1
Chore(Button): Move some CSS
Kara-Zor-El Aug 5, 2024
27464d3
Chore: move some CSS
Kara-Zor-El Aug 5, 2024
c448e2a
Fix(Button): Remove redundant code
Kara-Zor-El Aug 6, 2024
9ca925e
Fix(SectionHeader): fix styling
Kara-Zor-El Aug 6, 2024
275e496
Chore(SectionHeader): Add comment for header alignments
Kara-Zor-El Aug 6, 2024
c5652f4
Fix(Styling): Change names to be more dynamic
Kara-Zor-El Aug 6, 2024
c5de6f9
Feat(Section): Take Sections from config
Kara-Zor-El Aug 6, 2024
040a061
Fix(HomePage): Remove commented out bits
Kara-Zor-El Aug 6, 2024
f97119c
Fix(Section): Make colors more generic
Kara-Zor-El Aug 6, 2024
8a8f7fc
Fix(HomePage): Remove unnecessary imports
Kara-Zor-El Aug 6, 2024
9989e8e
Feat(SectionHeader): Make Rounded
Kara-Zor-El Aug 6, 2024
fbc9ca7
Fix(Various Changes): Fix a few things
Kara-Zor-El Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions components/Button.tsx
Kara-Zor-El marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import Link from 'next/link';
import styles from '../styles/Button.module.scss';
import Image from '../components/Image';

const ButtonType = {
NAVBAR: styles.navBtn,
NAVBAR_ACTIVE: [styles.navBtn, styles.active].join(' '),
LIGHT: styles.lightBtn,
SOCIAL: styles.socialBtn,
SOCIAL_DARK: styles.socialBtnDark,
} as const;

type ButtonType = (typeof ButtonType)[keyof typeof ButtonType];
Expand All @@ -16,38 +18,49 @@ interface Props {
href?: string;
className?: string;
type: ButtonType;
prefetch?: boolean;
}

interface LabelProps extends Props {
label: string;
children?: never;
image?: never;
}

interface ChildrenProps extends Props {
children: React.ReactNode;
label?: never;
interface IconProps extends Props {
image: {
src: string;
altText: string;
};
label?: string;
}

const Button: React.FC<LabelProps | ChildrenProps> = ({
label,
children,
const Button: React.FC<LabelProps | IconProps> = ({
onClick,
href,
href = '',
className,
type = ButtonType.NAVBAR,
prefetch = false,
...props
spotandjake marked this conversation as resolved.
Show resolved Hide resolved
}) => {
const classes = `${className} ${type} ${styles.button}`;
const content = label || children;
if (props.image) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one refactor here which will make things better for maintence make this:

const content = <>
  {(props.image == undefined ? <></> : <div className={styles.imageWrapper}>
        <Image src={props.image.src} alt={props.image.altText} fill={true} />
      </div>)}
      {props.label == undefined ??<></> : (<span className={styles.buttonText}>{props.label}</span>)}
</>

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we can get rid of the route this.

<Link className={classes} href={href} onClick={onClick}>
<div className={styles.imageWrapper}>
<Image src={props.image.src} alt={props.image.altText} fill={true} />
</div>
{props.label && (
<span className={styles.buttonText}>{props.label}</span>
)}
</Link>
);
}

return href ? (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we can just pass the content in down here :) which means one point of maintence.

<Link href={href} className={classes} onClick={onClick} prefetch={prefetch}>
<span> {content} </span>
<Link href={href} className={classes} onClick={onClick}>
<span>{props.label}</span>
</Link>
) : (
<button onClick={onClick} className={classes}>
{content}
{props.label}
</button>
);
};
Expand Down
41 changes: 41 additions & 0 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import styles from '../styles/components/Footer.module.scss';
import config from '../config.yaml';
import Button, { ButtonType } from '../components/Button';
import Link from 'next/link';
import { footer } from '../config.yaml';
import ReactMarkdown from 'react-markdown';
import Logo from '../components/Logo';

export default function Footer() {
return (
<footer className={styles.Footer}>
spotandjake marked this conversation as resolved.
Show resolved Hide resolved
{/* Top section */}
<div className={styles.top}>
<ReactMarkdown className={styles.text}>{footer.text}</ReactMarkdown>
</div>
{/* Left side */}
<div className={styles.left}>
<div className={styles.logo}>
<Logo />
</div>
<Link href={`mailto:${config.email}`} className={styles.link}>
{config.email}
</Link>
</div>
{/* Right side */}
<div className={styles.right}>
<div className={styles.socialMedia}>
{config.heroIcons.map((icon, index) => (
<Button
key={index}
image={{ src: icon.path, altText: icon.altText }}
type={ButtonType.SOCIAL_DARK}
href={icon.link}
className={styles.socialMedia}
/>
))}
</div>
</div>
</footer>
);
}
29 changes: 9 additions & 20 deletions components/HeroBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
// CSS
import styles from '../styles/components/HeroBanner.module.scss';
import Button, { ButtonType } from './Button';
import { heroIcons } from '../config.yaml';
import Image from '../components/Image';
import { heroIcons, tagline } from '../config.yaml';
import Logo from '../components/Logo';

interface Props {
imagePath: string;
altText: string;
}

export default function HeroBanner({ imagePath, altText }: Props) {
export default function HeroBanner() {
return (
<div className={styles.HeroBanner}>
{/* Left Column */}
<div className={styles.leftColumn}>
<Logo />
<Button type={ButtonType.LIGHT}>Apply</Button>
<Button type={ButtonType.LIGHT} label='Apply' />
</div>
{/* Right Column */}
<div className={styles.rightColumn}>
<h1>Trent Computer Science Club Association</h1>
<hr />
<div className={styles.tagline}>Where passion meets code</div>
<div className={styles.tagline}>{tagline}</div>
<div className={styles.socialMedia}>
{heroIcons.map((icon) => (
<Button key={icon.altText} type={ButtonType.SOCIAL}>
<Image
key={icon.altText}
src={icon.path}
alt={icon.altText}
width={100}
height={100}
className={styles.socialMedia}
/>
</Button>
<Button
key={icon.altText}
type={ButtonType.SOCIAL}
image={{ src: icon.path, altText: icon.altText }}
/>
))}
</div>
</div>
Expand Down
8 changes: 2 additions & 6 deletions components/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ interface LogoProps {

export default function Logo({ href = '/' }: LogoProps) {
return (
<Link href={href} className={styles.container} prefetch={true}>
<Link href={href} className={styles.container}>
<div>
<Image
src='/logo.svg'
alt='TCSCA Logo'
fill={true}
/>
<Image src='/logo.svg' alt='TCSCA Logo' fill={true} />
</div>
</Link>
);
Expand Down
5 changes: 2 additions & 3 deletions components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ export default function NavBar(props: Props) {
? ButtonType.NAVBAR_ACTIVE
: ButtonType.NAVBAR
}
>
{page.pageName}
</Button>
label={page.pageName}
/>
</li>
);
});
Expand Down
46 changes: 46 additions & 0 deletions config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,56 @@ declare module '*.yaml' {
path: string;
}

interface Footer {
text: string;
}

interface NewsItem {
text: string;
date: Date;
href: string;
}

const HomeSectionTypes = {
TextSection = 'TextSection',
LatestNews = 'LatestNews',
};

type HomeSectionType =
(typeof HomeSectionTypes)[keyof typeof HomeSectionTypes];

interface HomePageSection {
type: HomeSectionType;
header: string;
}

interface TextSection extends HomePageSection {
type: HomeSectionType.TextSection;
text: string;
image: string;
imageAlt: string;
buttonText?: string;
Kara-Zor-El marked this conversation as resolved.
Show resolved Hide resolved
buttonRoute?: string;
}

interface LatestNews extends HomePageSection {
type: HomeSectionType.LatestNews;
newsFeed: NewsItem[];
}

Kara-Zor-El marked this conversation as resolved.
Show resolved Hide resolved
type TextSectionType = (typeof TextSection)[keyof typeof TextSection];
type LatestNewsType = (typeof LatestNews)[keyof typeof LatestNews];
type HomeSection = TextSectionType | LatestNewsType;

interface Config {
pageInfo: PageInfo[];
bannerInfo: BannerInfo;
heroIcons: HeroIcon[];
homeSections: HomeSection[];
email: string;
tagline: string;
footer: Footer;
HomeSection: HomeSection;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a homeSection and a homeSections? and why is the capitalization different for this one?

}

const value: Config;
Expand Down
23 changes: 22 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pageInfo:
displayInNav: true
bannerInfo:
text: 'HACKATHON 2024, coming to Trent, [Learn More](example.com)!'
# please refer to https://react-icons.github.io/react-icons/icons/ for possible icons
heroIcons:
- altText: Link to TCSCA Instagram
link: https://www.instagram.com/trentcsca/
Expand All @@ -27,3 +26,25 @@ heroIcons:
- altText: Link to TCSCA Discord
link: https://discord.gg/serea2sPAd
path: /Icons/discord.svg
email: &contactEmail '[email protected]'
discordLink: https://discord.gg/serea2sPAd
tagline: Where innovation happens
footer:
text: Got questions or want to get involved? We'd love to hear from you! Feel free to contact us at the socials listed or by our [contact us](Contact) page. We'd love to hear from you and help you get the most out of your experience with the Trent Computer Science Club Association.
homeSections:
- type: TextSection
header: About Us
text: Welcome to the Trent Computer Science Club Association! We are a vibrant community of tech enthusiasts at Trent University, dedicated to fostering a love for technology and innovation. Our club hosts workshops, events, tech talks, and hackathons, providing a platform for students to learn, connect, and grow. Whether you're looking for coding help, career guidance, or just a place to share your passion for computer science, our club is here for you.
image: /AboutUsPlaceHolder.jpg
imageAlt: About Us Image
buttonText: Learn More
buttonRoute: /About
- type: LatestNews
header: Latest News
newsFeed:
- text: NEWS ABOUT TRENT COMPUTER SCIENCE
date: 2024-09-10
href: /
- text: NEWS ABOUT EXCITING EVENT
date: 2024-07-25
href: /
82 changes: 82 additions & 0 deletions layouts/LatestNews.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react';
import Button, { ButtonType } from '../components/Button';
import Link from 'next/link';
import styles from '../styles/layouts/LatestNews.module.scss';
import ReactMarkdown from 'react-markdown';

const NewsSectionStyle = {
primary: styles.primaryStyle,
secondary: styles.secondaryStyle,
} as const;

type NewsSectionStyleType =
(typeof NewsSectionStyle)[keyof typeof NewsSectionStyle];

interface NewsItem {
text: string;
href: string;
date: Date;
}

interface NewsSectionProps {
newsFeed: NewsItem[];
style?: NewsSectionStyleType;
}

const NewsSection: React.FC<NewsSectionProps> = ({
newsFeed,
style = NewsSectionStyle.primary,
}) => {
return (
<div className={`${styles.latestNewsLayout} ${style}`}>
{newsFeed.map((item, index) => (
<NewsItemComponent key={index} {...item} />
))}
</div>
);
};

const NewsItemComponent: React.FC<NewsItem> = ({ text, href, date }) => {
return (
<Link className={styles.newsItem} href={href}>
<div className={styles.left}>
<ReactMarkdown className={styles.title}>{text}</ReactMarkdown>
<p className={styles.date}>{formatDate(date)}</p>
</div>
<div className={styles.right}>
<Button
type={ButtonType.LIGHT}
className={styles.learnMore}
label='Learn more'
/>
</div>
</Link>
);
};

const formatDate = (date: Date): string => {
const day = date.getDate();

const getDaySuffix = (day: number): string => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no toLocale that outputs this right? Maybe check out the moment time library from npm it might have what we want. This approach isn't the best for localization imo, which is why i think a time library might be better.

If you can't find something suitable we can keep this logic so maybe only spend like 15 mins looking into moment or the default localization api's

if (day > 3 && day < 21) return 'th'; // Covers 11th, 12th, 13th, etc.
switch (day % 10) {
case 1:
return 'st';
case 2:
return 'nd';
case 3:
return 'rd';
default:
return 'th';
}
};

const [month, year] = date
.toLocaleDateString('en-US', { month: 'long', year: 'numeric' })
.split(' ');

return `${month} ${day}${getDaySuffix(day)}, ${year}`;
};

export default NewsSection;
export { NewsSectionStyle, type NewsItem, type NewsSectionProps };
Loading
Loading