Skip to content

Commit

Permalink
vite fixes and performance optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
jekrch committed Jun 25, 2024
1 parent f621978 commit 4dbf3f8
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 86 deletions.
1 change: 1 addition & 0 deletions dist/assets/IntroColumn-C1CURhup.js

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

1 change: 0 additions & 1 deletion dist/assets/index-CdX9zOuz.css

This file was deleted.

1 change: 1 addition & 0 deletions dist/assets/index-Di97Rn61.css

Large diffs are not rendered by default.

130 changes: 65 additions & 65 deletions dist/assets/index-CDYCwPbm.js → dist/assets/index-fm0Aj39Z.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

<link rel="manifest" href="/manifest.json" />
<title>Eurovision Ranker</title>
<script type="module" crossorigin src="/assets/index-CDYCwPbm.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CdX9zOuz.css">
<script type="module" crossorigin src="/assets/index-fm0Aj39Z.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Di97Rn61.css">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
6 changes: 0 additions & 6 deletions postcss.config.js

This file was deleted.

10 changes: 10 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ const App: React.FC = () => {
const [isOverlayExit, setIsOverlayExit] = useState(false);
const [runTour, setRunTour] = useState(false);

const loadAuroralCSS = () => {
return import('./auroral.css');
};

useEffect(() => {
if (theme.includes('ab')) {
loadAuroralCSS();
}
}, [theme]);

/**
* Determines whether any rankings are set in the url
* @returns
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/MainModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const MainModal: React.FC<MainModalProps> = (props: MainModalProps) => {
target="_blank"
rel="noopener noreferrer"
href="https://github.com/jekrch/eurovision-ranker/releases"
>v3.6</a>
>v3.6.1</a>
</span>
<span className="text-right">
{`Copyright (c) 2023${new Date().getFullYear()?.toString() !== '2023' ? '-' + new Date().getFullYear() : ''} `}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ranking/IntroColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faHouseUser, faHeart, faList, faGlasses } from '@fortawesome/free-solid-svg-icons';

type IntroColumnProps = {
export type IntroColumnProps = {
openModal: (tabName: string) => void;
openConfigModal: (tabName: string) => void;
setRunTour: (runTour: boolean) => void;
};

const IntroColumn: React.FC<IntroColumnProps> = ({ openModal, openConfigModal, setRunTour }) => {
return (
<div className="flex justify-left items-center ">
<div className="flex justify-left items-center">
<div className="text-gray-400 font-normal tracking-tight font-sans text-italic text-left ml-7 m-4 text-xs whitespace-normal max-w-[10em] mt-3">
<ol className="list-disc mb-7">
<li className="mb-3">Drag countries into this column to rank</li>
Expand Down
22 changes: 22 additions & 0 deletions src/components/ranking/IntroColumnWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { Suspense, useEffect, useState } from 'react';
import { IntroColumnProps } from './IntroColumn';

const LazyIntroColumn = React.lazy(() => import('./IntroColumn'));

export const IntroColumnWrapper: React.FC<IntroColumnProps> = (props) => {
const [introColumnLoaded, setIntroColumnLoaded] = useState(false);

useEffect(() => {
setIntroColumnLoaded(true);
}, []);

return (
<Suspense fallback={<div className="w-[10em]"/>}>
{introColumnLoaded ? (
<LazyIntroColumn {...props} />
) : (
<div>Loading...</div>
)}
</Suspense>
);
};
8 changes: 4 additions & 4 deletions src/components/ranking/RankedCountriesList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useEffect, useState } from 'react';
import React, { Suspense, useEffect, useState } from 'react';
import { Draggable } from 'react-beautiful-dnd';
import { StrictModeDroppable } from './StrictModeDroppable';
import classNames from 'classnames';
import { CountryContestant } from '../../data/CountryContestant';
import { Card } from './Card';
import { DetailsCard } from './DetailsCard';
import RankedItemsHeader from './RankedItemsHeader';
import IntroColumn from './IntroColumn';
import { FaChevronRight } from 'react-icons/fa';
import IconButton from '../IconButton';
import { useDispatch, useSelector } from 'react-redux';
Expand All @@ -17,6 +16,7 @@ import { supportedYears } from '../../data/Contestants';
import { generateYoutubePlaylistUrl } from '../../utilities/YoutubeUtil';
import { removeCountryFromUrlCategoryRankings } from '../../utilities/CategoryUtil';
import { updateUrlFromRankedItems } from '../../utilities/UrlUtil';
import { IntroColumnWrapper } from './IntroColumnWrapper';

interface RankedCountriesListProps {
openSongModal: (countryContestant: CountryContestant) => void;
Expand Down Expand Up @@ -52,7 +52,7 @@ const RankedCountriesList: React.FC<RankedCountriesListProps> = ({
const unrankedItems = useSelector((state: AppState) => state.unrankedItems);
const categories = useSelector((state: AppState) => state.categories);
const activeCategory = useSelector((state: AppState) => state.activeCategory);

/**
* used to synchronize the horizontal scrollbar on detail cards across all ranked items
*/
Expand Down Expand Up @@ -146,7 +146,7 @@ const RankedCountriesList: React.FC<RankedCountriesListProps> = ({
)}
>
{rankedItems.length === 0 && showUnranked && (
<IntroColumn
<IntroColumnWrapper
openModal={openModal}
openConfigModal={openConfigModal}
setRunTour={setRunTour}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ranking/UnrankedCountriesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const UnrankedCountriesList: React.FC = ({
const unrankedItems = useSelector((state: AppState) => state.unrankedItems);

return (
<div className="max-w-[50vw] overflow-y-auto flex-grow mr-1">
<div className="min-w-[10em] max-w-[50vw] overflow-y-auto flex-grow mr-1">
<StrictModeDroppable droppableId="unrankedItems" key={`strict-md`}>
{(provided) => (
<ul
Expand Down
4 changes: 4 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,14 @@ code {
}

.pulse-on-load:hover {
transform-origin: center center;
will-change: transform;
animation: pulse 1s ease-in-out infinite;
}

.pulse-on-load {
transform-origin: center center;
will-change: transform;
animation: pulse 1s ease-in-out 2;
}

Expand Down
6 changes: 4 additions & 2 deletions src/utilities/UrlUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ vi.mock('./ContestantRepository', () => ({
fetchCountryContestantsByYear: vi.fn()
}));



function mockWindowLocationSearch(search: string) {
Object.defineProperty(window, 'location', {
value: {
Expand All @@ -26,8 +28,8 @@ function mockWindowLocationSearch(search: string) {
// reset window.location to its original state after each test
afterEach(() => {

const dom = new JSDOM();
global.navigator = dom.window.navigator;
// const dom = new JSDOM();
// global.navigator = dom.window.navigator;

vi.restoreAllMocks();
});
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/export/ExportUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('convertToJSON', () => {
describe('copyDataToClipboard', () => {
beforeEach(() => {
const dom = new JSDOM();
global.navigator = dom.window.navigator;
//global.navigator = dom.window.navigator;
});

it('copies text to clipboard', async () => {
Expand Down
14 changes: 13 additions & 1 deletion vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import postcss from 'postcss';
import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer';

export default defineConfig({
// depending on your application, base can also be "/"
Expand All @@ -17,5 +20,14 @@ export default defineConfig({
environment: 'jsdom',
setupFiles: './src/setupTests.ts',
},

css: {
postcss: {
plugins: [
postcss([
tailwindcss(),
autoprefixer(),
]),
],
},
},
})

0 comments on commit 4dbf3f8

Please sign in to comment.