# Dikey Tab Görünümü


## Kod Yapısı

Dikey tab alanı sadece ürün detay sayfasında kullanılan bir kod alanıdır. Kod bloğu **theme / html / templates / product / detail.twig** dosyasında inlude edilmektedir. Fakat bu template dosyasının yolu ise **theme / html / snippets / product / tab.twig.** Yapı Html ve Scss'den oluşmaktadır.

### HTML

```twig title="index.html"
<div class="product-detail-tab" data-product-id="{{ product.id }}">
    <div class="row">
        <div class="col-lg-3 pr-lg-0 d-none d-lg-flex">
            <div class="product-detail-tab-header">
                <div class="active" data-tab-index="1"><a href="javascript:void(0);">{{ theme.settings.tab_product_info }}</a></div>
                {% if theme.settings.product_detail_page_tabs.display_product_comments %}
                    <div class="" data-tab-index="2"><a href="javascript:void(0);">{{ theme.settings.tab_product_comments }}</a></div>
                {% endif %}
                {% if theme.settings.product_detail_page_tabs.display_payment_options %}
                    <div class="" data-tab-index="3" data-type="payment-option"><a href="javascript:void(0);">{{ theme.settings.tab_product_payment_options }}</a></div>
                {% endif %}
                {% if theme.settings.product_detail_page_tabs.display_product_feeds %}
                    <div class="" data-tab-index="4"><a href="javascript:void(0);">{{ theme.settings.tab_product_feeds }}</a></div>
                {% endif %}
                {% if theme.settings.product_detail_page_tabs.display_special_information_area and product.specialInfo %}
                    <div class="" data-tab-index="5"><a href="javascript:void(0);">{{ product.specialInfo.title }}</a></div>
                {% endif %}
            </div>
        </div>
        <div class="col-lg-9 pl-lg-0">
            <div class="product-detail-tab-content">
                <div class="product-detail-tab-row{% if theme.settings.product_detail_mobile_first_tab %} active{% endif %}">
                    <div class="d-block d-lg-none{% if theme.settings.product_detail_mobile_first_tab %} active{% endif %}" data-tab-index="1"><a href="javascript:void(0);">{{ theme.settings.tab_product_info }}</a></div>
                    <div class="active" data-tab-content="1">
                        <div class="product-detail">{{ product.details | raw }}</div>
                        {% if product.specs | length > 0 and theme.settings.display_product_attributes %}
                            <div class="product-specs-table">
                                <table class="table">
                                    <tbody>
                                        {% for spec in product.specs %}
                                            <tr>
                                                <td>{{ spec.name }}</td>
                                                <td>:</td>
                                                <td>{{ spec.values | join(', ') }}</td>
                                            </tr>
                                        {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        {% endif %}
                    </div>
                </div>
                {% if theme.settings.product_detail_page_tabs.display_product_comments %}
                <div class="product-detail-tab-row">
                        <div class="d-block d-lg-none" data-tab-index="2"><a href="javascript:void(0);">{{ theme.settings.tab_product_comments }}</a></div>
                        <div class="" data-tab-content="2">{% include 'html/snippets/product/comment.twig' %}</div>
                    </div>
                {% endif %}
                {% if theme.settings.product_detail_page_tabs.display_payment_options %}
                    <div class="product-detail-tab-row">
                        <div class="d-block d-lg-none" data-tab-index="3" data-type="payment-option"><a href="javascript:void(0);">{{ theme.settings.tab_product_payment_options }}</a></div>
                        <div class="" data-tab-content="3"></div>
                    </div>
                {% endif %}
                {% if theme.settings.product_detail_page_tabs.display_product_feeds %}
                    <div class="product-detail-tab-row">
                        <div class="d-block d-lg-none" data-tab-index="4"><a href="javascript:void(0);">{{ theme.settings.tab_product_feeds }}</a></div>
                        <div class="" data-tab-content="4">{% include 'html/snippets/product/form/product-feed.twig' %}</div>
                    </div>
                {% endif %}
                {% if theme.settings.product_detail_page_tabs.display_special_information_area and product.specialInfo %}
                    <div class="product-detail-tab-row">
                        <div class="d-block d-lg-none" data-tab-index="5"><a href="javascript:void(0);">{{ product.specialInfo.title }}</a></div>
                        <div class="" data-tab-content="5"><div>{{ product.specialInfo.content | raw }}</div></div>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>
```

### SCSS

```scss title="style.css"
/* Product Detail Tab */
.product-detail-tab {
    margin-bottom: var(--spacer-15);
    .product-detail-tab-header {
        position: relative;
        z-index: 1;
        width: 100%;
        margin-top: 1px;
        [data-tab-index] {
            > a {
                position: relative;
                display: flex;
                align-items: center;
                height: 52px;
                color: $color-sub-text;
                font-size: var(--font-size-14);
                font-weight: 600;
                padding: 0 var(--spacer-4);
                border: 1px solid $color-border;
                margin-top: -1px;
            }
            &.active {
                > a {
                    color: $color-primary;
                    &:after {
                        content: '';
                        position: absolute;
                        right: -2px;
                        top: 0;
                        width: 2px;
                        height: 100%;
                        background-color: $color-white;
                    }
                }
            }
        }
    }
	.product-detail-tab-content {
        @include min($md) {
            border: 1px solid $color-border;
        }
		[data-tab-content] {
			height: 0;
            overflow: hidden;
			> div {
                padding: var(--spacer-6);
                @include max($md) {
                    padding: var(--spacer-6) 0;
                }
			}
			&.active {
				height: auto;
                overflow: visible;
                @include min($sm) {
                    display: block !important;
                }
            }
		}
	}
    @include max($md) {
        .product-detail-tab-content {
            .product-detail-tab-row {
                margin-bottom: var(--spacer-8);
                [data-tab-index] {
                    > a {
                        position: relative;
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
                        height: 50px;
                        color: $color-text;
                        font-size: var(--font-size-20);
                        padding: 0 var(--spacer-8);
                        background-color: $color-border;
                        &:after {
                            content: '\f078';
                            font-weight: 900;
                            font-size: var(--font-size-24);
                            font-family: "Font Awesome 5 Free";
                            transition: $transition;
                        }
                    }
                }
                [data-tab-content] {
                    height: 0 !important;
                    overflow: hidden !important;
                    > div {
                        padding-bottom: 0;
                    }
                }
                &.active {
                    [data-tab-index] {
                        > a {
                            color: $color-white;
                            background-color: $color-primary;
                            &:after {
                                transform: rotate(-180deg);
                            }
                        }
                    }
                    [data-tab-content] {
                        &.active {
                            height: auto !important;
                            overflow: visible !important;
                        }
                    }
                }
            }
        }
    }
}
```

### JAVASCRİPT

Html ve Scss kodları mobilde direkt akordiyon olması için ayarlandı. Aşağıdaki Javascript kodu ise **theme / assets / javascript / product.js** dosyasına eklenmeli.

```js title="index.js"
/* Alttaki kod product.js de afterinit methoduna eklenecek */
this.responsiveTabs();

/* Alttaki kod ise product.js de method olarak eklenecek */
responsiveTabs: function(){
    IdeaApp.product.productTab('.product-detail-tab', function () {}, function () {});
    $('.product-detail-tab-row [data-tab-index]').on('click', function(event) {
        if($(this).parent().attr('class').indexOf('active') > -1) {
            $(this).next().slideUp();
            $(this).parent().removeClass('active');
        } else {
            $(this).next().slideDown().parent().siblings().find('[data-tab-content]').slideUp();
            $('.product-detail-tab-row').removeClass('active');
            $(this).parent().addClass('active');
        }
        $('html, body').animate({
            scrollTop: $(this).parent().parent().offset().top - 15
        }, 500);
    });
    {% if theme.settings.product_detail_mobile_first_tab %}
        $('.product-detail-tab-content .product-detail-tab-row.active .active[data-tab-content]').show();
    {% endif %}
    var productId = $('.product-detail-tab').attr('data-product-id');
    $.ajax({
        url: '/taksit-secenekleri',
        data: "productId=" + productId,
        success: function (response) {
            $('[data-selector="product-payment-options"]').html(response);
        }
    });
},
```
