"use strict"
// tab maker root
function TabMaker(tabButtons, tabItems, btnActive, tabActive, progressLine,dir, res) {
for (let i = 0; i < tabButtons.length; i++) {
tabButtons[i].addEventListener('click', function () {
for (let j = 0; j < tabButtons.length; j++) {
// tab button class active/remove
tabButtons[j].classList.remove(btnActive);
this.classList.add(btnActive);
// tab contents class active/remove
tabItems[j].classList.remove(tabActive);
tabItems[i].classList.add(tabActive);
}
if (progressLine) {
let singlePgWidth = 100 / tabItems.length;
if(dir==='width'){
progressLine.style.width = singlePgWidth * (i + 1) + '%';
}
else if(dir==='height'){
progressLine.style.height = singlePgWidth * (i + 1) + '%';
}
if(res && window.innerWidth < 768){
progressLine.style.height = 100 + '%';
progressLine.style.width = singlePgWidth * (i + 1) + '%';
}
}
})
}
}
// // tab one=== === === === === === === ===
const tabOneBtns = document.querySelectorAll('.sk-tab-one .sk-nav .sk-nav-link');
const tabOneContents = document.querySelectorAll('.sk-tab-one .sk-tab-content .sk-tab-pane');
TabMaker(tabOneBtns, tabOneContents, 'active-link', 'active-tab-pane');
.sk-tab-one {
display: flex;
padding-bottom: 70px;
}
.sk-tab-one .sk-nav {
display: flex;
flex-wrap: wrap;
padding-left: 0;
margin-bottom: 0;
list-style: none;
flex-direction: column;
margin-right: 35px;
}
.sk-tab-one .sk-nav-link {
background: 0 0;
border: 0;
border-radius: 8px;
display: block;
padding: 15px;
color: #30336b;
text-decoration: none;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out;
cursor: pointer;
margin-bottom: 15px;
font-weight: 700;
}
.sk-tab-one .sk-nav-link.active-link {
color: #fff;
background-color: #30336b;
}
.sk-tab-one .sk-tab-content .sk-tab-pane {
display: none;
transform: translateY(-110%);
transition: .5s;
}
.sk-tab-one .sk-tab-content .sk-tab-pane.active-tab-pane {
display: block;
transform: translateY(0);
}
.sk-tab-one .sk-tab-content {
background: rgba(187, 187, 187, 0.171);
padding: 30px;
}
.sk-tab-one .sk-sk-tab-content .sk-tab-pane p {
color: #535c68;
margin-bottom: 10px;
font-weight: 500;
}
<?php
namespace CreativeTabZoneWidgets;
use ElementorWidget_Base;
use ElementorControls_Manager;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class BWDTZTabs extends Widget_Base {
public function get_name() {
return esc_html__( 'NameTabsZone', 'bwd-tabs-zone' );
}
public function get_title() {
return esc_html__( 'BWD Tabs Zone', 'bwd-tabs-zone' );
}
public function get_icon() {
return 'sk-tabs-icon eicon-tabs';
}
public function get_categories() {
return [ 'bwd-tabs-zone-category' ];
}
public function get_script_depends() {
return [ 'bwd-tabs-zone-category' ];
}
protected function register_controls() {
$this->start_controls_section(
'sk_tabs_content_section',
[
'label' => esc_html__( 'Layout', 'bwd-tabs-zone' ),
'tab' => ElementorControls_Manager::TAB_CONTENT,
]
);
$repeater = new ElementorRepeater();
$repeater->add_control(
'sk_tabs_title', [
'label' => esc_html__( 'Name', 'bwd-tabs-zone' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Web Developer' , 'bwd-tabs-zone' ),
'label_block' => true,
]
);
$repeater->add_control(
'sk_tabs_description', [
'label' => esc_html__( 'Description', 'bwd-tabs-zone' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Cupiditate eaque ullam dolore ex quam nesciunt debitis deserunt cumque tempora, vitae, sapiente nostrum culpa nulla doloribus! Atque, necessitatibus explicabo. Facilis, voluptatibus?' , 'bwd-tabs-zone' ),
'label_block' => true,
]
);
$this->add_control(
'sk_tabs',
[
'label' => esc_html__( 'Meet The Team', 'bwd-tabs-zone' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'sk_tabs_title' => esc_html__( 'Title #1', 'bwd-tabs-zone' ),
],
[
'sk_tabs_title' => esc_html__( 'Title #2', 'bwd-tabs-zone' ),
],
[
'sk_tabs_title' => esc_html__( 'Title #3', 'bwd-tabs-zone' ),
],
[
'sk_tabs_title' => esc_html__( 'Title #4', 'bwd-tabs-zone' ),
],
],
'title_field' => `{{{ sk_tabs_title }}}`,
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
?>
<div class="sk-tab-one">
<div class="sk-nav">
<?php
if ( $settings['sk_tabs'] ) {
foreach ( $settings['sk_tabs'] as $item ) {
echo '<div class="sk_name elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">'; ?>
<button class="sk-nav-link" id="home-tab"><?php echo esc_html($item['sk_tabs_title']); ?></button>
</div>
<?php
}
} ?>
</div>
<div class="sk-tab-content">
<?php
if ( $settings['sk_tabs'] ) {
foreach ( $settings['sk_tabs'] as $item ) {
echo '<div class="sk-tab-pane elementor-repeater-item-' . esc_attr( $item['_id'] ) . '" id="home">'; ?>
<p><?php echo esc_html($item['sk_tabs_description']); ?></p>
</div>
<?php
}
}
?>
</div>
</div>
<?php
}
}