Skip to content

Commit

Permalink
Title prop
Browse files Browse the repository at this point in the history
  • Loading branch information
pomber committed Jan 23, 2023
1 parent d116f54 commit e0daac1
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-plums-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bright": patch
---

Add title prop
4 changes: 2 additions & 2 deletions lib/src/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export async function Code({
color: activeTabForeground,
}}
>
<span
<code
style={{
background: activeTabBackground,
color: activeTabForeground,
Expand All @@ -132,7 +132,7 @@ export async function Code({
}}
>
{filename}
</span>
</code>
</div>
)}
<pre
Expand Down
5 changes: 5 additions & 0 deletions lib/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type CodeProps = {
lineNumbers?: boolean
unstyled?: boolean
theme?: BrightTheme
title?: string
}

type CodeComponent = ((props: CodeProps) => Promise<JSX.Element>) & {
Expand All @@ -36,6 +37,7 @@ export const Code: CodeComponent = async ({
titleClassName,
lineNumbers,
unstyled,
title,
theme,
}) => {
const finalTheme = theme || Code.theme
Expand All @@ -57,6 +59,7 @@ export const Code: CodeComponent = async ({
unstyled={unstyled}
theme={darkTheme}
scheme="dark"
title={title}
/>
{/* @ts-expect-error Server Component */}
<InnerCode
Expand All @@ -70,6 +73,7 @@ export const Code: CodeComponent = async ({
unstyled={unstyled}
theme={lightTheme}
scheme="light"
title={title}
/>
</>
)
Expand All @@ -86,6 +90,7 @@ export const Code: CodeComponent = async ({
lineNumbers={lineNumbers}
unstyled={unstyled}
theme={finalTheme}
title={title}
/>
)
}
2 changes: 1 addition & 1 deletion web/app/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function Demo({
</WithBackground>
{preview || (
<Code
theme="material-darker"
theme="dracula"
lang="py"
style={{
fontSize: "1.2rem",
Expand Down
2 changes: 1 addition & 1 deletion web/app/head.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function Head() {
return (
<>
<title>Bright - Syntax Highlighting React Server Comopnent</title>
<title>Bright - Syntax Highlighting React Server Component</title>
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link
rel="icon"
Expand Down
51 changes: 51 additions & 0 deletions web/app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,55 @@ export default async function Page() {
/>
<div style={{ height: "3rem" }} />
<Details />

<div style={{ height: "3rem" }} />
<h2 style={{ textAlign: "center" }}>Title</h2>
<div style={{ height: "1rem" }} />
<Demo
demo={demo({
focus: true,
middle: (
<>
<span>const myCode = `</span>
<br />
<span style={{ color: "var(--text-color)" }}>
let hello = "hello brightness"
</span>
<br />
<span style={{ color: "var(--text-color)" }}>
console.log(hello, "my old friend")
</span>
<br />
<span>`.trim()</span>
<br />
<br />
</>
),
codeLine: (
<CodeLine
mark
children={<span style={{}}>{`{myCode}`}</span>}
props={
<>
<span style={{ color: "rgb(199, 146, 234)" }}>lang</span>
<span>="</span>
<span style={{ color: "rgb(195, 232, 141)" }}>js</span>
<span>" </span>

<span style={{ color: "rgb(199, 146, 234)" }}>title</span>
<span>="</span>
<span style={{ color: "rgb(195, 232, 141)" }}>shiny.js</span>
<span>"</span>
</>
}
/>
),
})}
code={`let hello = "hello brightness"
console.log(hello, "my old friend")`}
codeProps={{ title: "shiny.js", lang: "js" }}
/>

<div style={{ height: "3rem" }} />
<h2 style={{ textAlign: "center" }}>Line Numbers</h2>
<div style={{ height: "1rem" }} />
Expand Down Expand Up @@ -79,6 +128,7 @@ export default async function Page() {
console.log(hello, "my old friend")`}
codeProps={{ lineNumbers: true, lang: "js" }}
/>

<div style={{ height: "3rem" }} />
<h2 style={{ textAlign: "center" }}>Global Props</h2>
<div style={{ height: "1rem" }} />
Expand Down Expand Up @@ -190,6 +240,7 @@ print(theFuture is bright)`}
codeProps={{ lang: "py", theme: "material-lighter" }}
/>
<div style={{ height: "3rem" }} />

<h2 style={{ textAlign: "center" }}>Dark Mode</h2>
<div style={{ height: "1rem" }} />
<Demo
Expand Down

1 comment on commit e0daac1

@vercel
Copy link

@vercel vercel bot commented on e0daac1 Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bright – ./

bright-codehike.vercel.app
bright-git-main-codehike.vercel.app
bright.codehike.org

Please sign in to comment.