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

Request component markup via cURL #391

Open
Wolfr opened this issue Jul 6, 2021 · 5 comments
Open

Request component markup via cURL #391

Wolfr opened this issue Jul 6, 2021 · 5 comments

Comments

@Wolfr
Copy link
Contributor

Wolfr commented Jul 6, 2021

Feature request to be able to request component via cuRL. E.g.

curl -O http://projectname.company.com/styleguide/components/c-contact-card/c-contact-card-1.html

Resulting output:

<div class="c-panel">
    <div class="c-panel__body">
        <div class="c-contact-card">
            <div class="u-spacer-bottom">
                <div class="c-avatar c-avatar--large">PB</div>
                <div class="c-contact-card__title">Pagac Buildings</div>
                <p class="c-body-2">Construction</p>
            </div>
            <ul class="c-tag-list">
                <li class="c-tag">Residences</li>
                <li class="c-tag">Durable</li>
            </ul>
        </div>
    </div>
</div>
@thusc
Copy link
Contributor

thusc commented Jul 6, 2021

There are two use cases that make this feature interesting:

  • Given an HTML such as the one presented above, it is possible to diff it against another implementation (e.g. using Jinja2 templates in the Python world, or Mustache). Although it can be seen as duplication, it means the design system as implemented in Bedrock can be used as a source of truth (in an automated way) for others implementations. In other words, designers can update the design system or add to it and an automated tool can diff it so that developers from other teams can propagate the necessary changes to their own implementations. (This also means that a way to list all available components is needed).

    (An alternative to serving those partial HTML is to be able to generate them from the command-line.)

  • Another reason is that partial HTML (fragments) can also be used as-is with some frontend technologies such as htmx. It seems a bit old school to serve HTML instead of something like JSON but is regaining traction (see e.g. Phoenix LiveView, and imho is just useful indenpendently of the hype). This means that some pages presented in Bedrock could actually use htmx (or similar) without requiring anything else than Bedrock itself.

@Wolfr
Copy link
Contributor Author

Wolfr commented Jul 6, 2021

Thank you @thusc for your clarificiation.

BTW above example is a combined component so probably not the neatest example.

@thusc
Copy link
Contributor

thusc commented Jul 6, 2021

Actually combined components are quite useful, because it means that you can also validate the logic to combine them used by other implementations (e.g. should I wrap a table in an additional div when I embed it in a more complete page ?).

thusc added a commit to thusc/bedrock that referenced this issue Jul 13, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Jul 14, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Jul 14, 2021
thusc added a commit to thusc/bedrock that referenced this issue Jul 14, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Jul 17, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Jul 18, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Jul 18, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Jul 18, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Jul 18, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Aug 4, 2021
This is supposed to contribute to
usebedrock#391.
@thusc
Copy link
Contributor

thusc commented Oct 25, 2021

As an example for the second bullet points above about the fragments, consider those three pages:

We can clearly see how, starting with the first screen, we could use something like an AJAX call to only fetch the HTML fragment containing the result of the simulation, and inject it at the right place to avoid a full page refresh when submitting the form. For instance this can be achieved with htmx.

thusc added a commit to thusc/bedrock that referenced this issue Nov 27, 2021
thusc added a commit to thusc/bedrock that referenced this issue Nov 27, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Nov 27, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Nov 27, 2021
This is supposed to contribute to
usebedrock#391.
thusc added a commit to thusc/bedrock that referenced this issue Nov 27, 2021
This is supposed to contribute to
usebedrock#391.
noteed added a commit to hypered/smart-design that referenced this issue Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants