-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed library to use typescript now. Experimental snippet component…
… also being developed
- Loading branch information
Raj Singh
committed
Jul 2, 2020
1 parent
686b023
commit 45d799a
Showing
16 changed files
with
4,179 additions
and
462 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# WIP | ||
|
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
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,3 +1,3 @@ | ||
import Snippet from './snippet'; | ||
import Snippet from './Snippet'; | ||
|
||
export default Snippet; |
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,39 @@ | ||
export { default as a11yDark } from './a11y-dark'; | ||
export { default as a11yLight } from './a11y-light'; | ||
export { default as anOldHope } from './an-old-hope'; | ||
export { default as androidstudio } from './androidstudio'; | ||
export { default as arta } from './arta'; | ||
export { default as atomOneDark } from './atom-one-dark'; | ||
export { default as atomOneLight } from './atom-one-light'; | ||
export { default as codepen } from './codepen'; | ||
export { default as dracula } from './dracula'; | ||
export { default as far } from './far'; | ||
export { default as github } from './github'; | ||
export { default as googlecode } from './googlecode'; | ||
export { default as hopscotch } from './hopscotch'; | ||
export { default as hybrid } from './hybrid'; | ||
export { default as irBlack } from './ir-black'; | ||
export { default as monoBlue } from './mono-blue'; | ||
export { default as monokaiSublime } from './monokai-sublime'; | ||
export { default as monokai } from './monokai'; | ||
export { default as nord } from './nord'; | ||
export { default as obsidian } from './obsidian'; | ||
export { default as ocean } from './ocean'; | ||
export { default as paraisoDark } from './paraiso-dark'; | ||
export { default as paraisoLight } from './paraiso-light'; | ||
export { default as pojoaque } from './pojoaque'; | ||
export { default as purebasic } from './purebasic'; | ||
export { default as railscast } from './railscast'; | ||
export { default as rainbow } from './rainbow'; | ||
export { default as shadesOfPurple } from './shades-of-purple'; | ||
export { default as solarizedDark } from './solarized-dark'; | ||
export { default as solarizedLight } from './solarized-light'; | ||
export { default as sunburst } from './sunburst'; | ||
export { default as tomorrowNightBlue } from './tomorrow-night-blue'; | ||
export { default as tomorrowNightBright } from './tomorrow-night-bright'; | ||
export { default as tomorrowNightEighties } from './tomorrow-night-eighties'; | ||
export { default as tomorrowNight } from './tomorrow-night'; | ||
export { default as tomorrow } from './tomorrow'; | ||
export { default as vs2015 } from './vs2015'; | ||
export { default as xt256 } from './xt256'; | ||
export { default as zenburn } from './zenburn'; |
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,17 +1,5 @@ | ||
export const tuple = <T extends string[]>(...args: T) => args; | ||
|
||
const snippetTypes = tuple( | ||
'default', | ||
'secondary', | ||
'success', | ||
'warning', | ||
'error', | ||
'dark', | ||
'lite' | ||
); | ||
|
||
const copyTypes = tuple('default', 'slient', 'prevent'); | ||
|
||
export type SnippetTypes = typeof snippetTypes[number]; | ||
|
||
export type CopyTypes = typeof copyTypes[number]; |
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,38 @@ | ||
import React from 'react'; | ||
import { Code } from '../src'; | ||
import { withKnobs, select, text, boolean } from '@storybook/addon-knobs'; | ||
import { supportedLanguages, themeObj } from '../utils/knobs'; | ||
import he from 'he'; | ||
|
||
export default { | ||
title: 'Code', | ||
decorators: [withKnobs], | ||
}; | ||
|
||
// By passing optional props to this story, you can control the props of the component when | ||
// you consume the story in a test. | ||
export const Default = () => { | ||
const language = select( | ||
'language', | ||
Object.assign({}, ...supportedLanguages.map(val => ({ [val]: val }))), | ||
'javascript' | ||
); | ||
//@ts-ignore | ||
const themes = select('theme', themeObj, 'dracula'); | ||
const code = text('text', `const add = (x,y) => x+y;`); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
fontFamily: 'Fira Code', | ||
}} | ||
> | ||
<Code | ||
text={he.decode(code)} | ||
language={language} | ||
theme={require('../src')[themes]} | ||
wrapLines | ||
/> | ||
</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 |
---|---|---|
@@ -1,18 +1,40 @@ | ||
import React from 'react'; | ||
import { CodeBlock, dracula } from '../src'; | ||
import { CodeBlock } from '../src'; | ||
import { withKnobs, select, text, boolean } from '@storybook/addon-knobs'; | ||
import { supportedLanguages, themeObj } from '../utils/knobs'; | ||
import he from 'he'; | ||
|
||
export default { | ||
title: 'Code Block', | ||
decorators: [withKnobs], | ||
}; | ||
|
||
// By passing optional props to this story, you can control the props of the component when | ||
// you consume the story in a test. | ||
export const Default = () => ( | ||
<CodeBlock | ||
text={"const foo = 'bar';"} | ||
language="javascript" | ||
theme={dracula} | ||
showLineNumbers | ||
wrapLines | ||
/> | ||
); | ||
export const Default = () => { | ||
const language = select( | ||
'language', | ||
Object.assign({}, ...supportedLanguages.map(val => ({ [val]: val }))), | ||
'javascript' | ||
); | ||
//@ts-ignore | ||
const themes = select('theme', themeObj, 'dracula'); | ||
const showLineNumbers = boolean('showLineNumbers', true); | ||
const wrapLines = boolean('wrapLines', true); | ||
const code = text('text', `const add = (x,y) => x+y;`); | ||
return ( | ||
<div | ||
style={{ | ||
fontFamily: 'Fira Code', | ||
}} | ||
> | ||
<CodeBlock | ||
text={he.decode(code)} | ||
language={language} | ||
theme={require('../src')[themes]} | ||
showLineNumbers={showLineNumbers} | ||
wrapLines={wrapLines} | ||
/> | ||
</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,45 @@ | ||
import React from 'react'; | ||
import { CopyBlock } from '../src'; | ||
import { withKnobs, select, text, boolean } from '@storybook/addon-knobs'; | ||
import { supportedLanguages, themeObj } from '../utils/knobs'; | ||
import he from 'he'; | ||
|
||
export default { | ||
title: 'Copy Block', | ||
decorators: [withKnobs], | ||
}; | ||
|
||
// By passing optional props to this story, you can control the props of the component when | ||
// you consume the story in a test. | ||
export const Default = () => { | ||
const language = select( | ||
'language', | ||
Object.assign({}, ...supportedLanguages.map(val => ({ [val]: val }))), | ||
'python' | ||
); | ||
//@ts-ignore | ||
const code = text( | ||
'text', | ||
`import pandas as pd | ||
df = pd.read_csv('some_random.csv'); | ||
df.head(5)` | ||
); | ||
const themes = select('theme', themeObj, 'dracula'); | ||
const showLineNumbers = boolean('showLineNumbers', true); | ||
const wrapLines = boolean('wrapLines', true); | ||
const codeBlock = boolean('codeBlock', true); | ||
return ( | ||
<div | ||
style={{ | ||
fontFamily: 'Fira Code', | ||
}} | ||
> | ||
<CopyBlock | ||
text={he.decode(code)} | ||
language={language} | ||
theme={require('../src')[themes]} | ||
{...{ showLineNumbers, wrapLines, codeBlock }} | ||
/> | ||
</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,27 @@ | ||
import React from 'react'; | ||
import { Snippet } from '../src'; | ||
import { withKnobs, text, select } from '@storybook/addon-knobs'; | ||
import { themeObj } from '../utils/knobs'; | ||
import he from 'he'; | ||
|
||
export default { | ||
title: 'Snippet', | ||
decorators: [withKnobs], | ||
}; | ||
|
||
// By passing optional props to this story, you can control the props of the component when | ||
// you consume the story in a test. | ||
export const Default = () => { | ||
//@ts-ignore | ||
const themes = select('theme', themeObj, 'dracula'); | ||
const code = text('text', `df[df.index == 1]['name']`); | ||
return ( | ||
<div | ||
style={{ | ||
fontFamily: 'Fira Code', | ||
}} | ||
> | ||
<Snippet text={he.decode(code)} theme={require('../src')[themes]} /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.