-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Fix semi broken __docgenInfo integration in addon info #1030
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b613d53
added version number.
a546a2e
working on getting more documentation.
5ac9286
added a post install script.
38a3c53
added code to support js documentation for adding descriptions to a c…
d61acd6
removed version number.
2ba6511
removed reference to `window` since it is not needed.
cd3ab0f
fixed code style problems.
a984acc
added version number.
edd6b69
working on getting more documentation.
7958923
added a post install script.
ad15e80
added code to support js documentation for adding descriptions to a c…
8dc1369
removed version number.
622dadb
removed reference to `window` since it is not needed.
ad0fcfe
fixed code style problems.
3e7bc3c
Merge branch 'master' of github.com:bigassdragon/storybook
d08b51b
Merge branch 'master' into master
ndelangen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,119 +1,119 @@ | ||
import React from 'react'; | ||
import createFragment from 'react-addons-create-fragment'; | ||
import React from 'react' | ||
import createFragment from 'react-addons-create-fragment' | ||
|
||
const valueStyles = { | ||
func: { | ||
color: '#170', | ||
color: '#170' | ||
}, | ||
|
||
attr: { | ||
color: '#666', | ||
color: '#666' | ||
}, | ||
|
||
object: { | ||
color: '#666', | ||
color: '#666' | ||
}, | ||
|
||
array: { | ||
color: '#666', | ||
color: '#666' | ||
}, | ||
|
||
number: { | ||
color: '#a11', | ||
color: '#a11' | ||
}, | ||
|
||
string: { | ||
color: '#22a', | ||
wordBreak: 'break-word', | ||
wordBreak: 'break-word' | ||
}, | ||
|
||
bool: { | ||
color: '#a11', | ||
color: '#a11' | ||
}, | ||
|
||
empty: { | ||
color: '#777', | ||
}, | ||
}; | ||
color: '#777' | ||
} | ||
} | ||
|
||
function previewArray(val) { | ||
const items = {}; | ||
function previewArray (val) { | ||
const items = {} | ||
val.slice(0, 3).forEach((item, i) => { | ||
items[`n${i}`] = <PropVal val={item} />; | ||
items[`c${i}`] = ', '; | ||
}); | ||
items[`n${i}`] = <PropVal val={item} /> | ||
items[`c${i}`] = ', ' | ||
}) | ||
if (val.length > 3) { | ||
items.last = '…'; | ||
items.last = '…' | ||
} else { | ||
delete items[`c${val.length - 1}`]; | ||
delete items[`c${val.length - 1}`] | ||
} | ||
return ( | ||
<span style={valueStyles.array}> | ||
[{createFragment(items)}] | ||
</span> | ||
); | ||
) | ||
} | ||
|
||
function previewObject(val) { | ||
const names = Object.keys(val); | ||
const items = {}; | ||
function previewObject (val) { | ||
const names = Object.keys(val) | ||
const items = {} | ||
names.slice(0, 3).forEach((name, i) => { | ||
items[`k${i}`] = <span style={valueStyles.attr}>{name}</span>; | ||
items[`c${i}`] = ': '; | ||
items[`v${i}`] = <PropVal val={val[name]} />; | ||
items[`m${i}`] = ', '; | ||
}); | ||
items[`k${i}`] = <span style={valueStyles.attr}>{name}</span> | ||
items[`c${i}`] = ': ' | ||
items[`v${i}`] = <PropVal val={val[name]} /> | ||
items[`m${i}`] = ', ' | ||
}) | ||
if (names.length > 3) { | ||
items.rest = '…'; | ||
items.rest = '…' | ||
} else { | ||
delete items[`m${names.length - 1}`]; | ||
delete items[`m${names.length - 1}`] | ||
} | ||
return ( | ||
<span style={valueStyles.object}> | ||
{'{'}{createFragment(items)}{'}'} | ||
</span> | ||
); | ||
) | ||
} | ||
|
||
function previewProp(val) { | ||
let braceWrap = true; | ||
let content = null; | ||
function previewProp (val) { | ||
let braceWrap = true | ||
let content = null | ||
if (typeof val === 'number') { | ||
content = <span style={valueStyles.number}>{val}</span>; | ||
content = <span style={valueStyles.number}>{val}</span> | ||
} else if (typeof val === 'string') { | ||
if (val.length > 50) { | ||
val = `${val.slice(0, 50)}…`; | ||
val = `${val.slice(0, 50)}…` | ||
} | ||
content = <span style={valueStyles.string}>"{val}"</span>; | ||
braceWrap = false; | ||
content = <span style={valueStyles.string}>"{val}"</span> | ||
braceWrap = false | ||
} else if (typeof val === 'boolean') { | ||
content = <span style={valueStyles.bool}>{`${val}`}</span>; | ||
content = <span style={valueStyles.bool}>{`${val}`}</span> | ||
} else if (Array.isArray(val)) { | ||
content = previewArray(val); | ||
content = previewArray(val) | ||
} else if (typeof val === 'function') { | ||
content = <span style={valueStyles.func}>{val.name ? `${val.name}()` : 'anonymous()'}</span>; | ||
content = <span style={valueStyles.func}>{val.name ? `${val.name}()` : 'anonymous()'}</span> | ||
} else if (!val) { | ||
content = <span style={valueStyles.empty}>{`${val}`}</span>; | ||
content = <span style={valueStyles.empty}>{`${val}`}</span> | ||
} else if (typeof val !== 'object') { | ||
content = <span>…</span>; | ||
content = <span>…</span> | ||
} else if (React.isValidElement(val)) { | ||
content = ( | ||
<span style={valueStyles.object}> | ||
{`<${val.type.displayName || val.type.name || val.type} />`} | ||
</span> | ||
); | ||
) | ||
} else { | ||
content = previewObject(val); | ||
content = previewObject(val) | ||
} | ||
|
||
if (!braceWrap) return content; | ||
return <span>{content}</span>; | ||
} | ||
|
||
export default class PropVal extends React.Component { | ||
render() { | ||
return previewProp(this.props.val); | ||
render () { | ||
return previewProp(this.props.val) | ||
} | ||
} | ||
|
||
module.exports = PropVal; | ||
module.exports = PropVal |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah never mind then