Skip to content

Commit

Permalink
feat: first pass at callout component
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinperaza committed Dec 8, 2022
1 parent ab9cf17 commit be239d6
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 0 deletions.
67 changes: 67 additions & 0 deletions src/components/shared/Callout.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.container {
display: flex;
padding: 10px 15px 10px 15px;
gap: 12px;
border-radius: 4px;
margin: 15px 0;
}

.content {
margin: 0;
text-align: justify;
}

.error {
background: linear-gradient(
90deg,
rgba(245, 108, 157, 0.2) 0.78%,
rgba(245, 108, 157, 0.05) 41.41%
);

border: 1px solid rgba(245, 108, 157, 0.3);
}

.warning {
background: linear-gradient(
90deg,
rgba(255, 167, 38, 0.2) 0.78%,
rgba(255, 167, 38, 0.05) 41.41%
);
border: 1px solid rgba(255, 167, 38, 0.3);
color: #ffa726;
}

.info {
background: linear-gradient(
90deg,
rgba(41, 182, 246, 0.2) 0.78%,
rgba(41, 182, 246, 0.05) 41.41%
);
border: 1px solid rgba(2, 136, 209, 0.3);
color: #0288d1;
}

.success {
background: linear-gradient(
90deg,
rgba(0, 182, 138, 0.2) 0.78%,
rgba(0, 182, 138, 0.05) 41.41%
);
border: 1px solid rgba(2, 136, 209, 0.3);
color: #00b68a;
}

.title {
font-style: normal;
font-weight: 500;
font-size: 16px;
line-height: 130%;
letter-spacing: 0.15px;
margin-bottom: 10px;
}

.svg {
width: 25px;
height: 25px;
margin-right: 15px;
}
55 changes: 55 additions & 0 deletions src/components/shared/Callout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import clsx from "clsx";
import React, { PropsWithChildren } from "react";

import styles from "./Callout.module.css";

import error from "@site/static/img/callout/error.svg";
import warning from "@site/static/img/callout/warning.svg";
import success from "@site/static/img/callout/success.svg";
import info from "@site/static/img/callout/info.svg";

export enum Callouts {
ERROR = "error",
WARNING = "warning",
INFO = "info",
SUCCESS = "success",
}

interface Callout {
type: Callouts;
title: string;
content: string;
}

export const Callout = ({
type,
title,
content,
children,
}: PropsWithChildren<Callout>) => {
const containerClass = clsx({
[styles.error]: type == Callouts.ERROR,
[styles.warning]: type == Callouts.WARNING,
[styles.info]: type == Callouts.INFO,
[styles.success]: type == Callouts.SUCCESS,
});

const Svg = {
[Callouts.ERROR]: error,
[Callouts.WARNING]: warning,
[Callouts.INFO]: info,
[Callouts.SUCCESS]: success,
}[type];

return (
<div className={clsx([styles.container, containerClass])}>
<div>
<Svg className={styles.svg} />
</div>
<div>
{title && <p className={styles.title}>{title}</p>}
<p className={styles.content}>{content ?? children}</p>
</div>
</div>
);
};
3 changes: 3 additions & 0 deletions static/img/callout/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions static/img/callout/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 static/img/callout/success.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 static/img/callout/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit be239d6

Please sign in to comment.