-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add CodeReviewCard and corresponding story
- Loading branch information
Showing
19 changed files
with
716 additions
and
460 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 |
---|---|---|
@@ -1,38 +1,5 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
.code { | ||
padding: 200px; | ||
display: flex; | ||
justify-content: center; | ||
} |
This file was deleted.
Oops, something went wrong.
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 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,5 @@ | ||
.codeReview { | ||
display: flex; | ||
justify-content: center; | ||
width: 80%; | ||
} |
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,67 @@ | ||
import React, {FunctionComponent} from "react"; | ||
import { Pre, Line, LineNo, LineContent } from "./styles" | ||
import Highlight, { defaultProps } from "prism-react-renderer"; | ||
import theme from "prism-react-renderer/themes/nightOwl"; | ||
import "./CodeReview.less"; | ||
|
||
type Language = | ||
| "markup" | ||
| "bash" | ||
| "clike" | ||
| "c" | ||
| "cpp" | ||
| "css" | ||
| "javascript" | ||
| "jsx" | ||
| "coffeescript" | ||
| "actionscript" | ||
| "css-extr" | ||
| "diff" | ||
| "git" | ||
| "go" | ||
| "graphql" | ||
| "handlebars" | ||
| "json" | ||
| "less" | ||
| "makefile" | ||
| "markdown" | ||
| "objectivec" | ||
| "ocaml" | ||
| "python" | ||
| "reason" | ||
| "sass" | ||
| "scss" | ||
| "sql" | ||
| "stylus" | ||
| "tsx" | ||
| "typescript" | ||
| "wasm" | ||
| "yaml"; | ||
|
||
type CodeReviewProps = { | ||
code: string | ||
language: Language | ||
} | ||
|
||
export const CodeReview: FunctionComponent<CodeReviewProps> = ({ code, language }) => { | ||
return ( | ||
<Highlight {...defaultProps} theme={theme} code={code} language={language}> | ||
{({ className, style, tokens, getLineProps, getTokenProps }) => ( | ||
<Pre className={className} style={style}> | ||
{tokens.map((line, i) => ( | ||
<Line key={i} {...getLineProps({ line, key: i })}> | ||
<LineNo>{i + 1}</LineNo> | ||
<LineContent> | ||
{line.map((token, key) => ( | ||
<span key={key} {...getTokenProps({ token, key })} /> | ||
))} | ||
</LineContent> | ||
</Line> | ||
))} | ||
</Pre> | ||
)} | ||
</Highlight> | ||
) | ||
} | ||
|
||
export default CodeReview; |
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,51 @@ | ||
import React from "react"; | ||
import {Card} from "antd"; | ||
import CodeReview from "./CodeReview"; | ||
|
||
type Language = | ||
| "markup" | ||
| "bash" | ||
| "clike" | ||
| "c" | ||
| "cpp" | ||
| "css" | ||
| "javascript" | ||
| "jsx" | ||
| "coffeescript" | ||
| "actionscript" | ||
| "css-extr" | ||
| "diff" | ||
| "git" | ||
| "go" | ||
| "graphql" | ||
| "handlebars" | ||
| "json" | ||
| "less" | ||
| "makefile" | ||
| "markdown" | ||
| "objectivec" | ||
| "ocaml" | ||
| "python" | ||
| "reason" | ||
| "sass" | ||
| "scss" | ||
| "sql" | ||
| "stylus" | ||
| "tsx" | ||
| "typescript" | ||
| "wasm" | ||
| "yaml"; | ||
|
||
export interface CodeReviewCardProps { | ||
code: string; | ||
language: Language; | ||
} | ||
export const CodeReviewCard: React.FC<CodeReviewCardProps> = ({ code, language }) => { | ||
return ( | ||
<Card style={{ width: 500 }}> | ||
<CodeReview code={code} language={language}/> | ||
</Card> | ||
) | ||
} | ||
|
||
export default CodeReviewCard; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
import React from 'react'; | ||
import {CodeReviewCard, CodeReviewCardProps} from "../components/CodeReviewCard"; | ||
import { Story, Meta } from '@storybook/react/types-6-0'; | ||
|
||
|
||
export default { | ||
componenet: CodeReviewCard, | ||
title: 'CodeReviewCard' | ||
} as Meta; | ||
|
||
const Template: Story<CodeReviewCardProps> = (args) => <CodeReviewCard {...args} />; | ||
|
||
const jsxCode = ` | ||
(function someDemo() { | ||
var test = "Hello World!"; | ||
console.log(test); | ||
})(); | ||
return () => <App />; | ||
`.trim(); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
code: jsxCode, | ||
language: "jsx" | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.