Skip to content

Commit

Permalink
SideNav::List::Title: wrap text of long strings (HDS-3047) (#1899)
Browse files Browse the repository at this point in the history
Co-authored-by: Cristiano Rastelli <cristiano.rastelli@hashicorp.com>
  • Loading branch information
KristinLBradley and didoo committed Jan 24, 2024
1 parent d6d3588 commit 6a903ef
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-emus-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hashicorp/design-system-components": patch
---

`SideNav::List::Title`, `SideNav::List::BackLink`, `SideNav::List::Link`: fixed issue with long text strings without spaces not wrapping
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,18 @@
// (LIST) TITLE

.hds-side-nav__list-title {
display: flex;
align-items: center;
min-height: var(--token-side-nav-body-list-item-height);
margin-top: var(--token-side-nav-body-list-margin-vertical);
padding: 9px var(--token-side-nav-body-list-item-padding-horizontal); // 8px = (min-height - body-100-line-height) / 2
color: var(--token-side-nav-color-foreground-faint);
overflow-wrap: break-word;

// Remove margin from title at top of all list-items & lists
.hds-side-nav__list-wrapper:first-child .hds-side-nav__list-item:first-child > & {
margin-top: 0;
}
}


// LIST (root elements)

.hds-side-nav__list-wrapper, // <nav> element
Expand Down Expand Up @@ -147,8 +145,11 @@
// LIST ITEM > INNER ELEMENTS

.hds-side-nav__list-item-text {
min-width: 0;
max-width: 100%;
color: var(--token-side-nav-color-foreground-primary);
text-align: left;
overflow-wrap: break-word;
}

.hds-side-nav__list-item-icon-leading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export default class PlaceholderIndexComponent extends Component {
if (this.args.background) {
styles.push(`background: ${this.args.background}`);
}
if (this.args.flex) {
styles.push(`flex: ${this.args.flex}`);
}

return styles.length > 0 ? htmlSafe(styles.join('; ')) : undefined;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@
</Hds::SideNav::List::Item>
</ul>
</SF.Item>
<SF.Item @label="With very long text and no spaces">
<ul class="shw-component-sim-side-nav-body">
<Hds::SideNav::List::Title>ThisIsLongTextThatShouldWrapToTwoLinesAndNotOverflow</Hds::SideNav::List::Title>
<Hds::SideNav::List::Item>
<Shw::Placeholder @height="108px" @text="following content" />
</Hds::SideNav::List::Item>
</ul>
</SF.Item>
</Shw::Flex>

<Shw::Divider @level={{2}} />
Expand Down Expand Up @@ -616,12 +624,12 @@
</SG.Item>
<SG.Item @label="Icon + text + yielded content">
<Hds::SideNav::List::Link @icon="boundary" @text="Boundary">
<Shw::Placeholder @height="20px" @text="yielded content" />
<Shw::Placeholder @height="20px" @width="auto" @flex="1 1 0" @text="yielded content" />
</Hds::SideNav::List::Link>
</SG.Item>
<SG.Item @label="With hasSubItems">
<Hds::SideNav::List::Link @icon="boundary" @text="Boundary" @hasSubItems={{true}}>
<Shw::Placeholder @height="20px" @text="yielded content" />
<Shw::Placeholder @height="20px" @width="auto" @flex="1 1 0" @text="yielded content" />
</Hds::SideNav::List::Link>
</SG.Item>
<SG.Item @label="Text with no style">
Expand Down Expand Up @@ -723,6 +731,11 @@
<Hds::SideNav::List::BackLink @text="This is a long text that should go on two lines" @href="#" />
</ul>
</SF.Item>
<SF.Item @label="With very long text and no spaces">
<ul class="shw-component-sim-side-nav-body">
<Hds::SideNav::List::BackLink @text="ThisIsLongTextThatShouldWrapToTwoLinesAndNotOverflow" @href="#" />
</ul>
</SF.Item>
</Shw::Flex>

<Shw::Text::H4>States</Shw::Text::H4>
Expand Down

2 comments on commit 6a903ef

@vercel
Copy link

@vercel vercel bot commented on 6a903ef Jan 24, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

hds-showcase – ./packages/components

hds-showcase.vercel.app
hds-showcase-git-main-hashicorp.vercel.app
hds-showcase-hashicorp.vercel.app
hds-components-hashicorp.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 6a903ef Jan 24, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.