-
-
Notifications
You must be signed in to change notification settings - Fork 24
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 #60 from GalsenDev221/dev
(FEAT) / Final `Hacktoberfest` contribution 🍂
- Loading branch information
Showing
9 changed files
with
228 additions
and
41 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
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 |
---|---|---|
@@ -1,14 +1,95 @@ | ||
import React from 'react' | ||
import React from "react"; | ||
|
||
type PropsType = { | ||
message: string | ||
interface ErrorMessageProps { | ||
message: string; | ||
title?: string; | ||
className?: string; | ||
dismissible?: boolean; | ||
onDismiss?: () => void; | ||
} | ||
|
||
const ErrorMessage = ({ message }: PropsType) => { | ||
const ErrorMessage = ({ | ||
message, | ||
title, | ||
className = "", | ||
dismissible = false, | ||
onDismiss, | ||
}: ErrorMessageProps) => { | ||
const [isVisible, setIsVisible] = React.useState(true); | ||
|
||
const handleDismiss = React.useCallback(() => { | ||
setIsVisible(false); | ||
onDismiss?.(); | ||
}, [onDismiss]); | ||
|
||
if (!isVisible) return null; | ||
|
||
return ( | ||
// TODO: this components must be redesigned | ||
<div className='text-center mt-8'>{message}</div> | ||
) | ||
} | ||
<div | ||
role="alert" | ||
className={` | ||
bg-red-50 | ||
border-l-4 | ||
border-red-500 | ||
p-4 | ||
rounded-r-lg | ||
shadow-sm | ||
my-4 | ||
relative | ||
transform | ||
transition-all | ||
duration-300 | ||
hover:shadow-md | ||
${className} | ||
`} | ||
> | ||
<div className="flex items-start"> | ||
<div className="flex-shrink-0"> | ||
<svg | ||
className="h-5 w-5 text-red-500" | ||
viewBox="0 0 20 20" | ||
fill="currentColor" | ||
> | ||
<path | ||
fillRule="evenodd" | ||
d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" | ||
clipRule="evenodd" | ||
/> | ||
</svg> | ||
</div> | ||
|
||
<div className="ml-3"> | ||
{title && ( | ||
<h3 className="text-sm font-medium text-red-800">{title}</h3> | ||
)} | ||
<div className={`text-sm text-red-700 ${title ? "mt-1" : ""}`}> | ||
{message} | ||
</div> | ||
</div> | ||
{dismissible && ( | ||
<button | ||
onClick={handleDismiss} | ||
className="absolute top-4 right-4 text-red-500 hover:text-red-700 transition-colors" | ||
aria-label="Fermer le message d'erreur" | ||
> | ||
<svg | ||
className="h-4 w-4" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
stroke="currentColor" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth={2} | ||
d="M6 18L18 6M6 6l12 12" | ||
/> | ||
</svg> | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ErrorMessage | ||
export default ErrorMessage; |
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,8 @@ | ||
<div class="flex justify-center items-center h-screen space-x-4"> | ||
<label class="inline-flex relative items-center cursor-pointer"> | ||
<input type="checkbox" value="" class="sr-only peer" /> | ||
<div | ||
class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600" | ||
></div> | ||
</label> | ||
</div> |
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,8 @@ | ||
<div class="flex justify-center items-center h-screen space-x-4"> | ||
<label class="inline-flex relative items-center cursor-pointer"> | ||
<input type="checkbox" value="" class="sr-only peer" /> | ||
<div | ||
class="w-12 h-7 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[3px] after:left-[3px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-6 after:w-6 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600" | ||
></div> | ||
</label> | ||
</div> |
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,6 @@ | ||
<div class="flex justify-center items-center h-screen space-x-4"> | ||
<label class="inline-flex relative items-center cursor-pointer"> | ||
<input type="checkbox" value="" class="sr-only peer"> | ||
<div class="w-10 h-5 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[1px] after:left-[1px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div> | ||
</label> | ||
</div> |
Oops, something went wrong.