Skip to content

Commit

Permalink
ACT-1394 Component: Alert + Prettier whole project
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Lo. committed Jul 18, 2024
1 parent 2d23908 commit 3b2e51c
Show file tree
Hide file tree
Showing 42 changed files with 633 additions and 346 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint:js": "eslint . --ext js,jsx,ts,tsx --max-warnings=5",
"lint:style": "stylelint \"**/*.css\" --fix",
"lint:fix": "npm run lint:js -- --fix",
"format": "prettier --write '{blog,docs,src,static}/**/*.{md,mdx,ts,js,tsx,jsx,json}'"
"format": "prettier --write '{blog,docs,src}/**/*.{md,mdx,ts,js,tsx,jsx,json}'"
},
"lint-staged": {
"src/**/*.{ts,js,jsx,tsx}": "npm run lint:fix",
Expand Down Expand Up @@ -50,9 +50,10 @@
"launchdarkly-js-client-sdk": "^3.3.0",
"lodash.debounce": "^4.0.8",
"node-polyfill-webpack-plugin": "^2.0.1",
"prettier": "^3.0.0",
"prettier": "^3.3.3",
"prism-react-renderer": "^2.1.0",
"react": "^18.0.0",
"react-alert": "^7.0.3",
"react-dom": "^18.0.0",
"react-dropdown-select": "^4.11.2",
"react-player": "^2.13.0",
Expand Down Expand Up @@ -112,4 +113,4 @@
"@metamask/sdk-react>@metamask/sdk>eciesjs>secp256k1": false
}
}
}
}
70 changes: 41 additions & 29 deletions src/components/Accordion/index.tsx
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>
);
}
84 changes: 84 additions & 0 deletions src/components/Alert/alert.module.scss
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;
}
6 changes: 6 additions & 0 deletions src/components/Alert/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/components/Alert/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions src/components/Alert/index.tsx
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>
);
4 changes: 4 additions & 0 deletions src/components/Alert/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/components/Alert/success.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from "react";
import styles from "./button.module.scss";

interface IButton {
onClick: VoidFunction;
children: string | React.ReactElement
onClick: VoidFunction;
children: string | React.ReactElement;
}

export default function Button({onClick, children}: IButton) {
return (
<button className={styles.button} onClick={onClick}>
{children}
</button>
);
export default function Button({ onClick, children }: IButton) {
return (
<button className={styles.button} onClick={onClick}>
{children}
</button>
);
}
2 changes: 1 addition & 1 deletion src/components/CodeTerminal/CodeTerminal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CodeTerminal = () => {
value: keys[0].id,
private: keys[0].private || "",
},
"apiKey"
"apiKey",
);
return keys.map((item) => ({
label: item.name,
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeTerminal/ControlPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ControlPanel = ({ keysOptions = [], initValues, onChange }) => {
}
if (initValues?.netName?.value === NETWORKS.PALM) {
const noEthMethods = initMethods.filter(
(method) => method.value !== "eth_maxPriorityFeePerGas"
(method) => method.value !== "eth_maxPriorityFeePerGas",
);
updatedOptions.methods = [...noEthMethods];
}
Expand Down
Empty file.
Loading

0 comments on commit 3b2e51c

Please sign in to comment.