-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 4 types : warning, error, info et success - avec ou sans icone - message personnalisable Au passage, simplifie la molecule `Loading`. Configure la taille de l'icone par rapport à la taille du texte. Supprime la notion de `inline` et le padding autour du composant.
- Loading branch information
1 parent
0905576
commit 6530eaa
Showing
10 changed files
with
150 additions
and
43 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 was deleted.
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,57 @@ | ||
import clsx from 'clsx' | ||
import React from 'react' | ||
import { AlertOctagon, CheckCircle, Info, XOctagon } from 'react-feather' | ||
|
||
import styles from './Alert.module.scss' | ||
|
||
function getIcon(type) { | ||
if (type === 'success') { | ||
return <CheckCircle color={'rgb(82, 196, 26)'} /> | ||
} | ||
if (type === 'warning') { | ||
return <AlertOctagon color={'rgb(250, 173, 20)'} /> | ||
} | ||
if (type === 'error') { | ||
return <XOctagon color={'rgb(255, 77, 79)'} /> | ||
} | ||
if (type === 'info') { | ||
return <Info color={'rgb(22, 119, 255)'} /> | ||
} | ||
return <></> | ||
} | ||
|
||
function getStyle(type) { | ||
if (type === 'success') { | ||
return styles.success | ||
} | ||
if (type === 'warning') { | ||
return styles.warning | ||
} | ||
if (type === 'error') { | ||
return styles.error | ||
} | ||
if (type === 'info') { | ||
return styles.info | ||
} | ||
return '' | ||
} | ||
|
||
/** | ||
* @typedef {Object} AlertProps | ||
* @property {string} message | ||
* @property {string=} type | ||
* @property {boolean} showIcon | ||
*/ | ||
|
||
/** | ||
* @param {AlertProps} props | ||
* @returns {React.ReactHTMLElement} | ||
*/ | ||
export default function Alert({ message, type = 'error', showIcon = true }) { | ||
const icon = showIcon ? getIcon(type) : <></> | ||
return ( | ||
<div className={clsx(styles.alert, getStyle(type))}> | ||
{icon} <span>{message}</span> | ||
</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,28 @@ | ||
.alert { | ||
display: flex; | ||
gap: 0.5rem; | ||
align-items: center; | ||
padding: 0.5rem; | ||
border: 1px solid; | ||
font-size: 0.9em; | ||
} | ||
|
||
.warning { | ||
background-color: rgb(255, 251, 230); | ||
border-color: rgb(255, 229, 143); | ||
} | ||
|
||
.info { | ||
background-color: rgb(230, 244, 255); | ||
border-color: rgb(145, 202, 255); | ||
} | ||
|
||
.success { | ||
background-color: rgb(246, 255, 237); | ||
border-color: rgb(183, 235, 143); | ||
} | ||
|
||
.error { | ||
background-color: rgb(255, 242, 240); | ||
border-color: rgb(255, 204, 199); | ||
} |
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,33 @@ | ||
import React from 'react' | ||
import clsx from 'clsx' | ||
import { Loader } from 'react-feather' | ||
|
||
import styles from './Loading.module.scss' | ||
|
||
/** | ||
* @typedef {Object} LoadingProps | ||
* @property {string=} label (default: 'Loading…') | ||
* @property {boolean=} inline (default: false) | ||
* @property {boolean=} hidden (default: false) | ||
*/ | ||
|
||
/** | ||
* @param {LoadingProps} props | ||
* @returns {React.ReactHTMLElement} | ||
*/ | ||
export default function Loading({ | ||
label = 'Loading…', | ||
size = '1rem', | ||
hidden = false, | ||
}) { | ||
return ( | ||
<div | ||
className={clsx(styles.loading)} | ||
style={{ fontSize: size }} | ||
hidden={hidden} | ||
> | ||
<Loader className={styles.icon} aria-hidden /> | ||
{label} | ||
</div> | ||
) | ||
} |
20 changes: 8 additions & 12 deletions
20
front/src/components/loading.module.scss → .../components/molecules/Loading.module.scss
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