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

feat(docs): Interactive playground component #140

Merged
merged 15 commits into from
Mar 9, 2020
Merged

Conversation

prakash-chokalingam
Copy link
Contributor

Description

  • Added interactive playground for components

Sample:
Screenshot 2020-02-27 at 5 08 30 PM

  • Added icon tiles & copy functionality

  • Fixed few bugs on button component

@prakash-chokalingam prakash-chokalingam changed the title [Docs] Adding interactive playground component for docs [DOCS] Adding interactive playground component for docs Feb 27, 2020
@prakash-chokalingam prakash-chokalingam self-assigned this Feb 27, 2020
@prakash-chokalingam prakash-chokalingam added the enhancement New feature or request label Feb 27, 2020

{{!-- code --}}
{{playground.codeblock code=code}}
{{/playground/container}}
Copy link
Contributor

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}}
Copy link
Contributor

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}}
Copy link
Contributor

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
Copy link
Contributor

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"
Copy link
Contributor

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"))}}
Copy link
Contributor

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?

Copy link
Contributor Author

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}}
Copy link
Contributor

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;
Copy link
Contributor

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) => {
Copy link
Contributor

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.

@shibulijack-fd shibulijack-fd changed the title [DOCS] Adding interactive playground component for docs feat(docs): Interactive playground component Mar 2, 2020
}

_handleIconOnly(properties) {
let changables = ['label', 'type', 'icon'];
Copy link
Contributor

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;
Copy link
Contributor

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'];
Copy link
Contributor

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">
Copy link
Contributor

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?

@shibulijack-fd shibulijack-fd merged commit 3daf9bf into master Mar 9, 2020
@shibulijack-fd shibulijack-fd deleted the playground branch March 9, 2020 04:24
shibulijack-fd added a commit that referenced this pull request Mar 9, 2020
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants