Skip to content

Commit 2f7d2b5

Browse files
committed
Panel: Move caret to its own wrapper
The caret is combined with the header content. It is usually rendered like this: > Some heading However, custom header contents, after markdown rendering, will be wrapped with block HTML tags such as <p> and <h1>, which will make browsers render a line break between the caret and header content: > Some heading Let's fix this by moving the caret to a separate div. Then, make everything inside a panel header be on a single line by using CSS 'display: inline-block' and 'width: ...', such that the width adds up to 100%. +--------+-----------------+---------+ | caret | header-content | buttons | | (32px) | (100% - 32 - 32)| (32px) | +--------+-----------------+---------+ Thanks to @nusjzx for providing the fix to the button-wrapper in PR MarkBind#86, in which his use of 'calc(100% - 32px)' provided a source of inspiration for this fix. His fix in that PR is incorporated into this commit because without it, the responsive design will not work. An alternative fix considered was to use md.renderInline(). However, md.renderInline() does not render markdown headings. Another alternative fix was to insert the caret directly inside the header content. However, after PR MarkBind#74, MarkBind#81 and MarkBind#83 were merged, new problems continue to emerge. These problems are reported as comments in these pages: - MarkBind#74 - MarkBind#81 - MarkBind#83 - MarkBind/markbind#373 - MarkBind/markbind#383 As such, the PRs for this alternative fix has been reverted by the previous commits before this commit.
1 parent b11037f commit 2f7d2b5

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/Panel.vue

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
<div :class="['card-header',{'header-toggle':isExpandableCard}, cardType, borderType]"
1717
@click.prevent.stop="isExpandableCard && toggle()"
1818
@mouseover="onHeaderHover = true" @mouseleave="onHeaderHover = false">
19-
<div class="header-wrapper">
19+
<div class="caret-wrapper">
2020
<span :class="['glyphicon', localExpanded ? 'glyphicon-chevron-down' : 'glyphicon-chevron-right']" v-show="showCaret"></span>
21+
</div>
22+
<div class="header-wrapper">
2123
<slot name="header">
2224
<div :class="['card-title', cardType, {'text-white':!isLightBg}]" v-html="headerContent"></div>
2325
</slot>
@@ -316,15 +318,21 @@
316318
margin: 0px !important;
317319
}
318320
321+
.caret-wrapper {
322+
float: left;
323+
display: inline-block;
324+
width: 32px;
325+
}
326+
319327
.header-wrapper {
320328
display: inline-block;
321-
width: 72%;
329+
width: calc(100% - 32px - 96px);
322330
}
323331
324332
.button-wrapper {
325333
float: right;
326334
display: inline-block;
327-
width: 28%;
335+
width: 96px;
328336
}
329337
330338
.header-toggle {
@@ -403,12 +411,21 @@
403411
/* Bootstrap extra small(xs) responsive breakpoint */
404412
@media (max-width: 575.98px) {
405413
414+
.caret-wrapper {
415+
float: left;
416+
display: inline-block;
417+
width: 32px;
418+
}
419+
406420
.header-wrapper {
407-
width: 88%;
421+
display: inline-block;
422+
width: calc(100% - 32px - 32px);
408423
}
409424
410425
.button-wrapper {
411-
width: 12%;
426+
float: right;
427+
display: inline-block;
428+
width: 32px;
412429
}
413430
414431
.card-body {

0 commit comments

Comments
 (0)