Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 130246f

Browse files
touficbatacheyeelan0319
authored andcommitted
fix(toolbar): Make Toolbar accommodated very long section
Close #508
1 parent ea8f862 commit 130246f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

packages/mdc-toolbar/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,20 @@ of the toolbar (respectively).
9696
```
9797

9898
Toolbar sections are laid out using flexbox. Each section will take up an equal
99-
amount of space within the toolbar.
99+
amount of space within the toolbar by default. But you can accommodate very long section (very long title) by adding `mdc-toolbar__section--shrink-to-fit` to other sections.
100+
101+
```
102+
<div class="mdc-toolbar>
103+
<div class="mdc-toolbar__row">
104+
<section class="mdc-toolbar__section mdc-toolbar__section--align-start">
105+
<span class="mdc-toolbar__title">This is a super super super super long title</span>
106+
</section>
107+
<section class="mdc-toolbar__section mdc-toolbar__section--align-end mdc-toolbar__section--shrink-to-fit">
108+
<a class="material-icons search align-icons" aria-label="Search" alt="Search">search</a>
109+
</section>
110+
</div>
111+
</div>
112+
```
100113

101114
### Toolbar title
102115

@@ -139,3 +152,4 @@ The provided modifiers are:
139152
| `mdc-toolbar--fixed` | Make toolbar fixed to top of screen. |
140153
| `mdc-toolbar__section--align-start` | Makes section aligns to the start. |
141154
| `mdc-toolbar__section--align-end` | Makes section aligns to the end. |
155+
| `mdc-toolbar__section--shrink-to-fit`| Makes section takes the width of its content.|

packages/mdc-toolbar/mdc-toolbar.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ $mdc-toolbar-mobile-breakpoint: 599px;
5959
align-items: flex-start;
6060
justify-content: center;
6161
z-index: 1;
62+
overflow: hidden;
6263

6364
&--align-start {
6465
justify-content: flex-start;
@@ -74,6 +75,9 @@ $mdc-toolbar-mobile-breakpoint: 599px;
7475
&__title {
7576
@include mdc-typography(title);
7677

78+
overflow: hidden;
79+
text-overflow: ellipsis;
80+
white-space: nowrap;
7781
margin: 0;
7882
line-height: 1.5rem;
7983
}
@@ -97,3 +101,7 @@ $mdc-toolbar-mobile-breakpoint: 599px;
97101
margin-top: $mdc-toolbar-mobile-row-height;
98102
}
99103
}
104+
105+
.mdc-toolbar__section--shrink-to-fit {
106+
flex: none;
107+
}

0 commit comments

Comments
 (0)