This repository was archived by the owner on Jul 12, 2020. It is now read-only.
forked from yuche/vue-strap
-
Notifications
You must be signed in to change notification settings - Fork 20
Enable seamless Panel's caret to stay inline for custom header slots #83
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chng-Zhi-Xuan
left a comment
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.
Tested and works well for even <p> tags with slot attribute. 👍
src/Panel.vue
Outdated
| const wrappedElementName = jQuery(headerInnerHTML).attr("name"); | ||
| this.$refs.headerWrapper.innerHTML = | ||
| jQuery(headerInnerHTML).unwrap().prepend(this.caretHtml + ' ') | ||
| .wrap(`<${wrappedElementName}></${wrappedElementName}>`).parent().html(); |
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.
Should abstract this to a method for code quality and maintainability. Maybe insertCaretInsideCustomHeader?
76026af to
bb4cf67
Compare
bb4cf67 to
11e6bee
Compare
Member
Author
|
Update:
|
Chng-Zhi-Xuan
approved these changes
Jul 23, 2018
yamgent
added a commit
to yamgent/vue-strap
that referenced
this pull request
Jul 27, 2018
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.
yamgent
added a commit
to yamgent/vue-strap
that referenced
this pull request
Jul 27, 2018
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.
yamgent
added a commit
to yamgent/vue-strap
that referenced
this pull request
Jul 27, 2018
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.
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [X] Enhancement to an existing feature
What is the rationale for this request?
Previously, on #74, we enable seamless Panel's caret to stay inline.
However, that logic only works if it is not using custom header slots, so the caret will break for custom cases, like in here. This can be very irritating for the author.
What changes did you make? (Give an overview)
This PR will fix the problem mentioned above, by implementing the logic for custom header slots.
Provide some example code that this change will affect:
NIL
Is there anything you'd like reviewers to focus on?
NIL
Testing instructions:
npm run build, and copyvue-strap.min.jsto MarkBind repository.index.md:markbind serve. Ensure that all the panel headings are inline even when the window is resized to be very small.