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

Fix GIFs not loading in production #72

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"postcss": "^8.4.30",
"prettier": "^2.7.1",
"stylelint": "^15.10.1",
"stylelint-config-sass-guidelines": "^9.0.1",
"stylelint-config-sass-guidelines": "^10.0.0",
"stylelint-order": "^5.0.0",
"typed-scss-modules": "^7.0.2"
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/leaderboard/LeaderboardRow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isSrcAGif } from '@/lib/utils';
import Image from 'next/image';
import Link from 'next/link';
import type { RefObject } from 'react';
Expand Down Expand Up @@ -37,6 +38,7 @@ const LeaderboardRow = ({
quality={10}
alt={`Profile picture for ${name}`}
className={styles.profilePicture}
unoptimized={isSrcAGif(image)}
/>
<div className={styles.nameRank}>
<span className={styles.name}>
Expand Down
7 changes: 7 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ export const getUserRank = (user: PublicProfile): string => {

return ranks[index] ?? '';
};

/**
* Checks whether an image source is a gif
* @param src - source of the image
* @returns whether or not the source is a gif
*/
export const isSrcAGif = (src: string): boolean => /\.gif($|&)/.test(src);
4 changes: 2 additions & 2 deletions src/styles/themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
--theme-text-on-surface-1: #{vars.$light-text-on-surface-1}; // dark text on sidebar
--theme-text-on-surface-2: #{vars.$light-text-on-surface-2}; // light titles on sidebar

--invert: percentage($number: 1);
--invert: math.percentage($number: 1);
}

[data-theme='dark'] {
Expand Down Expand Up @@ -78,7 +78,7 @@
--theme-text-on-surface-1: #{vars.$dark-text-on-surface-1}; // dark text on sidebar
--theme-text-on-surface-2: #{vars.$dark-text-on-surface-2}; // dark titles on sidebar

--invert: percentage($number: 1);
--invert: math.percentage($number: 1);
}

html,
Expand Down
Loading