Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make all code default to the current pageTheme #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/components/Code.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const ButtonCopyToClipboard = ({ text, ...props }) => {
export default function Code({
as = "div",
children,
dataTheme = "dark",
dataTheme,
language = "html",
display = "block",
allowCopy = true,
Expand All @@ -85,12 +85,14 @@ export default function Code({
const Tag = as;
const displayInline = display === "inline";

const { pageTheme } = usePage();

if (displayInline) {
return <HighlightedCode {...{ children, displayInline, language, ...props }} />;
}

return (
<Tag className={className ? `code ${className}` : "code"} data-theme={dataTheme}>
<Tag className={className ? `code ${className}` : "code"} data-theme={dataTheme || pageTheme}>
{allowCopy && <ButtonCopyToClipboard text={children.toString()} />}
<HighlightedCode {...{ children, displayInline, language, ...props }} />
</Tag>
Expand Down
4 changes: 1 addition & 3 deletions app/components/homepage/Comparison.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Code from "~/components/Code";
import { usePage } from "~/contexts/PageContext";

export default function Comparison(props) {
const { pageTheme } = usePage();
return (
<section className="comparison" {...props}>
<hgroup>
Expand All @@ -16,7 +15,7 @@ export default function Comparison(props) {
<p>
<span className="emoji">😌</span> Pico CSS
</p>
<Code language="html" allowCopy={false} dataTheme={pageTheme}>{`<form>
<Code language="html" allowCopy={false}>{`<form>
<input type="text">
<button type="submit">Action</button>
</form>`}</Code>
Expand All @@ -28,7 +27,6 @@ export default function Comparison(props) {
<Code
language="html"
allowCopy={false}
dataTheme={pageTheme}
>{`<div class="container display-flex my-md mx-sm">
<form class="form shadow-md my-md mx-sm align-center">
<div class="input-wrapper border-radius-sm">
Expand Down