From 2162e9d5633395e975cff63b412189122df247fb Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Thu, 20 Jan 2022 10:38:18 -0500 Subject: [PATCH] properly merge multiple class names --- components/CodeBlock/CodeBlock.module.css | 16 +++++++++++++++- components/CodeBlock/CodeBlock.tsx | 7 ++++--- components/ContactForm/ContactForm.tsx | 2 +- components/CopyButton/CopyButton.module.css | 11 ----------- components/CopyButton/CopyButton.tsx | 5 +++-- components/Heading/Heading.tsx | 3 ++- components/Menu/Menu.tsx | 9 +++++---- components/NoteMeta/NoteMeta.tsx | 9 +++++---- components/ThemeToggle/ThemeToggle.tsx | 13 +++++++++---- components/Video/Video.tsx | 6 +++--- 10 files changed, 47 insertions(+), 34 deletions(-) diff --git a/components/CodeBlock/CodeBlock.module.css b/components/CodeBlock/CodeBlock.module.css index aadcb7de..c4b711b7 100644 --- a/components/CodeBlock/CodeBlock.module.css +++ b/components/CodeBlock/CodeBlock.module.css @@ -1,6 +1,7 @@ /* all code */ .code { font-size: 0.925em; + tab-size: 2; page-break-inside: avoid; border: 1px solid var(--kinda-light); } @@ -16,13 +17,26 @@ margin: 1em auto; } +.block .copy_btn { + position: absolute; + top: 0; + right: 0; + padding: 0.65em; + color: var(--medium-dark); + background-color: var(--background-inner); + border: 1px solid var(--kinda-light); +} + +.block .copy_btn:hover { + color: var(--link); +} + /* the following sub-classes MUST be global -- the highlight rehype plugin isn't aware of this file */ .block :global(.code-highlight) { display: block; overflow-x: auto; padding: 1em; - tab-size: 2; color: var(--code-text); background-color: var(--code-background); } diff --git a/components/CodeBlock/CodeBlock.tsx b/components/CodeBlock/CodeBlock.tsx index ea86f1f7..ea441578 100644 --- a/components/CodeBlock/CodeBlock.tsx +++ b/components/CodeBlock/CodeBlock.tsx @@ -1,3 +1,4 @@ +import classNames from "classnames"; import CopyButton from "../CopyButton/CopyButton"; import type { ReactNode } from "react"; @@ -13,15 +14,15 @@ const CodeBlock = (props: Props) => { // full multi-line code blocks with prism highlighting and copy-to-clipboard button return (
- - + + {props.children}
); } else { // inline code in paragraphs, headings, etc. (not highlighted) - return {props.children}; + return {props.children}; } }; diff --git a/components/ContactForm/ContactForm.tsx b/components/ContactForm/ContactForm.tsx index 990eba4b..8c68c59a 100644 --- a/components/ContactForm/ContactForm.tsx +++ b/components/ContactForm/ContactForm.tsx @@ -160,7 +160,7 @@ const ContactForm = () => { Sending... ) : ( <> - Send + Send )} diff --git a/components/CopyButton/CopyButton.module.css b/components/CopyButton/CopyButton.module.css index a0617595..56a420fe 100644 --- a/components/CopyButton/CopyButton.module.css +++ b/components/CopyButton/CopyButton.module.css @@ -1,19 +1,8 @@ .copy { - position: absolute; - top: 0; - right: 0; - padding: 0.65em; line-height: 1; - color: var(--medium-dark); - background-color: var(--background-inner); - border: 1px solid var(--kinda-light); cursor: pointer; } -.copy:hover { - color: var(--link); -} - .success { color: var(--success) !important; } diff --git a/components/CopyButton/CopyButton.tsx b/components/CopyButton/CopyButton.tsx index 600e37c4..749d36ec 100644 --- a/components/CopyButton/CopyButton.tsx +++ b/components/CopyButton/CopyButton.tsx @@ -11,9 +11,10 @@ const cx = classNames.bind(styles); type Props = { source: ReactNode; timeout?: number; + className?: string; }; -const CopyButton = ({ source, timeout = 2000 }: Props) => { +const CopyButton = ({ source, timeout = 2000, className }: Props) => { const [copied, setCopied] = useState(false); const handleCopy = (e) => { @@ -43,7 +44,7 @@ const CopyButton = ({ source, timeout = 2000 }: Props) => { return ( ); }; diff --git a/components/Video/Video.tsx b/components/Video/Video.tsx index a405bd45..f61b9b2c 100644 --- a/components/Video/Video.tsx +++ b/components/Video/Video.tsx @@ -27,9 +27,9 @@ const Video = ({ webm, mp4, thumbnail, subs, autoplay }: Props) => { attributes: { controlsList: "nodownload", preload: "metadata", - autoPlay: autoplay, - muted: autoplay, - loop: autoplay, + autoPlay: !!autoplay, + muted: !!autoplay, + loop: !!autoplay, }, }, };