Skip to content

Commit

Permalink
Merge pull request #23 from sfuosdev/fix/issue-22/image-urls
Browse files Browse the repository at this point in the history
Completes issue 22 by fixing the base path and img urls
  • Loading branch information
TommyOh0428 authored Nov 26, 2024
2 parents 4c1d5fc + 13b4a6f commit d367dda
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Resources from './components/Resources'

function App() {
return (
<Router>
<Router basename="/Website">
<div className="min-h-screen flex flex-col">
<Header />
<main className="flex-grow">
Expand Down
4 changes: 3 additions & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import { getBasePath } from '../utils/basePath';

const Header = () => {
const basePath = getBasePath();
const [menuOpen, setMenuOpen] = useState(false);

const openMenu = () => {
Expand Down Expand Up @@ -46,7 +48,7 @@ const Header = () => {

{/* Centered Club Logo */}
<Link to="/" className="flex-shrink-0 mx-auto md:flex md:mx-0">
<img src="/oslogo_transparent.svg" alt="SFU OS Dev Club Logo" className="h-10 w-10 md:h-12 md:w-12" />
<img src={`${basePath}/oslogo_transparent.svg`} alt="SFU OS Dev Club Logo" className="h-10 w-10 md:h-12 md:w-12" />
</Link>

{/* Empty Div for spacing on right side on small screens */}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Projects.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react'
import Project from './Project'
import { ProjectType } from '../interfaces/project-type'
import { getBasePath } from '../utils/basePath';

const onGoingProjectsList: ProjectType[] = [
{
Expand Down Expand Up @@ -45,6 +46,7 @@ const pastProjectsList: ProjectType[] = [
];

const Projects = () => {
const basePath = getBasePath();
const [activeTab, setActiveTab] = useState('ONGOING');

const renderProjectsList = () => {
Expand All @@ -68,7 +70,7 @@ const Projects = () => {
key={index}
title={project.title}
description={project.description}
imgURL={project.imgURL}
imgURL={`${basePath}/${project.imgURL}`}
githubURL={project.githubURL}
/>
));
Expand Down
14 changes: 8 additions & 6 deletions src/components/Teams.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useEffect, useRef, useState } from 'react';
import { getBasePath } from '../utils/basePath';

const Teams = () => {
const basePath = getBasePath();
const scrollContainerRef = useRef<HTMLDivElement | null>(null);
const [isScrolledLeft, setIsScrolledLeft] = useState(true);
const [isScrolledRight, setIsScrolledRight] = useState(false);
Expand Down Expand Up @@ -52,7 +54,7 @@ const Teams = () => {

<div className="flex flex-col justify-start sm:items-start text-center sm:text-left text-primary-light w-[250px] mb-8">
<a href="https://www.linkedin.com/in/daniel-pham-5b4873286/" target="blank_">
<img className="max-w-[250px] mb-4 rounded-lg" src="daniel-pham.png" alt="Daniel Pham" />
<img className="max-w-[250px] mb-4 rounded-lg" src={`${basePath}/daniel-pham.png`} alt="Daniel Pham" />
</a>
<h3 className="text-xl font-semibold text-white mb-1">Daniel Pham</h3>
<p className="text-primary-light mb-2">Co-President</p>
Expand All @@ -61,7 +63,7 @@ const Teams = () => {

<div className="flex flex-col justify-start sm:items-start text-center sm:text-left text-primary-light w-[250px] mb-8">
<a href="https://www.linkedin.com/in/tommy-oh-766450217/" target="blank_">
<img className="max-w-[250px] mb-4 rounded-lg" src="tommy.jfif" alt="Tommy Oh" />
<img className="max-w-[250px] mb-4 rounded-lg" src={`${basePath}/tommy.jfif`} alt="Tommy Oh" />
</a>
<h3 className="text-xl font-semibold text-white mb-1">Tommy (Kanggeon) Oh</h3>
<p className="text-primary-light mb-2">Co-President</p>
Expand All @@ -77,7 +79,7 @@ const Teams = () => {

<div className="flex flex-col justify-start sm:items-start text-center sm:text-left text-primary-light w-[250px] mb-8">
<a href="https://www.linkedin.com/in/sean-wotherspoon/" target="blank_">
<img className="max-w-[250px] mb-4 rounded-lg" src="sean.jfif" alt="Sean Wotherspoon" />
<img className="max-w-[250px] mb-4 rounded-lg" src={`${basePath}/sean.jfif`} alt="Sean Wotherspoon" />
</a>
<h3 className="text-xl font-semibold text-white mb-1">Sean Wotherspoon</h3>
<p className="text-primary-light mb-2">Director of Technology</p>
Expand All @@ -86,7 +88,7 @@ const Teams = () => {

<div className="flex flex-col justify-start sm:items-start text-center sm:text-left text-primary-light w-[250px] mb-8">
<a href="https://www.linkedin.com/in/daniel-ahn-59b649297/" target="blank_">
<img className="max-w-[250px] mb-4 rounded-lg" src="daniel-ahn.jfif" alt="Daniel Ahn" />
<img className="max-w-[250px] mb-4 rounded-lg" src={`${basePath}/daniel-ahn.jfif`} alt="Daniel Ahn" />
</a>
<h3 className="text-xl font-semibold text-white mb-1">Daniel Ahn</h3>
<p className="text-primary-light mb-2">Director of Communications</p>
Expand All @@ -96,7 +98,7 @@ const Teams = () => {

<div className="flex flex-col justify-start sm:items-start text-center sm:text-left text-primary-light w-[250px] mb-8">
<a href="https://www.linkedin.com/in/dhruvgpt/" target="blank_">
{/* <img className="max-w-[250px] mb-4 rounded-lg" src="image.png" alt="Dhruv Gupta" /> */}
{/* <img className="max-w-[250px] mb-4 rounded-lg" src={`${basePath}/dhruv-gupta.jfif`} alt="Dhruv Gupta" /> */}
<div className="w-full h-full max-w-[250px] max-h-[250px] mb-4 rounded-lg flex justify-center items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" fill="currentColor" className="bi bi-person-fill" viewBox="0 0 16 16">
<path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6"/>
Expand All @@ -110,7 +112,7 @@ const Teams = () => {

<div className="flex flex-col justify-start sm:items-start text-center sm:text-left text-primary-light w-[250px] mb-8">
<a href="https://www.linkedin.com/in/jeeya-parasbhai-khavadia-55b243239/" target="blank_">
<img className="max-w-[250px] mb-4 rounded-lg" src="jeeya.jfif" alt="Jeeya Parasbhai Khavadia" />
<img className="max-w-[250px] mb-4 rounded-lg" src={`${basePath}/jeeya.jfif`} alt="Jeeya Parasbhai Khavadia" />
</a>
<h3 className="text-xl font-semibold text-white mb-1">Jeeya Parasbhai Khavadia</h3>
<p className="text-primary-light mb-2">Director of Events</p>
Expand Down
3 changes: 3 additions & 0 deletions src/utils/basePath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const getBasePath = () => {
return import.meta.env.MODE === 'production' ? '/Website' : '';
};
11 changes: 6 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig(() => {
return {
base: '/',
plugins: [react()],
};
export default defineConfig(({ mode }) => {
const base = mode === "production" ? "/Website/" : "/";
return {
base,
plugins: [react()],
};
});

0 comments on commit d367dda

Please sign in to comment.