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

w system argument hard to discover when looking for 'width' #2435

Closed
cheshire137 opened this issue Dec 8, 2023 · 2 comments · Fixed by #2451
Closed

w system argument hard to discover when looking for 'width' #2435

cheshire137 opened this issue Dec 8, 2023 · 2 comments · Fixed by #2451
Assignees
Labels

Comments

@cheshire137
Copy link
Member

I saw #638 was closed, but I just ran into the inability to apply the width-full class to a view component in version 0.15.1 of the primer_view_components gem. I'm trying to make this view component have the width-full class:

    Primer::BaseComponent.new(
      tag: :span,
      display: :flex,
      align_items: :center,
      justify_content: :space_between,
    )

If I pass width: :full, it adds a width="full" HTML attribute to the element, but if I pass classes: "width-full", it raises an exception:

Use System Arguments (https://primer.style/view-components/system-arguments) instead of Primer CSS class name width-full.

width: "100%" also results in a width="100%" HTML attribute on the element.

@kenyonj
Copy link
Contributor

kenyonj commented Dec 8, 2023

You can use the sys arg w for this:

pry(main)> puts helper.render Primer::BaseComponent.new(tag: :span, w: :full)
<span data-view-component="true" class="width-full"></span>

This is listed in the "Layout" section of https://primer.style/view-components/system-arguments

@cheshire137
Copy link
Member Author

Thank you! I saw width under HTML Attributes and thought it was the one I wanted:

screenshot of Primer system arguments docs page for HTML Attributes

-- https://primer.style/view-components/lookbook/pages/system_arguments

I see w under Layout, as you say, but it doesn't mention the word "width" at all. Same for h, which I'm guessing is similar but for height.

screenshot of Primer system arguments docs page for Layout

Maybe the docs could be updated so both arguments reference each other, and so w and h mention the words width and height?

@cheshire137 cheshire137 changed the title Can't set width-full on Primer::BaseComponent w system argument hard to discover when looking for 'width' Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants