-
-
Notifications
You must be signed in to change notification settings - Fork 943
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACT-1394 Component: Alert + Prettier whole project
- Loading branch information
Vlad Lo.
committed
Jul 18, 2024
1 parent
2d23908
commit 3b2e51c
Showing
42 changed files
with
633 additions
and
346 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,57 @@ | ||
import React, {useState} from "react"; | ||
import React, { useState } from "react"; | ||
import clsx from "clsx"; | ||
import styles from "./accordion.module.scss"; | ||
import CloseImg from './close.svg' | ||
import Text from '@site/src/components/Text' | ||
import CloseImg from "./close.svg"; | ||
import Text from "@site/src/components/Text"; | ||
|
||
interface IAccordion { | ||
children: string | React.ReactElement; | ||
children: string | React.ReactElement; | ||
} | ||
|
||
export default function Accordion({children}: IAccordion) { | ||
const [isOpened, setIsOpened] = useState(true); | ||
export default function Accordion({ children }: IAccordion) { | ||
const [isOpened, setIsOpened] = useState(true); | ||
|
||
const handleClose = () => { | ||
setIsOpened(value => !value) | ||
} | ||
const handleClose = () => { | ||
setIsOpened((value) => !value); | ||
}; | ||
|
||
const [title, ...body] = Array.isArray(children) ? children : [children] | ||
const [title, ...body] = Array.isArray(children) ? children : [children]; | ||
|
||
return ( | ||
<div className={styles.accordion}> | ||
<div className={styles.header}> | ||
{title} | ||
<span role="button" onClick={handleClose} className={styles.closeButton}> | ||
<CloseImg className={clsx(styles.image, isOpened && styles.opened)}/> | ||
</span> | ||
</div> | ||
<div className={clsx(styles.content, isOpened && styles.opened)}> | ||
{body} | ||
</div> | ||
</div> | ||
); | ||
return ( | ||
<div className={styles.accordion}> | ||
<div className={styles.header}> | ||
{title} | ||
<span | ||
role="button" | ||
onClick={handleClose} | ||
className={styles.closeButton} | ||
> | ||
<CloseImg className={clsx(styles.image, isOpened && styles.opened)} /> | ||
</span> | ||
</div> | ||
<div className={clsx(styles.content, isOpened && styles.opened)}> | ||
{body} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export function AccordionHeader({children}: { children: React.ReactElement }) { | ||
return <Text as='h3' className={styles.accordionHeader}> | ||
{children} | ||
export function AccordionHeader({ | ||
children, | ||
}: { | ||
children: React.ReactElement; | ||
}) { | ||
return ( | ||
<Text as="h3" className={styles.accordionHeader}> | ||
{children} | ||
</Text> | ||
); | ||
} | ||
|
||
export function AccordionBody({children}: { children: React.ReactElement }) { | ||
return <Text as='p' className={styles.accordionContainer}> | ||
{children} | ||
export function AccordionBody({ children }: { children: React.ReactElement }) { | ||
return ( | ||
<Text as="p" className={styles.accordionContainer}> | ||
{children} | ||
</Text> | ||
); | ||
} |
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,84 @@ | ||
:root[data-theme='dark'] { | ||
--alert-error-background: rgb(53, 40, 41); | ||
--alert-error-border: #E06470; | ||
--alert-success-background: rgb(34, 48, 36); | ||
--alert-success-border: #28A745; | ||
--alert-info-background: rgb(61, 57, 43); | ||
--alert-info-border: #FFDF70; | ||
} | ||
|
||
:root[data-theme='light'] { | ||
--alert-error-background: rgb(248, 235, 237); | ||
--alert-error-border: #D73847; | ||
--alert-success-background: rgb(234, 242, 235); | ||
--alert-success-border: #1C8234; | ||
--alert-info-background: rgb(247, 238, 231); | ||
--alert-info-border: #BF5208; | ||
} | ||
|
||
.alert { | ||
padding: 8px 36px; | ||
border-radius: 4px; | ||
border-left: 4px solid; | ||
position: relative; | ||
width: 80vw; | ||
|
||
&.info { | ||
border-color: var(--alert-info-border); | ||
background-color: var(--alert-info-background); | ||
|
||
.icon { | ||
color: var(--alert-info-border) | ||
} | ||
} | ||
|
||
&.success { | ||
border-color: var(--alert-success-border); | ||
background-color: var(--alert-success-background); | ||
|
||
.icon { | ||
color: var(--alert-success-border) | ||
} | ||
} | ||
|
||
&.error { | ||
border-color: var(--alert-error-border); | ||
background-color: var(--alert-error-background); | ||
|
||
.icon { | ||
color: var(--alert-error-border) | ||
} | ||
} | ||
|
||
.icon { | ||
position: absolute; | ||
left: 5px; | ||
top: 8px; | ||
} | ||
|
||
.closeButton { | ||
cursor: pointer; | ||
display: block; | ||
height: 16px; | ||
line-height: 1; | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
|
||
.closeIcon { | ||
min-width: 16px; | ||
width: 16px; | ||
min-height: 16px; | ||
height: 16px; | ||
} | ||
} | ||
} | ||
|
||
.alertTitle { | ||
font-weight: 500 !important; | ||
margin: 0; | ||
} | ||
|
||
.alertText { | ||
margin: 0; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,59 @@ | ||
import React from "react"; | ||
import { positions, types } from "react-alert"; | ||
import styles from "./alert.module.scss"; | ||
import clsx from "clsx"; | ||
import CloseImg from "./close.svg"; | ||
import InfoImg from "./info.svg"; | ||
import SuccessImg from "./success.svg"; | ||
import ErrorImg from "./error.svg"; | ||
import Text from "@site/src/components/Text"; | ||
|
||
export const options = { | ||
position: positions.TOP_CENTER, | ||
timeout: 10000, | ||
offset: "5px", | ||
containerStyle: { | ||
zIndex: 1000, | ||
marginTop: 60, | ||
}, | ||
}; | ||
|
||
export const AlertTemplate = ({ style, options, message, close }) => ( | ||
<div | ||
style={style} | ||
className={clsx( | ||
styles.alert, | ||
options.type === types.INFO && styles.info, | ||
options.type === types.SUCCESS && styles.success, | ||
options.type === types.ERROR && styles.error, | ||
)} | ||
> | ||
{options.type === types.INFO && <InfoImg className={styles.icon} />} | ||
{options.type === types.SUCCESS && <SuccessImg className={styles.icon} />} | ||
{options.type === types.ERROR && <ErrorImg className={styles.icon} />} | ||
{message} | ||
<span role="button" onClick={close} className={styles.closeButton}> | ||
<CloseImg className={styles.closeIcon} /> | ||
</span> | ||
</div> | ||
); | ||
|
||
export const AlertTitle = ({ | ||
children, | ||
}: { | ||
children: string | React.ReactElement; | ||
}) => ( | ||
<Text as="p" className={styles.alertTitle}> | ||
{children} | ||
</Text> | ||
); | ||
|
||
export const AlertText = ({ | ||
children, | ||
}: { | ||
children: string | React.ReactElement; | ||
}) => ( | ||
<Text as="p" className={styles.alertText}> | ||
{children} | ||
</Text> | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Empty file.
Oops, something went wrong.