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

Create a new documentation component DocsExample that allows to toggle between an example and its code #826

Open
6 tasks
MisRob opened this issue Nov 14, 2024 · 3 comments · May be fixed by #836
Open
6 tasks
Assignees
Labels
category: supporting code Implementation of the system good first issue Self-contained, straightforward, low-complexity help wanted Open source contributors welcome P2 - normal Priority: Nice to have size: medium

Comments

@MisRob
Copy link
Member

MisRob commented Nov 14, 2024

🌱 Are you new to the codebase? Welcome! Please see the contributing guidelines.

Desired behavior

Create a new documentation component DocsExample that toggles between an example and its code on the documentation website.

<DocsExample>

  // The default slot renders the example

  <template #code>
     // The code slot renders code snippet(s)
     <DocsShowCode language="html">
     
     </DocsShowCode>
     
     <DocsShowCode language="javascript">
     
     </DocsShowCode>
  </template>
</DocsExample>

Here is one example demonstrating the expected visual output. For this KCardGrid demonstration (source, output), the new

<DocsExample language="html">
  <KCardGrid ...>
       ...
  </KCardGrid>

  <template #code>
    <DocsShowCode language="html">
       <KCardGrid ...>
          ...
        </KCardGrid>
     </DocsShowCode>

    <DocsShowCode language="javascript">
      export default { 
        ...
       }     
     </DocsShowCode>
  </template>
</DocsExample>

should produce the following:

(1) On an initial page load, we'd only show the card grid passed via the default slot

(2) The code sample(s) related to the example would be passed via placing DocsShowCode(s) to #code slot

(3) DocsExample would render a toggle button to "View code"/"Hide code" in its top right corner. Clicking it would show/hide the code sample(s) above the card grid:

The overall experience would be similar to that of the Vuetify documentation:

Current behavior

Right now we show code above or below the example, or not at all, and there is no way to toggle it.

The Value Add

  • Consistency
  • Conciseness

Guidance

  • Understand how the documentation website is built and what's the general function of documentation components
  • Familiarize yourself closely with the DocsShow and DocsShowCode and how they are used on documentation pages:
  • Then create a new component DocsExample that produces the "Desired behavior"
    • Under the hood, this component should utilize DocsShow to render the example
    • However it shouldn't internally use DocsShowCode since in some situations, we need to provide more code snippets in different languages related to one example. Therefore, DocsShowCode will be provided from outside as demonstrated above.
    • Be careful to not refactor DocsShow and DocsShowCode to not cause regressions in the current documentation website

Out of scope

At this stage, we only want to focus on creating DocsExample and using it at one place to demonstrate it works. Please do not refactor all examples on all website pages with it.

Acceptance criteria

  • There is a new DocsExample documentation component as specified above
  • DocsExample internally utilizes DocsShow
  • DocsExample internally doesn't utilize DocsShowCode but rather receives it via the #code slot
  • DocsExample can render multiple DocsShowCode snippets in various languages
  • There are no regressions in the documentation places that use DocsShow and DocsShowCode
  • DocsExample is used in the given KCardGrid documentation example
@MisRob MisRob added category: supporting code Implementation of the system P2 - normal Priority: Nice to have help wanted Open source contributors welcome size: medium good first issue Self-contained, straightforward, low-complexity labels Nov 14, 2024
@MisRob
Copy link
Member Author

MisRob commented Nov 14, 2024

Labeling as "good first issue" since its pretty straightforward and can be tested easily, but note that it's medium size. Furthermore, if it's your first encounter with the documentation website, some time will be needed to understand the current documentation mechanism well.

@chetan21122004
Copy link

Hi @MisRob, I’m a beginner in open source and have worked on a task for the KCardGrid component. Could you please assign it to me? Also, I’m unsure if I’m doing it correctly, your feedback would be really helpful.
https://github.com/user-attachments/assets/fbb75faa-a394-4e56-8295-560e09b5ee8b

@MisRob
Copy link
Member Author

MisRob commented Nov 20, 2024

Hi @chetan21122004, thanks a lot! I think this could be a nice issue for you if you spend time studying the guidance and try to follow it closely. Is all clear and can you understand the relationship of this task to the Docs.. components?

From the user point of view, your recording looks like a lovely start. Could we rather do slide down/up animation similar to the Vuetify example referenced in the issue? Also, the example should stay visible below the code:

Clicking it would show/hide the code sample(s) above the card grid:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: supporting code Implementation of the system good first issue Self-contained, straightforward, low-complexity help wanted Open source contributors welcome P2 - normal Priority: Nice to have size: medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants