Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Conversation

@yamgent
Copy link
Member

@yamgent yamgent commented Jul 23, 2018

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:

  1. Run npm run build, and copy vue-strap.min.js to MarkBind repository.
  2. Create a new MarkBind website with the following code in index.md:
<panel type="seamless">
<span slot="header" class="card-title">
This header won't break even if I used <code>card-title</code>, hooray!
</span>
</panel>

<panel type="seamless">
<span slot="header">
No breaking as <code>card-title</code> not used, hip hip hooray!
</span>
</panel>

<panel type="seamless" header="Normal seamless">
Normal seamless panel content.
</panel>
  1. Run markbind serve. Ensure that all the panel headings are inline even when the window is resized to be very small.

@yamgent yamgent requested a review from Chng-Zhi-Xuan July 23, 2018 07:51
Copy link

@Chng-Zhi-Xuan Chng-Zhi-Xuan left a 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();

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?

@yamgent yamgent force-pushed the seamless-panel-caret branch 2 times, most recently from 76026af to bb4cf67 Compare July 23, 2018 08:20
@yamgent yamgent force-pushed the seamless-panel-caret branch from bb4cf67 to 11e6bee Compare July 23, 2018 08:23
@yamgent
Copy link
Member Author

yamgent commented Jul 23, 2018

Update:

  • Changes requested made.

@yamgent yamgent added this to the v2.0.1-markbind.16 milestone Jul 24, 2018
@yamgent yamgent merged commit 576952c into MarkBind:master Jul 24, 2018
@yamgent yamgent deleted the seamless-panel-caret branch July 24, 2018 03:45
@damithc
Copy link

damithc commented Jul 25, 2018

Looks like the problem moved to a different place :-)

image

The code looks like this (in chapter.njk):

<panel type="seamless" expanded>
  <span slot="header" class="card-title"><include src="{{ level_location }}/text.md#title" /></span>

yamgent added a commit to yamgent/vue-strap that referenced this pull request Jul 27, 2018
…ret"

This reverts commit 576952c, reversing
changes made to 1ce9ce3.
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.
@yamgent yamgent mentioned this pull request Jul 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants