# Akordiyon Tab Görünümü


## Kod Yapısı

Akordiyon 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şmatadır.

### HTML

```twig title="index.html"
<div class="product-detail-tab" data-product-id="{{ product.id }}">
    <div class="product-detail-tab-content">
        <div class="product-detail-tab-row{% if theme.settings.product_detail_mobile_first_tab %} active{% endif %}">
            <div class="{% 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="{% if theme.settings.product_detail_mobile_first_tab %}active{% endif %}" 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="" 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="" 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="" 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="" 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>
```

### SCSS

```scss title="style.css"
.product-detail-tab {
    .product-detail-tab-content {
        .product-detail-tab-row {
            [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-16);
                    border-bottom: 1px solid $color-border;
                    &:after {
                        content: '\f078';
                        font-weight: 900;
                        font-size: var(--font-size-16);
                        font-family: "Font Awesome 5 Free";
                        transition: $transition;
                    }
                }
            }
            &.active {
                border-bottom: 1px solid $color-border;
                [data-tab-index] {
                    > a {
                        color: $color-primary;
                        &:after {
                            transform: rotate(-180deg);
                        }
                    }
                }
            }
        }
        [data-tab-content] {
            height: auto;
            overflow: visible;
            display: none;
            > div {
                padding: var(--spacer-5) 0;
            }
        }
    }
}
```

### 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);
        }
    });
},
```
