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

Update Do/Don't component API #184

Merged
merged 10 commits into from
Oct 1, 2020
Merged

Update Do/Don't component API #184

merged 10 commits into from
Oct 1, 2020

Conversation

colebemis
Copy link
Contributor

Problem

While creating design guidelines for Octicons, I ran into limitations with the Do/Don't component API that prevented me from rendering do/don't examples as I wanted.

I didn't want the images to scale to fill all the available space because I wanted to avoid the 1px grid lines appearing blurry. Instead, I wanted the images to keep their natural width and be centered inside a container with the same background color:

image

The current Do/Don't component API, however, did not allow me to control how images are rendered:

<Do src="https://example.com/do.png">
  Use brief and direct communication
</Do>

Solution

I updated the Do/Don't component API to allow consumers to control how images are rendered:

- <Do src="https://example.com/do.png">
-   Use brief and direct communication
- </Do>
+ <Do>
+   <img src="https://example.com/do.png" alt="" />
+   <Caption>Use brief and direct communication</Caption>
+ </Do>

This API allows me to create the Octicons design guidelines do/don't example (pictured above) like so:

<Do>
  <Flex bg="gray.1" justifyContent="center">
    <img src="https://example.com/do.png" alt="" />
  </Flex>
  <Caption>Use brief and direct communication</Caption>
</Do>

This API also allows people to create do/don't examples with more than just images. For example, using code in do/don't examples could be useful in CLI guidelines:

<DoDontContainer>
  <Do>
    <Code>✓ Checks passing</Code>
    <Caption>Use checks for success messages</Caption>
  </Do>
  <Dont>
    <Code>✓ Checks failing</Code>
    <Caption>Don't use checks for failure messages</Caption>
  </Dont>
</DoDontContainer>

image

@colebemis colebemis requested a review from emplums September 24, 2020 17:17
@vercel
Copy link

vercel bot commented Sep 24, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

doctocat – ./

🔍 Inspect: https://vercel.com/primer/doctocat/muh2rr2cb
✅ Preview: https://doctocat-git-do-dont-refactor.primer.vercel.app

gatsby-theme-primer-example – ./

🔍 Inspect: https://vercel.com/primer/gatsby-theme-primer-example/3fdx9al0k
✅ Preview: https://gatsby-theme-primer-example-git-do-dont-refactor.primer.vercel.app

Copy link
Contributor

@emplums emplums left a comment

Choose a reason for hiding this comment

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

👍 this seams reasonable!

@colebemis
Copy link
Contributor Author

FYI I'm going to hold off on merging this until I have changesets set up in this repo so I can test out the release process.

@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2020

🦋 Changeset detected

Latest commit: ea38980

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@primer/gatsby-theme-doctocat Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel vercel bot temporarily deployed to Preview – gatsby-theme-primer-example October 1, 2020 00:13 Inactive
@vercel vercel bot temporarily deployed to Preview – doctocat October 1, 2020 00:13 Inactive
@vercel vercel bot temporarily deployed to Preview – gatsby-theme-primer-example October 1, 2020 00:14 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants