Skip to content

Instantly share code, notes, and snippets.

View tofazzal-shuvo's full-sized avatar

Md Tofazzal Haque tofazzal-shuvo

  • Polygon Technology
  • Dhaka
View GitHub Profile
@tofazzal-shuvo
tofazzal-shuvo / .jsx
Created June 24, 2024 07:03
Next.js 14 Image component responsiveness
// All solutions are for only image URLs. Statically imported image don't have this complexity.
<div className="grid grid-cols-3 gap-10">
{blogs.map(({ title, desc, img, id, imgUrl }) => (
<div className="text-center p-5 rounded-lg shadow-md" key={id}>
<h2>{title}</h2>
// OPTION 1: This will make the image width 100% to the container and dony by css.
<Image
// src={imgUrl}
src={img}
width={0}
import validator from "validator";
export default (name, value, required) => {
if (!value && required) {
if (name === "email") return { [name]: "Email can't be empty!" };
else if (name === "password") return { [name]: "Password can't be empty!" };
} else {
if (name === "password" && value.length < 6)
return { [name]: "Password can't be less then 6 character!" };
else if (name === "email" && !validator.isEmail(value))
import validator from "validator";
export default (name, value, required) => {
if (!value && required) {
if (name === "email") return { [name]: "Email can't be empty!" };
else if (name === "password") return { [name]: "Password can't be empty!" };
} else {
if (name === "password" && value.length < 6)
return { [name]: "Password can't be less then 6 character!" };
else if (name === "email" && !validator.isEmail(value))
import validator from "validator";
export default (name, value, required) => {
if (!value && required) {
if (name === "email") return { [name]: "Email can't be empty!" };
else if (name === "password") return { [name]: "Password can't be empty!" };
} else {
if (name === "password" && value.length < 6)
return { [name]: "Password can't be less then 6 character!" };
else if (name === "email" && !validator.isEmail(value))
import validator from "validator";
export default (name, value, required) => {
if (!value && required) {
if (name === "email") return { [name]: "Email can't be empty!" };
else if (name === "password") return { [name]: "Password can't be empty!" };
} else {
if (name === "password" && value.length < 6)
return { [name]: "Password can't be less then 6 character!" };
else if (name === "email" && !validator.isEmail(value))