-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from code-hike/copy-button
Copy button component
- Loading branch information
Showing
20 changed files
with
515 additions
and
261 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,59 @@ | ||
one line: | ||
|
||
```js | ||
const x = 2 | ||
``` | ||
|
||
no editor: | ||
|
||
```js | ||
function foo() { | ||
return 2 | ||
} | ||
``` | ||
|
||
one file editor: | ||
|
||
```js foo.js | ||
function foo() { | ||
return 2 | ||
} | ||
``` | ||
|
||
two files: | ||
|
||
<CH.Code> | ||
|
||
```js foo.js | ||
function foo() { | ||
return 2 | ||
} | ||
``` | ||
|
||
```js bar.js | ||
function bar() { | ||
return 2 | ||
} | ||
``` | ||
|
||
</CH.Code> | ||
|
||
two panels: | ||
|
||
<CH.Code> | ||
|
||
```js foo.js | ||
function foo() { | ||
return 2 | ||
} | ||
``` | ||
|
||
--- | ||
|
||
```js bar.js | ||
function bar() { | ||
return 2 | ||
} | ||
``` | ||
|
||
</CH.Code> |
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,73 @@ | ||
import Link from "next/link" | ||
import Head from "next/head" | ||
|
||
const extraItems = ["themes"] | ||
|
||
export function Layout({ | ||
children, | ||
current, | ||
contentFileNames, | ||
style = {}, | ||
}) { | ||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
flexDirection: "row", | ||
gap: 8, | ||
margin: "8px", | ||
}} | ||
> | ||
<Head> | ||
<title>Code Hike Test - {current}</title> | ||
</Head> | ||
<Sidebar | ||
contentFileNames={contentFileNames} | ||
current={current} | ||
/> | ||
|
||
<div | ||
style={{ | ||
maxWidth: 900, | ||
minWidth: 600, | ||
background: "#fafafa", | ||
borderRadius: 4, | ||
padding: 16, | ||
position: "relative", | ||
...style, | ||
}} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
function Sidebar({ contentFileNames, current }) { | ||
const items = contentFileNames.concat(extraItems) | ||
return ( | ||
<nav | ||
style={{ | ||
background: "#fafafa", | ||
borderRadius: 4, | ||
padding: "16px 0", | ||
minWidth: 180, | ||
}} | ||
> | ||
<ul style={{ margin: 0, padding: 0 }}> | ||
{items.map(item => ( | ||
<li | ||
key={item} | ||
style={{ listStyle: "none" }} | ||
className="sidebar-link" | ||
data-active={item === current} | ||
> | ||
<Link href={`/${encodeURIComponent(item)}`}> | ||
<a>{item}</a> | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
) | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.