-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Refactor underline nav #377
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 from me.
I went through this PR and changed our stories to use storiesFromMarkdown. I also fixed the function to convert any octicons rails tags to a react component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! I have some minor feedback on class names and a couple of nested styles, and a bit more feedback on documentation, but the majority of this looks 👌 ✨
Sorry this ended up being so late today, hopefully it won't be too hard to update class names in your github pr but let me know if you need a hang with that.
border-bottom: 1px solid $gray-200; | ||
} | ||
|
||
.UnderlineNav-items { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel a little worried having UnderlineNav-items
and UnderlineNav-item
will be a bit confusing and not immediately obvious what they do. Could we change UnderlineNav-items
to UnderlineNav-body
? That's a pattern we use elsewhere and I think it makes sense because you have actions
to handle other content. Otherwise best I could think of was UnderlineNav-items-container
or wrapper
but they get a little long 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to UnderlineNav-body
👍
text-align: center; | ||
border-bottom: 2px solid transparent; | ||
|
||
.Counter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to avoid nesting other component selectors like this because it creates dependencies and means overriding if we want to act differently. We could just use the ml-1
utility. How strongly do you feel this needs to be built into the pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this from the component. My only concern is that people will use inconsistent spacing, but I think it needs to be flexible because markup spacing affects this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this, and the other similar scenarios, are tricky. This is where I feel like we should handle the Counter
styling in context with the UnderlineNav
in other parts of the code (say helpers or something), rather than Sass. Handling it in the Sass means adding additional classes to apply to components that may already require a number of classes. That's not the worst but can feel like overkill and be a contributor to CSS bloat. We don't have a good solution for handling elsewhere in the code base right now, but it keeps coming up and is something that's on our radar. If we start to see this particular use case being styled incorrectly, then the best option is to have another class to apply to the Counter
rather than nesting it.
margin-left: $spacer-1; | ||
} | ||
|
||
.octicon { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar thoughts here to nesting Counter
. We could have an element class to account for it, such as UnderlineNav-octicon
as utilities won't work because you need the hover styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the spacing from the component (same concern as Counter) but kept the color styles in under .UnderlineNav-octicon
|
||
.container-lg, | ||
.container-md, | ||
.container-xl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here re nesting other Primer styles. UnderlineNav-container
may work? It's a little bit of a quirky one and potentially could be done with utilities but I can image this tripping people up so probably good to offer it as part of the component styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to .UnderlineNav-container
👍
modules/primer-navigation/README.md
Outdated
@@ -93,12 +93,123 @@ You can also add optional headings to a menu. Feel free to use nearly any semant | |||
</nav> | |||
``` | |||
|
|||
## Underline nav | |||
|
|||
`.UnderlineNav` is navigation that is typically used at the top of a page as the main page navigation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be worded better, it says navigation twice and descriptions could be a little more helpful. Suggest something like this but feel free to edit:
Use
UnderlineNav
to style navigation with a minimal underlined selected state. This component comes with variations to accommodate icons, counters, and button actions; and is typically used for navigation placed at the top of the page.
modules/primer-navigation/README.md
Outdated
</nav> | ||
``` | ||
|
||
Use `.UnderlineNav-actions` to use another element alongside the underline nav |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use is used twice here, could be worded better, suggest something like this:
Use
.UnderlineNav-actions
to place another element, such as a button, to the opposite side of the navigation items.
modules/primer-navigation/README.md
Outdated
</nav> | ||
``` | ||
|
||
You can right align the navigation with `.UnderlineNav--right`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep in style with our newer docs (i.e. less wordy and command tense), suggest changing this to:
Use
.UnderlineNav--right
to right align the navigation.
modules/primer-navigation/README.md
Outdated
</nav> | ||
``` | ||
|
||
This also works when adding actions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest changing description to: UnderlineNav--right
also works with when used with UnderlineNav-actions
.
modules/primer-navigation/README.md
Outdated
``` | ||
|
||
|
||
The navigation will work with added counters and/or octicons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, use a more commanding tone, such as:
Counters
andocticons
can be used with navigation items:
modules/primer-navigation/README.md
Outdated
</nav> | ||
``` | ||
|
||
Use `.UnderlineNav--full` to use a container within the components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting change wording to something like:
Use
UnderlineNav--full
in combination with container styles to make navigation fill the width of the container.
I couldn't find a way to avoid using "container" twice but I think it's okay.
@broccolini this is ready for review again! ✨ |
modules/primer-navigation/README.md
Outdated
@@ -93,12 +93,118 @@ You can also add optional headings to a menu. Feel free to use nearly any semant | |||
</nav> | |||
``` | |||
|
|||
## Underline nav | |||
|
|||
Use `.UnderlineNav` to style navigation with a minimal underlined selected state. This component comes with variations to accommodate icons, counters, and button actions; and is typically used for navigation placed at the top of the page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we need to remove that it accommodates counters becaase of the Sass changes 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to:
Use
.UnderlineNav
to style navigation with a minimal underlined selected state, typically used for navigation placed at the top of the page. This component comes with variations to accommodate icons, containers, and other content.
It's a little wordy, so let me know if you have suggestions!
text-align: center; | ||
border-bottom: 2px solid transparent; | ||
|
||
.Counter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this, and the other similar scenarios, are tricky. This is where I feel like we should handle the Counter
styling in context with the UnderlineNav
in other parts of the code (say helpers or something), rather than Sass. Handling it in the Sass means adding additional classes to apply to components that may already require a number of classes. That's not the worst but can feel like overkill and be a contributor to CSS bloat. We don't have a good solution for handling elsewhere in the code base right now, but it keeps coming up and is something that's on our radar. If we start to see this particular use case being styled incorrectly, then the best option is to have another class to apply to the Counter
rather than nesting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thank you so much for working on this! 💖 I just have one small comment, otherwise this looks good to merge
…into underline-nav
This refactors the underline nav component and and adds documentation to the Navigation component. As discussed here, this:
/cc @primer/ds-core