Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove UIKit classes #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

vladyio
Copy link

@vladyio vladyio commented Oct 27, 2019

Hi, thanks for your work! This is not a PR to merge, it's kind of a suggestion for you which came as a result of my own needs.

  1. I work with Jekyll 4.0, so I had to update the dependency version.
  2. Adding UIKit as an additional dependency wasn't an option for me, so I modified the template so it doesn't depend on the whole CSS/JS set from UIKit. This is a workaround that works in my case, most probably you can use it as an inspiration to get rid of UIKit in future.

To make things work I also add some CSS and JS to my project (this code is from w3schools)

Add this to your `head.html`:
 <script>
   document.addEventListener("DOMContentLoaded", function(){
     document.getElementById("default").click();
   });

   function showTab(evt, tabId) {
     // Declare all variables
     var i, tabcontent, tablinks;

     // Get all elements with class="tabcontent" and hide them
     tabcontent = document.getElementsByClassName("tabcontent");
     for (i = 0; i < tabcontent.length; i++) {
       tabcontent[i].style.display = "none";
     }

     // Get all elements with class="tablinks" and remove the class "active"
     tablinks = document.getElementsByClassName("tablinks");
     for (i = 0; i < tablinks.length; i++) {
       tablinks[i].className = tablinks[i].className.replace(" active", "");
     }

     // Show the current tab, and add an "active" class to the button that opened the tab
     document.getElementById(tabId).style.display = "block";
     evt.currentTarget.className += " active";
   }
 </script>
Add this to your CSS assets:
/* TABS */

/* Style the tab */
.tab {
  overflow: hidden;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
}

/* Style the buttons that are used to open the tab content */
.tab button {
  background-color: inherit;
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
}

/* Change background color of buttons on hover */
.tab button:hover {
  background-color: #ddd;
}

/* Create an active/current tablink class */
.tab button.active {
  background-color: #ccc;
}

/* Style the tab content */
.tabcontent {
  display: none;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-top: none;
}

.tabcontent {
  animation: fadeEffect 0.5s; /* Fading effect takes 1 second */
}

/* Go from zero to full opacity */
@keyframes fadeEffect {
  from {opacity: 0.5;}
  to {opacity: 1;}
}

/* END TABS */
Resulting control

@vladyio vladyio mentioned this pull request Oct 27, 2019
@tranlv
Copy link

tranlv commented May 29, 2020

@vladyio
Copy link
Author

vladyio commented May 31, 2020

Hi @vladyio , which css asset should I add into ?https://github.com/tranlyvu/distributedsystemsblog.com/tree/master/_sass/minimal-mistakes

thanks

There's no difference which Sass file you choose there, you can even create a separate one exclusively for this purpose.

@nickhuangcyh
Copy link

@vladyio Thank you. You just save my day.

nickhuangcyh added a commit to nickhuangcyh/blog that referenced this pull request Feb 13, 2022
@oleg-nenashev
Copy link

The patch from @vladyio works well for pages when there is only one tabbed section, but breaks otherwise. In wiremock/wiremock.org#165 I took those scripts and reworked them to support multiple appearances on the page, and also added a "Copy" button

@clustergarage If you are still interested in this project, I can create a PR here with proper integration for @vladyio's commits. If anyone is interested to co-maintain, I can create a fork with the patches in a separate repo

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.

4 participants