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

Add VA Design System Storybook link for mobile components #3810

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/_components/button/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ anchors:

#### Base - Primary

{% include storybook-preview.html height="100px" story="button--base" base_path=site.storybook_mobile_path link_text="va-mobile__button--base" %}
{% include storybook-preview.html height="100px" story="button--base" link_text="va-mobile__button--base" is_mobile=true %}
Copy link
Contributor Author

@jamigibbs jamigibbs Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a component is flagged as is_mobile=true like this, iframe preview and Storybook documentation links will automatically adjust depending on the component type in the storybook-preview.html file. In both cases, the Storybook link will bring the user to the design.va.gov Storybook instance.


#### Base - Secondary

{% include storybook-preview.html height="100px" story="button--base-secondary" base_path=site.storybook_mobile_path link_text="va-mobile__button--base-secondary" %}
{% include storybook-preview.html height="100px" story="button--base-secondary" link_text="va-mobile__button--base-secondary" is_mobile=true %}

#### Destructive

{% include storybook-preview.html height="100px" story="button--destructive" base_path=site.storybook_mobile_path link_text="va-mobile__button--destructive" %}
{% include storybook-preview.html height="100px" story="button--destructive" link_text="va-mobile__button--destructive" is_mobile=true %}

## Usage

Expand Down
14 changes: 9 additions & 5 deletions src/_includes/storybook-preview.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{% assign storybook_path = site.storybook_path %}
{% if include.base_path %}
{% assign storybook_path = include.base_path %}
{% endif %}
{% if include.is_mobile %}{% assign storybook_path = site.storybook_mobile_path %}{% endif %}
{% assign storybook_iframe_path = storybook_path | append: '/iframe.html?id=' | append: include.story | append: '&viewMode=story' %}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference here between the web and mobile component iframe preview is the base link which will be from either https://department-of-veterans-affairs.github.io/va-mobile-library/ or https://design.va.gov.

These root URLs are not clickable or displayed visually in the documentation. They are only used to load the component in the iframe.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. We eventually want https://department-of-veterans-affairs.github.io/va-mobile-library/ to go away and be rolled into design.va.gov. What do we need to do to not be dependent on the deployed github mobile "design system"?

Copy link
Contributor Author

@jamigibbs jamigibbs Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to do to not be dependent on the deployed github mobile "design system"?

@humancompanion-usds I am working on a discovery for that now! :) I see this approach as a bridge until a full integration can be done. There are a few different ways we can do it that look promising.

<div
class="site-showcase"
style="max-width: {{ include.width | default: '100%' }}"
>
<iframe
width="100%"
height="{{ include.height }}"
src="{{ storybook_path }}/iframe.html?id={{ include.story }}&amp;viewMode=story"
src="{{ storybook_iframe_path }}"
></iframe>
</div>

[{% if include.link_text %}<img aria-hidden="true" role="img" src="{{ site.baseurl }}/images/storybook.svg" class="site-component-resources-links__icon" width="16px" alt="Storybook logo">View {{ include.link_text}}{% else %}See this{% endif %} in Storybook]({{ storybook_path }}/?path=/docs/{{ include.story }})
{% assign story_name_prefix = '' %}
{% if include.is_mobile %}{% assign story_name_prefix = 'va-mobile_' %}{% endif %}
{% assign storybook_preview_path = site.storybook_path | append: '/?path=/story/' | append: story_name_prefix | append: include.story %}
Copy link
Contributor Author

@jamigibbs jamigibbs Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition here is to add the va-mobile_ prefix to the story name so that we can navigate to the design.va.gov Storybook documentation page for mobile components.


[{% if include.link_text %}<img aria-hidden="true" role="img" src="{{ site.baseurl }}/images/storybook.svg" class="site-component-resources-links__icon" width="16px" alt="Storybook logo">View {{ include.link_text}}{% else %}See this{% endif %} in Storybook]({{ storybook_preview_path }})
Loading