-
Notifications
You must be signed in to change notification settings - Fork 20
Enable seamless Panel's caret to stay inline #74
Conversation
src/Panel.vue
Outdated
@click.stop="close()"> | ||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | ||
</button> | ||
<button type="button" :class="['popup-button', 'btn', isLightBg ? 'btn-outline-secondary' : 'btn-outline-light']" | ||
v-show="this.popupUrl !== null" | ||
v-show="((this.popupUrl !== null) && (isSeamless ? onHeaderHover : (!noCloseBool)))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, if no-close
is specified, but popup
is specified, the popup button still does not show. The user might have reasons to show the popup button even if he wants to hide the close button.
src/Panel.vue
Outdated
if (this.isSeamless) { | ||
return this.caretHtml + ' ' + this.inlineRenderedHeader; | ||
} | ||
return this.renderedHeader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, maybe everything can just use inline
then, since for non-seamless, it seems to not make a difference, there is no reason to do different rendering ways for different type of panels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor nits
src/Panel.vue
Outdated
@click.stop="close()"> | ||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | ||
</button> | ||
<button type="button" :class="['popup-button', 'btn', isLightBg ? 'btn-outline-secondary' : 'btn-outline-light']" | ||
v-show="this.popupUrl !== null" | ||
v-show="((this.popupUrl !== null) && (isSeamless ? onHeaderHover : true))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(isSeamless ? onHeaderHover : true))
is a form of p -> q
.
Therefore, this can be simplified to:
(this.popupUrl !== null) && (!isSeamless || onHeaderHover)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
src/Panel.vue
Outdated
} | ||
}, | ||
hasCustomHeader () { | ||
if (this.$slots.header) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be simplified to return this.$slots.header;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it will return either a null
object or a v-node
object, which is not a Boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about return this.$slots.header !== null;
then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong, it gives undefined
instead of null
. Will modify accordingly.
60d4d6f
to
096ecaf
Compare
Update
|
That panel header appears that way because it uses a custom header slot. We did not implement the logic to insert the caret inside the content, because the content here can literally be anything, so we cannot make any good assumptions. Hence, custom headers will always have the caret outside the content, See the original post:
|
Try styling the slot as |
Tried it, didn't work. :S |
I see. Looks like there is no easy way around it. Still, we should not give up entirely. I use slots a lot because my headings often contains span elements (e.g., to add stars of a certain color). Would the introduction of a May be create a separate issue and explain the exact problem? |
Found the reason why the caret breaks on your website. It is because your custom headers were using the
As to why I was able to somehow "replicate" the issue on my side, I realize that this does not happen if the custom slot header is declared with |
@damithc we found another issue with the implementation of caret with the panel that may be related to this bug, so you can ignore the above solution for now, as we will try to fix it on our side. |
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. Therefore, this commit shall be viewed as the canonical fix for issue MarkBind/markbind#337.
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.
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.
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [x] Enhancement to an existing feature
Fixes MarkBind/markbind#337
What is the rationale for this request?
Seamless Panels have its caret pushed to the previous line when the Panel width is too small. The expected behaviour is having the header text wrap around while having the caret inline.
What changes did you make? (Give an overview)
v-html="headerContent"
.slot="header"
, the problem will re-emerge as there is no way to insert the caret inside the slotted element without usingCheerio / JQuery
.Is there anything you'd like reviewers to focus on?
Testing instructions:
npm run build
and paste the updatedvue-strap.min.js
into MarkBind's asset folder.markbind init
, author a seamless panel with a long header.markbind serve
and reduce window width.