-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(docs): Interactive playground component #140
Conversation
packages/@nucleus/tests/dummy/app/components/nucleus-button/playground.js
Outdated
Show resolved
Hide resolved
|
||
{{!-- code --}} | ||
{{playground.codeblock code=code}} | ||
{{/playground/container}} |
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.
Can we restructure (& rename) the contextual components to look something like this:
{{#docs-playground as |p|}}
{{!-- component --}}
{{#p.container}}
{{nucleus-button
label=label.value
variant=type.value
size=size.value
block=block.value
disabled=disabled.value
icon=icon.value
iconSize=iconSize.value
iconOnly=iconOnly.value
}}
{{/p.container}}
{{!-- props --}}
{{p.props onchange=(action 'onchange') properties=properties}}
{{!-- code --}}
{{p.codeblock code=code}}
{{/docs-playground}}
@@ -0,0 +1 @@ | |||
{{yield}} |
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.
This component can be avoided with the contextual components refactoring.
{{#docs-demo as |demo|}}
<div class="playground-container">
<div class="playground-container--component">
{{yield (hash container=(component "playground/container"))}}
</div>
<div class="playground-container--props">
<h3>Properties</h3>
{{yield (hash props=(component "playground/props"))}}
</div>
</div>
<div class="playground-container--code">
{{yield (hash codeblock=(component "playground/code"))}}
</div>
{{/docs-demo}}
{{/if}} | ||
|
||
{{!-- input --}} | ||
{{#if property.input}} |
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.
A single property cannot have both select and input flags right? In that case, can we refactor this to something like property.type
and switch based on that?
|
||
{{!-- input --}} | ||
{{#if property.input}} | ||
<Input |
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.
Also, can we have some basic styling for input to make it appear editable? I know we'll replace this with nucleus-input in the future, but it doesn't look like a text field at all now.
{{!-- toggle --}} | ||
{{#if property.toggle}} | ||
<Input | ||
@type="checkbox" |
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.
+1 for using angle bracket syntax! Looks super neat.
{{#docs-demo as |demo|}} | ||
<div class="playground-container"> | ||
<div class="playground-container--component"> | ||
{{yield (hash component=(component "docs-playground/component"))}} |
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.
Is it just me or does naming a component "component" sounds confusing, especially with component
template helper? Perhaps rename it to something like container
?
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.
I hope the name preview
will provide more context here...
{{/if}} | ||
|
||
{{!-- input --}} | ||
{{#if property.input}} |
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.
{{#else if}} to make sure only one component is rendered in case someone misconfigures. Also, the code is self explanatory that way.
|
||
.ember-text-field { | ||
border: 1px solid $playground-border-color; | ||
padding: 5px; |
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.
width: 100%
|
||
|
||
_generateCode() { | ||
let attributes = get(this, 'properties').map((prop) => { |
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.
Is it possible to move this mapping part into util as well? Seems to be duplicated.
} | ||
|
||
_handleIconOnly(properties) { | ||
let changables = ['label', 'type', 'icon']; |
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.
type
has been changed to variant
. Please change the necessary code.
&--component { | ||
align-self: center; | ||
width: 50%; | ||
text-align: center; |
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.
This might affect the childrens' text-align and get applied to nucleus-components. Needs some looking into
} | ||
|
||
_handleIconOnly(properties) { | ||
let changables = ['label', 'type', 'icon']; |
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.
type
has been changed to variant
. Can you please refactor?
@@ -0,0 +1,16 @@ | |||
{{#docs-demo as |demo|}} | |||
<div class="playground-container"> | |||
<div class="playground-container--component"> |
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.
Can we rename it to playground-container--preview
for better clarity?
* origin/master: feat(docs): Interactive playground component (#140) fix(button): block btn issue (#147) Revert "chore: updated package versioning (#135)" (#144) fix(modal): added submit disabled to confirm-dialog (#146) fix(button): improvised styling (#137) chore: updated package versioning (#135)
Description
Sample:
Added icon tiles & copy functionality
Fixed few bugs on button component