Skip to content

Commit ea3c78a

Browse files
pricopmdo
andauthored
Update nav link & pill items height (#42146)
* Update nav link & pill items height Currently, `link` and `nav-pills` items height sit at `36px` (because they don't have any borders), while `tab`, and `underline` sit at `38px`, which perfectly matches the height of `input` and `button` components. This PR adds an invisible border for the `link` and `nav-pills` items, so that all 4 `nav` variants share the exact same height, regardless of which is used, which makes it suitable to be used with other components, such as `input` or `buttons` for example, as described in this discussion: https://github.com/orgs/twbs/discussions/42145 without having discrepancy when it comes to elements height. * Update scss/_nav.scss Co-authored-by: Mark Otto <markdotto@gmail.com> * Shortened the code for borders & pill active states Shortened the code for borders by using `border` attribute. Also applied the correct background for pill shaped items. * Removed border from nav links in DocsSidebar Removed the invisible border so that the sidebar remains as condensed as it was before. --------- Co-authored-by: Mark Otto <markdotto@gmail.com>
1 parent d373999 commit ea3c78a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

scss/_nav.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ $nav-tokens: defaults(
2424
--nav-link-active-color: var(--fg-body),
2525
--nav-link-active-bg: var(--bg-2),
2626
--nav-link-disabled-color: var(--fg-4),
27+
--nav-link-border-width: var(--border-width),
2728
--nav-link-transition-property: "color, background-color, border-color",
2829
--nav-link-transition-timing: .15s ease-in-out,
2930
--nav-link-transition: var(--nav-link-transition-property) var(--nav-link-transition-timing),
@@ -56,8 +57,8 @@ $nav-pills-tokens: () !default;
5657
// stylelint-disable-next-line scss/dollar-variable-default
5758
$nav-pills-tokens: defaults(
5859
(
59-
--nav-pills-link-active-color: var(--component-active-color),
60-
--nav-pills-link-active-bg: var(--component-active-bg),
60+
--nav-pills-link-active-color: var(--primary-contrast),
61+
--nav-pills-link-active-bg: var(--primary-bg),
6162
),
6263
$nav-pills-tokens
6364
);
@@ -110,7 +111,7 @@ $nav-underline-tokens: defaults(
110111
text-decoration: none;
111112
white-space: nowrap;
112113
background: none;
113-
border: 0;
114+
border: var(--nav-link-border-width) solid transparent;
114115
@include border-radius(var(--border-radius));
115116
// @include font-size(var(--nav-link-font-size));
116117
@include transition(var(--nav-link-transition));
@@ -209,6 +210,7 @@ $nav-underline-tokens: defaults(
209210

210211
.nav-link {
211212
padding-inline: 0;
213+
border: 0;
212214
border-block-end: var(--nav-underline-border-width) solid transparent;
213215
@include border-radius(0);
214216

site/src/components/DocsSidebar.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const sidebar = getData('sidebar')
5656
<li>
5757
<a
5858
href={url}
59-
class:list={['nav-link bd-links-link', { active }]}
59+
class:list={['nav-link bd-links-link border-0', { active }]}
6060
aria-current={active ? 'page' : undefined}
6161
>
6262
{page.title}
@@ -88,7 +88,7 @@ const sidebar = getData('sidebar')
8888
<li>
8989
<a
9090
href={url}
91-
class:list={['nav-link bd-links-link', { active }]}
91+
class:list={['nav-link bd-links-link border-0', { active }]}
9292
aria-current={active ? 'page' : undefined}
9393
>
9494
{item.title}

0 commit comments

Comments
 (0)