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

Enhancement: Replace <img> tags with Next.js Image Component #824 #985

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 7 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
es2021: true,
node: true,
browser: true,
"cypress/globals": true
'cypress/globals': true,
},
settings: {
react: {
Expand Down Expand Up @@ -34,7 +34,10 @@ module.exports = {

'react/jsx-curly-spacing': ['error', { when: 'never', children: true }],
indent: ['error', 2, { SwitchCase: 1 }],
'linebreak-style': ['error', process.platform === 'win32' ? 'windows' : 'unix'],
'linebreak-style': [
'error',
process.platform === 'win32' ? 'windows' : 'unix',
],
quotes: ['error', 'single'],

'jsx-quotes': ['error', 'prefer-single'],
Expand All @@ -53,7 +56,8 @@ module.exports = {
'keyword-spacing': ['error', { before: true, after: true }],
'comma-spacing': ['error', { before: false, after: true }],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'@next/next/no-img-element': 'off',
// Change this rule from 'off' to 'error'
Copy link
Member

Choose a reason for hiding this comment

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

What is the need of this comment? This PR does change it to 'error'.

'@next/next/no-img-element': 'error',
'no-multi-spaces': 'error',
'space-infix-ops': 'error',
'space-before-blocks': 'error',
Expand Down
10 changes: 8 additions & 2 deletions components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import Link from 'next/link';
import TextTruncate from 'react-text-truncate';
import Image from 'next/image';
export interface CardProps {
title: string;
body: string;
Expand Down Expand Up @@ -36,13 +37,18 @@ const CardBody = ({
<div className='group relative h-full w-full rounded-lg border border-gray-200 bg-white p-6 px-12 shadow-3xl dark:shadow-2xl dark:shadow-slate-900 transition-colors ease-in-out hover:bg-slate-100 dark:bg-slate-800 hover:dark:bg-slate-900/30'>
<div className='flex justify-center '>
{image && (
<img src={image} className='h-32 p-2' data-test='card-image' />
<Image
src={image}
alt={title}
className='h-32 p-2'
data-test='card-image'
/>
)}
</div>
<div className='flex flex-row items-start mb-6'>
{icon && (
<span className='mr-6 flex h-14 w-14 flex-shrink-0 items-center justify-center rounded-lg border bg-blue-200 px-3 text-gray-900 dark:text-white'>
<img
<Image
src={icon}
alt={title}
className='h-full w-full'
Expand Down
9 changes: 5 additions & 4 deletions components/DarkModeToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useTheme } from 'next-themes';
import { useEffect, useState } from 'react';
import React from 'react';
import Image from 'next/image';

function ListItem({
children,
Expand Down Expand Up @@ -52,7 +53,7 @@ export default function DarkModeToggle() {
className='dark-mode-toggle rounded-md dark:hover:bg-gray-700 p-1.5 hover:bg-gray-100 transition duration-150 '
data-test='dark-mode-toggle'
>
<img
<Image
src={activeThemeIcon}
alt='Dark Mode'
width={25}
Expand All @@ -77,7 +78,7 @@ export default function DarkModeToggle() {
onClick={() => setTheme('system')}
data-test='select-system-theme'
>
<img
<Image
src={'/icons/theme-switch.svg'}
alt='System theme'
width={18}
Expand All @@ -90,7 +91,7 @@ export default function DarkModeToggle() {
onClick={() => setTheme('light')}
data-test='select-light-theme'
>
<img
<Image
src={'/icons/sun.svg'}
alt='System theme'
width={18}
Expand All @@ -103,7 +104,7 @@ export default function DarkModeToggle() {
onClick={() => setTheme('dark')}
data-test='select-dark-theme'
>
<img
<Image
src={'/icons/moon.svg'}
alt='System theme'
width={18}
Expand Down
Loading
Loading