-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/move examples to top level (#6)
Moved examples to top level
- Loading branch information
Showing
12 changed files
with
77 additions
and
77 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//////////////// STORYBOOK EXAMPLES //////////////// | ||
const displayOpts = opts => '{' + Object.entries(opts).map(arr => { | ||
const key = arr[0]; | ||
const val = arr[1]; | ||
|
||
if (typeof val === "object") { return ` ${key}: ${displayOpts(val)}`; } | ||
if (key.indexOf('-') > 0) { return ` '${key}': '${val}'` } | ||
|
||
return ` ${key}: '${val}'`; | ||
}) + '}'; | ||
|
||
export const usageExample = (opts = null) => { | ||
const options = !opts ? '' : `const options = ${displayOpts(opts)};`; | ||
const optionsExample = !opts ? '' : ', options'; | ||
|
||
const hljs = !opts || !opts.lang ? '' : ` | ||
import hljs from 'highlight.js/lib/highlight'; | ||
// Register language for hljs | ||
hljs.registerLanguage('${opts.lang}', require('highlight.js/lib/langs/${opts.lang}')); | ||
`; | ||
|
||
return ` | ||
import copyCodeBlock from 'copyCodeBlock'; | ||
${hljs} | ||
const htmlString = 'Just pretend this is the Example Code from above'; | ||
${options} | ||
copyCodeBlock(htmlString${optionsExample}); | ||
` | ||
}; | ||
|
||
export const usageExampleJsHighlight = { | ||
lang: 'javascript', | ||
colors: { | ||
background: '#282a36', | ||
textColor: '#fff', | ||
comment: 'salmon', | ||
built_in: '#fff', | ||
attr: 'lightblue' | ||
} | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 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