-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
339 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Code } from 'codice' | ||
import { highlight } from 'sugar-high' | ||
|
||
const CODE_SIMPLE_SNIPPET_HTML = highlight(`console.log("hello world")`) | ||
|
||
const CODE_ULTIMATE_SNIPPET_HTML = highlight(`\ | ||
import { Code } from 'codice' | ||
<Code controls filename="app/index.js"> | ||
{'<div>Hello World</div>'} | ||
</Code> | ||
`) | ||
|
||
function CodeExampleItem({ | ||
title, | ||
children, | ||
}: { | ||
title: string | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<div className="code-example__item"> | ||
<h3 className="code-example__item__title">{title}</h3> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export function CodeExamples() { | ||
return ( | ||
<div className="code-example"> | ||
<CodeExampleItem title="Ultimate Code Block"> | ||
<Code className="code code--controls" controls filename="app/index.js"> | ||
{CODE_ULTIMATE_SNIPPET_HTML} | ||
</Code> | ||
</CodeExampleItem> | ||
|
||
<CodeExampleItem title="Code Block with filename"> | ||
<Code className="code code--filename" filename="app/index.js"> | ||
{highlight(`\ | ||
function marker() { | ||
return "long live sugar-high" | ||
}`)} | ||
</Code> | ||
</CodeExampleItem> | ||
|
||
<CodeExampleItem title="Simple Code Block"> | ||
<Code className="code code--simple">{CODE_SIMPLE_SNIPPET_HTML}</Code> | ||
</CodeExampleItem> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { LiveEditor } from './live-editor' | ||
|
||
const defaultCode = `\ | ||
import { useState } from 'react' | ||
import { highlight } from 'sugar-high' | ||
import { Editor } from 'codice' | ||
const defaultText = 'console.log("hello world")' | ||
export default function Page() { | ||
const [code, setCode] = useState(defaultText) | ||
return ( | ||
<div> | ||
<Editor | ||
value={code} | ||
className='editor' | ||
title='index.js' | ||
highlight={text => highlight(text)} | ||
onChange={(text) => setCode(text)} | ||
/> | ||
</div> | ||
) | ||
} | ||
` | ||
|
||
export function EditorExample({ searchParams }) { | ||
return ( | ||
<div> | ||
<LiveEditor searchParams={searchParams} defaultCode={defaultCode} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,40 @@ | ||
import { LiveEditor } from './editor' | ||
import { EditorExample } from './editor-example' | ||
import { CodeExamples } from './code-example' | ||
import { Code } from 'codice' | ||
|
||
export default async function Page(props) { | ||
const searchParams = await props.searchParams | ||
|
||
return ( | ||
<div> | ||
<LiveEditor searchParams={searchParams} /> | ||
<div className='titles'> | ||
<h1> | ||
<span className='huge-title'>Codice</span> | ||
</h1> | ||
<p> | ||
<span className='subtitle'> | ||
The Story of Code Presentation | ||
</span> | ||
</p> | ||
<div className='description'> | ||
<p> | ||
Codice is a simple code editor and code block component for React. It is a zero-dependency library that provides a simple and easy-to-use code editor and code block component. | ||
</p> | ||
<Code className='code--default'> | ||
{`npm install codice`} | ||
</Code> | ||
</div> | ||
</div> | ||
|
||
<div className='section'> | ||
<h2>Editor Examples</h2> | ||
<EditorExample searchParams={searchParams} /> | ||
</div> | ||
|
||
<div className='section'> | ||
<h2>Code Block Examples</h2> | ||
<CodeExamples /> | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.