An opinionated toast component for React.
Run prettier
emilkowalski8f92c6d97930
diff --git a/.eslintrc.js b/.eslintrc.jsindex 5b999ef..a2845bf 100644--- a/.eslintrc.js+++ b/.eslintrc.js@@ -1,10 +1,10 @@module.exports = {root: true,// This tells ESLint to load the config from the package `eslint-config-custom`- extends: ["custom"],+ extends: ['custom'],settings: {next: {- rootDir: ["apps/*/"],+ rootDir: ['apps/*/'],},},};diff --git a/.prettierrc.js b/.prettierrc.jsindex 1859000..8ff4ab2 100644--- a/.prettierrc.js+++ b/.prettierrc.js@@ -4,4 +4,4 @@ module.exports = {tabWidth: 2,trailingComma: 'all',printWidth: 120,-}+};diff --git a/src/assets.tsx b/src/assets.tsxindex d88f5c8..498ba61 100644--- a/src/assets.tsx+++ b/src/assets.tsx@@ -30,13 +30,7 @@ export const Loader = ({ visible }: { visible: boolean }) => {};const SuccessIcon = (- <svg- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 20 20"- fill="currentColor"- height="20"- width="20"- >+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><pathfillRule="evenodd"d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z"@@ -46,13 +40,7 @@ const SuccessIcon = ();const InfoIcon = (- <svg- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 20 20"- fill="currentColor"- height="20"- width="20"- >+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><pathfillRule="evenodd"d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z"@@ -62,13 +50,7 @@ const InfoIcon = ();const ErrorIcon = (- <svg- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 20 20"- fill="currentColor"- height="20"- width="20"- >+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><pathfillRule="evenodd"d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z"diff --git a/src/types.ts b/src/types.tsindex 16003c3..cd7b2ee 100644--- a/src/types.ts+++ b/src/types.ts@@ -34,13 +34,7 @@ export interface ToastT {className?: string;}-export type Position =- | 'top-left'- | 'top-right'- | 'bottom-left'- | 'bottom-right'- | 'top-center'- | 'bottom-center';+export type Position = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center';export interface HeightT {height: number;toastId: number;diff --git a/website/app/globals.css b/website/app/globals.cssindex 8e58576..049bc73 100644--- a/website/app/globals.css+++ b/website/app/globals.css@@ -14,11 +14,9 @@--gray12: hsl(0, 0%, 9%);--hover: rgb(40, 40, 40);--border-radius: 6px;- --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,- Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol,- Noto Color Emoji;- --font-mono: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono,- Courier New, monospace;+ --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial,+ Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;+ --font-mono: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;}::selection {@@ -127,18 +125,12 @@ code {.button:focus-visible {outline: none;box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.06), 0px 1px 0px 0px rgba(0, 0, 0, 0.08),- 0px 2px 2px 0px rgba(0, 0, 0, 0.04), 0px 3px 3px 0px rgba(0, 0, 0, 0.02),- 0px 4px 4px 0px rgba(0, 0, 0, 0.01), 0 0 0 2px rgba(0, 0, 0, 0.15);+ 0px 2px 2px 0px rgba(0, 0, 0, 0.04), 0px 3px 3px 0px rgba(0, 0, 0, 0.02), 0px 4px 4px 0px rgba(0, 0, 0, 0.01),+ 0 0 0 2px rgba(0, 0, 0, 0.15);}@media (max-width: 600px) {.buttons {- mask-image: linear-gradient(- to right,- transparent,- black 24px,- black calc(100% - 24px),- transparent- );+ mask-image: linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent);}}diff --git a/website/app/page.tsx b/website/app/page.tsxindex dc5ec6c..fc3c066 100644--- a/website/app/page.tsx+++ b/website/app/page.tsx@@ -32,12 +32,7 @@ export default function Home() {</div></main><Footer />- <Toaster- richColors={richColors}- closeButton={closeButton}- expand={expand}- position={position}- />+ <Toaster richColors={richColors} closeButton={closeButton} expand={expand} position={position} /></>);}diff --git a/website/next.config.js b/website/next.config.jsindex dafb0c8..4436b22 100644--- a/website/next.config.js+++ b/website/next.config.js@@ -3,6 +3,6 @@ const nextConfig = {experimental: {appDir: true,},-}+};-module.exports = nextConfig+module.exports = nextConfig;diff --git a/website/src/components/CodeBlock/index.tsx b/website/src/components/CodeBlock/index.tsxindex dc9bb7c..971557e 100644--- a/website/src/components/CodeBlock/index.tsx+++ b/website/src/components/CodeBlock/index.tsx@@ -45,13 +45,7 @@ const theme = {],};-export const CodeBlock = ({- children,- initialHeight = 0,-}: {- children: string;- initialHeight?: number;-}) => {+export const CodeBlock = ({ children, initialHeight = 0 }: { children: string; initialHeight?: number }) => {const [ref, bounds] = useMeasure();const [copying, setCopying] = React.useState<number>(0);@@ -69,13 +63,7 @@ export const CodeBlock = ({<MotionConfig transition={{ duration: 0.15 }}><AnimatePresence initial={false} mode="wait">{copying ? (- <motion.div- animate="visible"- exit="hidden"- initial="hidden"- key="check"- variants={variants}- >+ <motion.div animate="visible" exit="hidden" initial="hidden" key="check" variants={variants}><svgviewBox="0 0 24 24"width="14"@@ -91,13 +79,7 @@ export const CodeBlock = ({</svg></motion.div>) : (- <motion.div- animate="visible"- exit="hidden"- initial="hidden"- key="copy"- variants={variants}- >+ <motion.div animate="visible" exit="hidden" initial="hidden" key="copy" variants={variants}><svgviewBox="0 0 24 24"width="14"diff --git a/website/src/components/Hero/hero.module.css b/website/src/components/Hero/hero.module.cssindex 7205f46..778b3ee 100644--- a/website/src/components/Hero/hero.module.css+++ b/website/src/components/Hero/hero.module.css@@ -52,8 +52,7 @@flex-shrink: 0;font-family: inherit;box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.06), 0px 1px 0px 0px rgba(0, 0, 0, 0.08),- 0px 2px 2px 0px rgba(0, 0, 0, 0.04), 0px 3px 3px 0px rgba(0, 0, 0, 0.02),- 0px 4px 4px 0px rgba(0, 0, 0, 0.01);+ 0px 2px 2px 0px rgba(0, 0, 0, 0.04), 0px 3px 3px 0px rgba(0, 0, 0, 0.02), 0px 4px 4px 0px rgba(0, 0, 0, 0.01);position: relative;overflow: hidden;cursor: pointer;@@ -73,8 +72,8 @@.button:focus-visible {outline: none;box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.06), 0px 1px 0px 0px rgba(0, 0, 0, 0.08),- 0px 2px 2px 0px rgba(0, 0, 0, 0.04), 0px 3px 3px 0px rgba(0, 0, 0, 0.02),- 0px 4px 4px 0px rgba(0, 0, 0, 0.01), 0 0 0 2px rgba(0, 0, 0, 0.15);+ 0px 2px 2px 0px rgba(0, 0, 0, 0.04), 0px 3px 3px 0px rgba(0, 0, 0, 0.02), 0px 4px 4px 0px rgba(0, 0, 0, 0.01),+ 0 0 0 2px rgba(0, 0, 0, 0.15);}.button:after {diff --git a/website/src/components/Installation/index.tsx b/website/src/components/Installation/index.tsxindex 97b44e5..9984144 100644--- a/website/src/components/Installation/index.tsx+++ b/website/src/components/Installation/index.tsx@@ -31,13 +31,7 @@ export const Installation = () => {<MotionConfig transition={{ duration: 0.15 }}><AnimatePresence initial={false} mode="wait">{copying ? (- <motion.div- animate="visible"- exit="hidden"- initial="hidden"- key="check"- variants={variants}- >+ <motion.div animate="visible" exit="hidden" initial="hidden" key="check" variants={variants}><svgviewBox="0 0 24 24"width="14"@@ -53,13 +47,7 @@ export const Installation = () => {</svg></motion.div>) : (- <motion.div- animate="visible"- exit="hidden"- initial="hidden"- key="copy"- variants={variants}- >+ <motion.div animate="visible" exit="hidden" initial="hidden" key="copy" variants={variants}><svgviewBox="0 0 24 24"width="14"diff --git a/website/src/components/Other/Other.tsx b/website/src/components/Other/Other.tsxindex d562d08..e04085e 100644--- a/website/src/components/Other/Other.tsx+++ b/website/src/components/Other/Other.tsx@@ -41,7 +41,7 @@ export const Other = ({},},],- [setRichColors]+ [setRichColors],);const [activeType, setActiveType] = React.useState(allTypes[0]);diff --git a/website/src/components/Position/index.tsx b/website/src/components/Position/index.tsxindex a2abd8b..6b6d9f3 100644--- a/website/src/components/Position/index.tsx+++ b/website/src/components/Position/index.tsx@@ -1,16 +1,9 @@import { toast } from 'sonner';import { CodeBlock } from '../CodeBlock';-const positions = [- 'top-left',- 'top-center',- 'top-right',- 'bottom-left',- 'bottom-center',- 'bottom-right',-] as const;+const positions = ['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'] as const;-export type Position = typeof positions[number];+export type Position = (typeof positions)[number];export const Position = ({position: activePosition,