Skip to content

[GSoC] Playground / Toggle System for Live Documentation #3057

Closed

Description

@thompsongl

A better playground / toggle system for EUI live documentation. Right now we have flat, read-only code displayed next to static examples. It would be nice if people could change the code examples in-browser on our docs site and see the changes live in the examples.

Outcome
An edit mechanism that would allow users to change, add, or otherwise modify props and content in rendered examples.

Related Discussion

  • Discuss comment; Please note that the ideas mentioned are not requirements but concept suggestions that would need to be thoroughly vetted.

  • Discuss comment; "having the interactive playground inline in our documentation is something we'd really like to see"


Interested in working on EUI for Google Summer of Code? See more details here: https://github.com/elastic/gsoc

Activity

  1. locked and limited conversation to collaborators on Mar 12, 2020
  2. unlocked this conversation on May 11, 2020
  3. thompsongl commented on May 11, 2020

    @thompsongl
    ContributorAuthor

    @anishagg17 We'll use this issue to discuss and track modifications to your proposal.

    Comment in this thread and then I can assign the issue to you.

  4. anishagg17 commented on May 13, 2020

    @anishagg17
    Contributor

    @thompsongl Sorry for the late reply , I think my mention notifications are turned off.

    @anishagg17 We'll use this issue to discuss and track modifications to your proposal.

    Sure this would be great!

  5. thompsongl commented on May 13, 2020

    @thompsongl
    ContributorAuthor

    @cchaos We'll use this issue to track discussion for the EUI docs project. Post anything you've been thinking about for design, etc.

    I'll be updating the main summary area soon

  6. cchaos commented on May 13, 2020

    @cchaos
    Contributor

    My current thoughts are that I'd like to avoid creating a new tab to each documentation section. Instead, I'm thinking that it's basically a separate page(application) with all the components listed in it's own side nav on the left and toggles/code editor on the right. Then each component in our normal docs would just have a button/link that goes to it's playground section in this new page/app. I'll probably think through the design/layout of this over the next month, but that's the basic idea.

  7. thompsongl commented on May 15, 2020

    @thompsongl
    ContributorAuthor

    I'd like to avoid creating a new tab to each documentation section. Instead, I'm thinking that it's basically a separate page(application) with all the components listed in it's own side nav on the left and toggles/code editor on the right. Then each component in our normal docs would just have a button/link that goes to it's playground section in this new page/app.

    @anishagg17 You can start exploring this idea. I'll do some research, as well.
    Some things to consider:

    • How would this concept change the scope of your original proposal?
    • How would this concept change the technology choices (i.e., react-live) in your original proposal?
  8. anishagg17 commented on May 16, 2020

    @anishagg17
    Contributor

    Before coding , let's discuss several alternatives that can be used for this purpose

    Also ,

    just have a button/link that goes to it's playground section in this new page/app

    Inculcates creating a new section within the docs-site this would be the first step later we can use the library of our choice and utilise it

  9. anishagg17 commented on May 16, 2020

    @anishagg17
    Contributor

    react-live

    Pros

    1. Same code can be used for both readOnly code and Playground
    2. Some modifications would be required to codeExamples.
    3. CodeEditor, ErrorDisplay, ComponentPreview all can be designed, customised.

    Cons

    1. Import Statements are not supported inside the code example. (We can pass code through a function to comment out import statements)
    2. TypeScript code can't be used
  10. anishagg17 commented on May 16, 2020

    @anishagg17
    Contributor

    react-view

    Pros

    • Import Statements are supported.
    • Supports TypeScript code.
    • Provides more flexibility, adding toggles, ranges

    Cons

    • We would have to write out separate codeExamples for the playground, but about 40% would be copy pasted. Same code can also be used for both readOnly code and Playground but we would have to write out some complex function to remove all import statements and use them for import prop that might require special care for some examples as in case of EuiSideNav one import statement is multiline.
     const params = useView({
        initialCode: `() => {
          const text: string = "Hey";
          return <h2>{text}</h2>;
        }`,
       scope: {
          /* Component Name */,
        },
        imports: {
          '@elastic/eui': {
            named: ['/* Component Name*/'],
          },
        },
      });
    
  11. thompsongl commented on May 18, 2020

    @thompsongl
    ContributorAuthor

    react-view looks interesting. Have you seen any usages where the prop configuration is less manual? Like, is it possible to consume prop types from PropTypes or TypeScript output?

  12. 26 remaining items

  13. anishagg17 commented on Jul 2, 2020

    @anishagg17
    Contributor

    Layout

    • Accordion ( has a function onToggle, Components extraAction and buttonContent)
      Bottom Bar [Playground] EuiBottomBar #3870 (comment)
    • EuiFlexGroup ( has child components if we set some default for all of them then this example makes sense )
    • EuiFlexGrid
    • Horizontal Rule ✅
    • Panel ( has betaBadgeTooltipContent as reactNode)
    • Spacer ✅

    Navigation

    • Button ✅
    • Facet ( has a function onClick)
    • Key Pad Menu ( EuiKeyPadMenuItem seems simple it too has a function onClick )
    • Link ( has a function onClick)
    • Pagination ( has a function onPageClick)
    • Steps ( EuiStep seems simple)
    • Tabs ( EuiTab seems simple it too has a function onClick )

    Display

    • Aspect ratio ✅
    • Avatar ✅
    • Badge ( has a function onClick)
    • Callout ✅
    • Card ( has a function onClick)
    • Code ✅
    • Comment list (EuiComment seems simple)
    • EmptyPrompt ✅
    • Health ✅
    • Icons ✅
    • Image ✅
    • Loading ✅
    • Progress ✅
    • Stat ✅
    • Text ✅
    • Title (Mostly depends upon children , reactNode)
    • Toast ( has a function onClose)
    • ToolTip ( has a function onMouseOut)

    Forms

    (for most of the forms we would have to set some default onChange and value so that they can be made simple)

    • EuiFieldText
    • EuiFieldSearch
    • EuiFieldNumber
    • EuiFieldPassword
    • EuiTextArea
    • EuiCheckbox
    • EuiRadio
    • EuiSwitch
    • EuiColorPicker
    • EuiCodeEditor
    • EuiExpression ✅
    • EuiRange (has an array levels)
    • EuiDualRange (has an array levels)

    Utilities

    I have added almost all the components which are already simple or could be made simple via some modifications in the config file.

  14. anishagg17 commented on Jul 6, 2020

    @anishagg17
    Contributor

    @thompsongl I have completed the list If you find any component missing you may add it.

  15. thompsongl commented on Jul 6, 2020

    @thompsongl
    ContributorAuthor

    (for most of the forms we would have to set some default onChange and value so that they can be made simple)

    We have a kind of toggle system in place already for form controls, so they are lower on the priority list. We eventually move them over the playground, but we can wait.

  16. thompsongl commented on Jul 9, 2020

    @thompsongl
    ContributorAuthor

    Let's start working on the Display components. Probably a single PR per component.

    I think Badge, Card, and Toast can be added, also, as long as we fake the necessary onClick/onClose functions.

  17. anishagg17 commented on Jul 30, 2020

    @anishagg17
    Contributor

    @thompsongl as EuiIcon doesn't render props currently . So, should we skip EuiIcon component for now and can build it later on.

  18. thompsongl commented on Jul 30, 2020

    @thompsongl
    ContributorAuthor

    So, should we skip EuiIcon component for now and can build it later on.

    Yep, sounds like a good plan

  19. anishagg17 commented on Jul 31, 2020

    @anishagg17
    Contributor

    @thompsongl I noticed that EuiEmptyPrompt has actions , title and body as some major props(all ReactNode) .

    If body and actions are set to String, and title is faked then it works

    Otherwise , it's playground shouldn't be considered.

    Also, since it is the last component of Display section , do let me know which section should I work next

  20. thompsongl commented on Aug 10, 2020

    @thompsongl
    ContributorAuthor

    If body and actions are set to String, and title is faked then it works

    Let's try this for EuiEmptyPrompt

    let me know which section should I work next

    Start with Layout components, then Utilities

  21. anishagg17 commented on Aug 12, 2020

    @anishagg17
    Contributor

    @cchaos does EuiPortal(Utilities) requires a playground?

  22. thompsongl commented on Aug 12, 2020

    @thompsongl
    ContributorAuthor

    does EuiPortal(Utilities) requires a playground?

    No, we can skip that one

  23. anishagg17 commented on Aug 25, 2020

    @anishagg17
    Contributor

    @thompsongl #3959 marks the completion of all playgrounds 🎉 . Anything more that I need to do?

  24. cchaos commented on Aug 25, 2020

    @cchaos
    Contributor

    @anishagg17 Thank you so much for all the work you did on this project!!! 🎉 🎉 It's amazing what's been accomplished over this past summer. The playground toggles really step up our documentation game and gives us such an easier way to test all the permutations of each component. Best of luck to you in future endeavors!

  25. thompsongl commented on Aug 25, 2020

    @thompsongl
    ContributorAuthor

    @anishagg17 Nothing more as far as EUI is concerned 😄 Just make sure you submit all your GSoC evaluations, etc. before the deadline later this week (if you haven't already).

    You've done great work and should be proud of the last few months! I know all of us here were glad to have you and are thrilled with the outcome 🚀

  26. thompsongl commented on Aug 25, 2020

    @thompsongl
    ContributorAuthor

    Closing this because @anishagg17 did all the things

    We'll track anything related to component playground in the future in separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions