Skip to content

Commit

Permalink
Team logos working
Browse files Browse the repository at this point in the history
  • Loading branch information
jwngr committed Jul 7, 2024
1 parent b8c7338 commit 9bb5ff2
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 31 deletions.
2 changes: 1 addition & 1 deletion website/src/components/TVNetworkLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import usaLogo from '../images/tvLogos/usa.png';
import {TVNetwork} from '../models';

function getTvNetworkLogo(network: TVNetwork) {
switch (network.toLowerCase()) {
switch (network.toUpperCase()) {
case TVNetwork.ABC:
return abcLogo;
case TVNetwork.ACCN:
Expand Down
10 changes: 0 additions & 10 deletions website/src/components/TeamLogo.jsx

This file was deleted.

17 changes: 17 additions & 0 deletions website/src/components/TeamLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';

import defaultLogo from '../images/defaultTeamLogo.png';
import {Team} from '../models';

const teamLogos = import.meta.glob('../images/teamLogos/*.png', {eager: true});

export const TeamLogo: React.FC<{
readonly team: Team;
readonly className: string;
}> = ({team, className}) => {
// TODO: Is there a less hacky way to do this? I don't want to have to import / load all images.
const logoModule = teamLogos[`../images/teamLogos/${team.abbreviation}.png`] as {default: string};
const logo = logoModule ? logoModule.default : defaultLogo;

return <img className={className} src={logo} alt={`${team.name} logo`} />;
};
2 changes: 1 addition & 1 deletion website/src/components/explorables/Victory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
VictoryVoronoiContainer,
} from 'victory';

import schedule from '../../resources/schedule';
import schedule from '../../resources/schedule.json';

import './Victory.css';

Expand Down
2 changes: 1 addition & 1 deletion website/src/components/explorables/WinPercentage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ohioStateSchedule from '../../resources/explorables/winPercentage/ohioSta
// import oldDominionSchedule from '../../resources/explorables/winPercentage/oldDominion.json';
// import texasSchedule from '../../resources/explorables/winPercentage/texas.json';
// import uscSchedule from '../../resources/explorables/winPercentage/usc.json';
import schedule from '../../resources/schedule';
import schedule from '../../resources/schedule.json';
import {LineChart} from '../charts/LineChart';
import {Note} from './Note';
import {Paragraph} from './Paragraph';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/explorables/WinPercentage_old.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as d3 from 'd3';
import _ from 'lodash';
import React, {Component} from 'react';

import schedule from '../../resources/schedule';
import schedule from '../../resources/schedule.json';
import {LineChart} from '../charts/LineChart';
// import {Tooltip} from '../charts/Tooltip';

Expand Down
2 changes: 1 addition & 1 deletion website/src/components/explorables/YardPoints.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, {Component} from 'react';
import {findDOMNode} from 'react-dom';
import TweetEmbed from 'react-tweet-embed';

import schedule from '../../resources/schedule';
import schedule from '../../resources/schedule.json';
import {Tooltip} from '../charts/Tooltip';
import {Note} from './Note';
import {Paragraph} from './Paragraph';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TotalScoreWrapper,
} from './index.styles';

const Team = ({team, ranking, record, homeOrAway}) => {
const TeamInfo = ({team, ranking, record, homeOrAway}) => {
return (
<TeamWrapper className={homeOrAway}>
<TeamImage team={team} className={homeOrAway} />
Expand All @@ -31,7 +31,7 @@ const Team = ({team, ranking, record, homeOrAway}) => {
);
};

Team.propTypes = {
TeamInfo.propTypes = {
team: PropTypes.object.isRequired,
ranking: PropTypes.number,
homeOrAway: PropTypes.string.isRequired,
Expand Down Expand Up @@ -97,11 +97,21 @@ export const TotalScore = ({game, homeTeam, awayTeam}) => {
</TotalScoreWrapper>
) : (
<TotalScoreWrapper>
<Team team={awayTeam} ranking={awayApRanking} record={awayRecord} homeOrAway="away" />
<TeamInfo
team={awayTeam}
ranking={awayApRanking}
record={awayRecord}
homeOrAway="away"
/>
<Score>
{game.score.away} - {game.score.home}
</Score>
<Team team={homeTeam} ranking={homeApRanking} record={homeRecord} homeOrAway="home" />
<TeamInfo
team={homeTeam}
ranking={homeApRanking}
record={homeRecord}
homeOrAway="home"
/>
</TotalScoreWrapper>
)
}
Expand Down
18 changes: 14 additions & 4 deletions website/src/components/gameSummary/FutureGameSummary/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
TeamWrapper,
} from './index.styles';

const Team = ({team, ranking, record, homeOrAway}) => {
const TeamInfo = ({team, ranking, record, homeOrAway}) => {
return (
<TeamWrapper className={homeOrAway}>
<TeamImage team={team} className={homeOrAway} />
Expand All @@ -37,7 +37,7 @@ const Team = ({team, ranking, record, homeOrAway}) => {
);
};

Team.propTypes = {
TeamInfo.propTypes = {
team: PropTypes.object.isRequired,
ranking: PropTypes.number,
homeOrAway: PropTypes.string.isRequired,
Expand Down Expand Up @@ -102,9 +102,19 @@ export const FutureGameSummary = ({game, homeTeam, awayTeam}) => {
</TeamsWrapper>
) : (
<TeamsWrapper>
<Team team={awayTeam} ranking={awayApRanking} record={awayRecord} homeOrAway="away" />
<TeamInfo
team={awayTeam}
ranking={awayApRanking}
record={awayRecord}
homeOrAway="away"
/>
<AtOrVersus>{atOrVs}</AtOrVersus>
<Team team={homeTeam} ranking={homeApRanking} record={homeRecord} homeOrAway="home" />
<TeamInfo
team={homeTeam}
ranking={homeApRanking}
record={homeRecord}
homeOrAway="home"
/>
</TeamsWrapper>
)
}
Expand Down
4 changes: 2 additions & 2 deletions website/src/components/gameSummary/GameSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import clone from 'lodash/clone';
import PropTypes from 'prop-types';
import React from 'react';

import schedule from '../../resources/schedule';
import teams from '../../resources/teams';
import schedule from '../../resources/schedule.json';
import teams from '../../resources/teams.json';
import {CompletedGameSummary} from './CompletedGameSummary';
import {FutureGameSummary} from './FutureGameSummary';

Expand Down
2 changes: 1 addition & 1 deletion website/src/lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import theme from '../resources/theme';
import theme from '../resources/theme.json';

export const LATEST_YEAR = 2037;
export const CURRENT_SEASON = 2022;
Expand Down
2 changes: 1 addition & 1 deletion website/src/lib/matchupHistory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';

import schedule from '../resources/schedule';
import schedule from '../resources/schedule.json';
import {CURRENT_SEASON} from './constants';

/**
Expand Down
Loading

0 comments on commit 9bb5ff2

Please sign in to comment.