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 docs for {Flex,FlexItem}Component #190

Merged
merged 17 commits into from
Feb 8, 2021
Merged

Conversation

srt32
Copy link
Contributor

@srt32 srt32 commented Feb 3, 2021

This change adds docs for FlexComponent and FlexItemComponent. There is a lot we could show here and I went with a handful of examples that exercises most of the knobs but not all the possible options.

image

image

@vercel
Copy link

vercel bot commented Feb 3, 2021

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

🔍 Inspect: https://vercel.com/primer/view-components/j8muzbei8
✅ Preview: https://view-components-git-fork-srt32-st-docs-for-flex-item.primer.vercel.app

@vercel vercel bot temporarily deployed to Preview February 3, 2021 23:18 Inactive
@vercel vercel bot temporarily deployed to Preview February 3, 2021 23:43 Inactive
@srt32
Copy link
Contributor Author

srt32 commented Feb 3, 2021

I feel like our current layout for PVC is not working well for something complex like flex. Comparing https://primer.style/css/utilities/flexbox#align-items to my WIP here on https://view-components-git-fork-srt32-st-docs-for-flex-item.primer.vercel.app/view-components/components/flex, I am not sure this page is going to scale nicely...

@vercel vercel bot temporarily deployed to Preview February 4, 2021 16:19 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 16:29 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 17:15 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 17:31 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 17:33 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 19:52 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 20:04 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 20:06 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 20:07 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 20:12 Inactive
@vercel vercel bot temporarily deployed to Preview February 4, 2021 20:14 Inactive
@srt32 srt32 marked this pull request as ready for review February 4, 2021 20:15
@srt32 srt32 changed the title Add docs for FlexItemComponent Add docs for {Flex,FlexItem}Component Feb 4, 2021
#
# @param justify_content [Symbol] Use this param to distribute space between and around flex items along the main axis of the container. <%= one_of(Primer::FlexComponent::JUSTIFY_CONTENT_OPTIONS) %>
# @param inline [Boolean] Defaults to false.
# @param flex_wrap [Boolean] Defaults to nil.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a boolean but also defaults to nil... what's the right thing here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@srt32 that's a good question. What do we do in Primer React?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question!

I also just noticed this on https://primer.style/components/Flex

Previously, a Flex.Item component was used for flex item specific properties; Box now contains all those properties and should be used in its place.

Maybe we should deprecate FlexItem?

I am having a hard time grokking the PRC (I'm new to the codebase) but it looks to mainly delegate to Box, which delegates to styleSystem.

The API though is directly

<Flex flexWrap="nowrap">

Copy link
Contributor

Choose a reason for hiding this comment

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

@emplums what do you think? I'd generally lean towards deprecating all of the Flex-related components and just encourage the usage of Box with the flex-related system arguments.

Copy link
Contributor

Choose a reason for hiding this comment

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

@joelhawksley the proposed game plan for PRC is that Box and Flex will have all the same properties, the only difference is Flex will have display: flex set by default. The idea is that it will be handy shortcut from having to type display: flex over and over, and will still keep the ease of grokking the code to see exactly where flex is being used

@vercel vercel bot temporarily deployed to Preview February 8, 2021 17:23 Inactive
@vercel vercel bot temporarily deployed to Preview February 8, 2021 17:36 Inactive
@srt32
Copy link
Contributor Author

srt32 commented Feb 8, 2021

This PR is ready for another look. I'd love to get this merged so we can call everything existing documented as we sort out where we're going with Flex.

# <div class="p-5 border bg-gray-light">Item 1</div>
# <div class="p-5 border bg-gray-light">Item 2</div>
# <div class="p-5 border bg-gray-light">Item 3</div>
# <%= render(Primer::BoxComponent.new(p: 5, classes: "border bg-gray-light")) { "Item 1" } %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. Are there not system arguments for the border/bg classes?

Copy link
Contributor Author

@srt32 srt32 Feb 8, 2021

Choose a reason for hiding this comment

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

Attempting to not get bogged down here...

<%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, border: true)) { "Item 1" } %>

which is what I assumed would work, did not for border (I will update for bg!):

image

which we think is because of

elsif BORDER_KEYS.include?(key)
memo[:classes] << "border-#{val.to_s.dasherize}"

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh! Looks like we need to add support for border: true somehow. Mind filing a separate issue?

@vercel vercel bot temporarily deployed to Preview February 8, 2021 18:01 Inactive
flex_wrap false
end

content do
Copy link
Contributor

Choose a reason for hiding this comment

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

@manuelpuyol is there anything you think we could do to avoid the html_safe here?

@vercel vercel bot temporarily deployed to Preview February 8, 2021 18:11 Inactive
@srt32 srt32 merged commit b74da66 into primer:main Feb 8, 2021
@srt32 srt32 deleted the st-docs-for-flex-item branch February 8, 2021 18:20
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.

None yet

3 participants