Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styleguide example #3304

Merged
merged 34 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a8a21ba
Adds plop boilerplate
scottyeck Dec 15, 2017
6e15197
Adds base stuff
scottyeck Dec 15, 2017
b6ca427
Configurable background colors
scottyeck Dec 15, 2017
3553224
Rename props
scottyeck Dec 15, 2017
710856e
Add a comment
scottyeck Dec 15, 2017
aa1b7ab
Add a component README
scottyeck Dec 15, 2017
9b28019
Tweaks
scottyeck Dec 15, 2017
ddabf39
Can query successfully
scottyeck Dec 15, 2017
b663d4d
Adds components and index
scottyeck Dec 15, 2017
d795628
Add prop types
scottyeck Dec 15, 2017
b5dd220
Adds component index
scottyeck Dec 15, 2017
b0eab2a
Link back to component index
scottyeck Dec 15, 2017
d1c64ee
Showing props / methods
scottyeck Dec 16, 2017
7a493d9
Add size prop to Button
scottyeck Dec 16, 2017
9e5b877
Remove log
scottyeck Dec 16, 2017
a75a77d
We are querying markdown
scottyeck Dec 16, 2017
ecbb019
Feeds example html into renderer
scottyeck Dec 16, 2017
f2a8d64
Parsing / rendering HTML
scottyeck Dec 16, 2017
40035e1
Starts parsing nodes
scottyeck Dec 16, 2017
616ead8
It works
scottyeck Dec 16, 2017
34bda41
Add prop types
scottyeck Dec 16, 2017
2b5050b
Adds size example to README
scottyeck Dec 16, 2017
d9ceaca
Sets up component index
scottyeck Dec 16, 2017
cb6864b
Writes dyanmic component index to the cache
scottyeck Dec 16, 2017
66c61c4
Renaming for clarity
scottyeck Dec 16, 2017
437d183
Add description
scottyeck Dec 18, 2017
78c6716
Renaming
scottyeck Dec 20, 2017
73f3283
Possible strategy for ensuring durability of components in library pr…
scottyeck Dec 20, 2017
80e742f
Using a particular prism theme
scottyeck Dec 20, 2017
c0145ea
Fix proptypes
scottyeck Dec 20, 2017
3137e39
POC styling editor
scottyeck Dec 20, 2017
f838725
Converts to table
scottyeck Dec 20, 2017
7bf75e2
Merge branch 'master' into styleguide-example
KyleAMathews Dec 22, 2017
28da937
new name
KyleAMathews Dec 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
It works
  • Loading branch information
scottyeck committed Dec 21, 2017
commit 616ead880594b1c22cf6582ec03ee9893d9b2885
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import React from "react"
import PropTypes from "prop-types"
import { LiveProvider, LiveEditor, LiveError, LivePreview } from "react-live"

import Button from "../../../components/Button"

class ComponentPreview extends React.Component {
render() {
return
return (
<LiveProvider scope={{ Button }} code={this.props.code}>
<LiveEditor />
<LiveError />
<LivePreview />
</LiveProvider>
)
}
}

ComponentPreview.propTypes = {
code: PropTypes.string.isRequired,
}

export default ComponentPreview
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React from "react"
import PropTypes from "prop-types"
import { Parser, ProcessNodeDefinitions } from "html-to-react"
import ComponentPreview from "../ComponentPreview"

const isValidNode = () => true
const isCodeExample = ({ name = `` } = {}) => name === `pre`

const parser = new Parser()
const processNodeDefinitions = new ProcessNodeDefinitions(React)
const getHtmlCode = children => children[0].children[0].data

const ExampleNodeProcessor = ({ children }) =>
React.createElement(ComponentPreview, { code: getHtmlCode(children) })

const processingInstructions = [
{
shouldProcessNode: isCodeExample,
processNode: (node, children) => {
console.log(node)
return processNodeDefinitions.processDefaultNode(node, children)
},
processNode: ExampleNodeProcessor,
},
{
shouldProcessNode: isValidNode,
Expand All @@ -29,8 +31,7 @@ class Example extends React.Component {
isValidNode,
processingInstructions
)
console.log(html)
return <div>{html}</div>
return <div>{React.Children.toArray(html)}</div>
}
}

Expand Down