-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from quynh-linh/linhdev
Update code
- Loading branch information
Showing
9 changed files
with
545 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use client'; | ||
|
||
import clsx from 'clsx'; | ||
import React from 'react'; | ||
|
||
interface HtmlParserProps extends React.HTMLAttributes<HTMLDivElement> { | ||
className?: string; | ||
data?: string; | ||
} | ||
|
||
export default function HtmlParser({ className, data, ...props }: HtmlParserProps) { | ||
if (!data) return <></>; | ||
|
||
return ( | ||
<div | ||
className={clsx( | ||
'prose-a:text-[#1381BE] prose-a:font-normal prose-a:no-underline prose-ul:list-disc prose-ul:text-justify', | ||
className, | ||
)} | ||
{...props} | ||
dangerouslySetInnerHTML={{ | ||
__html: data, | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ImageNext, { ImageProps as NextImageProps } from 'next/image'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
// Extend the props from next/image and add any additional custom props if necessary | ||
interface ImageProps extends Omit<NextImageProps, 'ref'> { | ||
src: string; // Ensure that `src` is a required string | ||
} | ||
|
||
// Create the component using forwardRef | ||
const Image = forwardRef<HTMLElement, ImageProps>(({ src, ...props }, ref) => { | ||
return <ImageNext src={src} {...props} ref={ref as any} />; | ||
}); | ||
|
||
// Set the display name for better debugging | ||
Image.displayName = 'Image'; | ||
|
||
export default Image; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Image } from './Image'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use client'; | ||
|
||
import clsx from 'clsx'; | ||
import Image from '../Image/Image'; | ||
|
||
interface ImageResponsiveProps { | ||
desktop?: string; | ||
mobile?: string; | ||
className?: string; | ||
classNameMobile?: string; | ||
priority?: boolean; | ||
[key: string]: any; // Additional props | ||
} | ||
|
||
export default function ImageResponsive({ | ||
desktop, | ||
mobile, | ||
className, | ||
classNameMobile, | ||
priority, | ||
...props | ||
}: ImageResponsiveProps) { | ||
if (!desktop && !mobile) return <></>; | ||
|
||
return ( | ||
<div> | ||
{mobile || desktop ? ( | ||
<Image | ||
className={clsx(classNameMobile, `!block lg:!hidden w-full h-full object-cover`)} | ||
src={(mobile || desktop) || ''} | ||
alt='Image' | ||
fill | ||
priority={priority} | ||
{...props} | ||
/> | ||
) : null} | ||
|
||
{desktop ? ( | ||
<Image | ||
className={clsx(className, desktop && '!hidden lg:!block w-full h-full object-cover')} | ||
src={desktop} | ||
alt='Image' | ||
fill | ||
priority={priority} | ||
{...props} | ||
/> | ||
) : null} | ||
</div> | ||
); | ||
} |