Skip to content

Commit 6dfa974

Browse files
chihuahuajart
authored andcommitted
Use flex positioning for card headings (#479)
In comments within #430, @wchargin proposed that we use flex positioning to position elements within the header. That seems like a robust idea. This PR thus uses @wchargin's proposed method to implement @jart's original, space-efficient design of that makes use of both the left and right sides of headings (if space is available). This PR fixes the layout issues brought up in #430. This change also fixes #421.
1 parent 24483c7 commit 6dfa974

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

tensorboard/components/tf_card_heading/tf-card-heading-style.html

+11-7
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,29 @@
2222
<template>
2323
<style>
2424

25+
figcaption {
26+
width: 100%;
27+
}
28+
2529
/** Horizontal line of labels. */
2630
.heading-row {
2731
margin-top: -4px;
28-
clear: both;
32+
display: flex;
33+
flex-direction: row;
34+
flex-wrap: wrap;
2935
}
3036

3137
/** Piece of text in the figure caption. */
3238
.heading-label {
33-
float: left;
39+
flex-grow: 1;
3440
margin-top: 4px;
35-
/* TODO(@jart): Use proper width so overflow works. */
36-
text-overflow: ellipsis;
37-
overflow: hidden;
41+
max-width: 100%;
42+
word-wrap: break-word;
3843
}
3944

4045
/** Makes label show on the right. */
4146
.heading-right {
42-
float: right;
43-
margin-left: 0.5em;
47+
flex-grow: 0;
4448
}
4549
</style>
4650
</template>

tensorboard/components/tf_card_heading/tf-card-heading.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<template>
4242
<div class="container">
4343
<figcaption class="content">
44-
<div class="row">
44+
<div class="heading-row">
4545
<template is="dom-if" if="[[_nameLabel]]">
4646
<div itemprop="name" class="heading-label name">
4747
[[_nameLabel]]
@@ -56,7 +56,7 @@
5656
</template>
5757
</div>
5858
<template is="dom-if" if="[[_tagLabel]]">
59-
<div class="row">
59+
<div class="heading-row">
6060
<div class="heading-label">
6161
tag: <span itemprop="tag">[[_tagLabel]]</span>
6262
</div>

0 commit comments

Comments
 (0)