Skip to content

Conversation

@jonahtanjz
Copy link
Contributor

@jonahtanjz jonahtanjz commented Jun 28, 2021

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • Others, please explain:

Overview of changes:
Resolves #1605.

Allow using of bootstrap display property class="d-print-none" to <tabs>, <tab-group> and <tab> which will exclude the entire tab, tab group or single tab respectively during printing. Remove usages of !important from these components to allow for overriding.

Anything you'd like to highlight / discuss:
NIL

Testing instructions:

  1. Create tab with d-print-none class
<tabs>
  <tab header="First tab">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ullamcorper ultrices lobortis.
  </tab>
  <tab header="Second tab">
    Some content of the second tab...
  </tab>
  <tab header="Third tab" class="d-print-none">
    Additional content from third tab...
  </tab>
  <tab-group header="Example Tab Group" class="d-print-none">
    <tab header="Tab Group 1">
      Some content in a tab group 1...
    </tab>
    <tab header="Tab Group 2">
      Some content in a tab group 2...
    </tab>
  </tab-group>
</tabs>
  1. Print the page
  2. Third tab and Example Tab Group should be excluded from the print preview

Proposed commit message: (wrap lines at 72 characters)
Support opt-out of printing certain tabs

Users may want to omit some tabs when printing.

Let's remove usages of !important in tabs so that
users are able to specify which tab components
to omit when printing using bootstrap's display
property.


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No blatantly unrelated changes
  • Pinged someone for a review!

@jonahtanjz jonahtanjz changed the title Add no-print attribute to tab Support opt-out of printing certain tabs Jun 28, 2021
Copy link
Contributor

@raysonkoh raysonkoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Have tested with some small examples and verified that it is working as intended.

Thanks @jonahtanjz!

@raysonkoh raysonkoh added this to the v3.0.4 milestone Jul 4, 2021
@damithc
Copy link
Contributor

damithc commented Jul 4, 2021

@MarkBind/active-devs let's do a release after this PR is merged.

@jonahtanjz
Copy link
Contributor Author

There's some changes to the implementation as discussed here #1605 (comment) @raysonkoh, this PR is not yet updated.

Prof @damithc, I will most likely make the changes and update the PR by tomorrow night!

@damithc
Copy link
Contributor

damithc commented Jul 4, 2021

Prof @damithc, I will most likely make the changes and update the PR by tomorrow night

Got it. Thanks @jonahtanjz

@jonahtanjz
Copy link
Contributor Author

@ang-zeyu Noticed that we can't really remove the current usages of !important as discussed #1605 (comment). Should we go with the implementation in this PR?

@jonahtanjz jonahtanjz force-pushed the add-print-opt-out-for-tabs branch from a0baf0d to 22089d0 Compare July 8, 2021 14:13
@jonahtanjz
Copy link
Contributor Author

@ang-zeyu Thanks for the suggestion 👍

Have changed v-show and d-print-block/flex to our own custom classes. Needed to add them individually to tab-group and tab so that we can increase the specificity from there. no-print is added to the global css file with !important so that it can be reused by other components as well once we have changed out all the other usages of !important.

@ang-zeyu ang-zeyu self-requested a review July 8, 2021 15:24
text-decoration: underline;
}
.printable-tab-group-header.tab-group-print-block {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ang-zeyu Thanks for the suggestion 👍

Have changed v-show and d-print-block/flex to our own custom classes. Needed to add them individually to tab-group and tab so that we can increase the specificity from there. no-print is added to the global css file with !important so that it can be reused by other components as well once we have changed out all the other usages of !important.

hmm... not sure I follow, what's the addition tab-group-print-block for? (the variants in tab.vue as well)

Copy link
Contributor Author

@jonahtanjz jonahtanjz Jul 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh seems like css that appear the latest will take effect anyway if same level of specificity. Initially added the tab-group-print-block so that it can help with increasing the specificity over the dispaly: none rules to ensure that it is always overriding it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh seems like css that appear the latest will take effect anyway if same level of specificity.

yes, one of the main reasons its named cascading style sheets. Let's remove it then!

margin: 0;
}
.tab-pane.hide {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would tab-pane-hide work instead? To avoid adding empty classes below to increase the specificity

Copy link
Contributor Author

@jonahtanjz jonahtanjz Jul 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there is a css rule in bootstrap, .tab-content > .active, that is more specific than .tab-pane-hide. We can also override that by using .tab-content > .tab-pane-hide in our scoped css but that would mean having to add .tab-content > .printable-tab-pane in the print rule as well. Should we go with this as this doesn't seem to resolve the empty classes issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using <style scoped>? It adds data-****** attributes under the hood and may be sufficient to override .tab-content > .active's specificity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this works 👍 I've updated the PR accordingly.

Copy link
Contributor

@ang-zeyu ang-zeyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm 👍. Thanks for accomodating the various change requests here!

@ang-zeyu ang-zeyu modified the milestones: v3.0.4, v3.0.5 Jul 17, 2021
@ang-zeyu ang-zeyu merged commit 1062bf1 into MarkBind:master Jul 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make 'print all tabs' optional

4 participants