# Yatay Filtre Görünümü

Kategori sayfasında blok alanında bulunan Standart Menu ile ilgili kod yapısı

## Görünüm

![Yatay Filtre Görünümü](/img/tema/856974708.png)

## Kod Yapısı

Yatay filtre'nin tema tarafındaki klasör yolu şu şekildedir: **theme** / **html** / **snippets** / **showcase** / **horizontal-filter-menu.twig**

Belirtilen yoldaki html dosyasında yatay filtre'ye ait değişkenler ve bu değişkenler ile oluşturulmuş standart bir yapı mevcuttur. Bu yapıyı twig kurallarına uyacak şekilde istediğinizi yapabilirsiniz.

### HTML

```twig title="index.html"
{% if filter_menu_groups %}
	<div class="horizontal-filter-menu openbox-content">
        <div class="horizontal-filter-menu-title">{{ theme.settings.horizontal_filter_menu_title }}</div>
		<div class="horizontal-filter-menu-content">
            <div class="filter-menu-groups-wrapper">
                {% for filter_menu_group in filter_menu_groups %}
                    <div class="filter-menu-groups filter-menu-box-{{ filter_menu_group.type }}">
                        <div class="filter-menu-group-selectbox">
                            <a href="javascript:void(0);" class="dropbox">
                                <span>{{ filter_menu_group.title }}</span>
                                <svg width="36" height="36" viewBox="0 0 36 36" fill="none">
                                    <path d="M24 16.0005L18 22L12 16.0005L12.9999 15L18 20.0004L23.0001 15L24 16.0005Z" fill="#2B2D42"/>
                                </svg>
                            </a>
                            <div class="filter-menu-group-selectbox-content dropbox-content">
                                {% for item in filter_menu_group.items %}
                                    <a href="{{ item.url }}"{% if item.checked %} class="checked"{% endif %} data-type="{{ filter_menu_group.type }}" data-parent="{{ filter_menu_group.parent }}" data-slug="{{ item.slug }}" data-group-slug="{{ item.groupSlug }}" data-parent-slug="{{ filter_menu_group.slug }}">{{ item.name }} <span>({{ item.productCount }})</span></a>
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                {% endfor %}
            </div>
            {% if selected_filter_groups | length > 0 %}
                <div class="filter-menu-selected-items">
                    {% for selected_filter_group in selected_filter_groups %}
                        <div class="filter-menu-selected-group">
                            {% for selected_filter in selected_filter_group.items %}
                                <div class="filter-menu-selected-item">
                                    <a href="{{ selected_filter.url }}" title="{{ selected_filter.name }}">
                                        <i>
                                            <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
                                                <path d="M10.6673 5.3335L5.33398 10.6668" stroke="#2B2D42" stroke-width="1.4" stroke-linecap="square" stroke-linejoin="round"/>
                                                <path d="M5.33398 5.3335L10.6673 10.6668" stroke="#2B2D42" stroke-width="1.4" stroke-linecap="square" stroke-linejoin="round"/>
                                            </svg>
                                        </i>
                                        <span>{{ selected_filter.name }}</span>
                                    </a>
                                </div>
                            {% endfor %}
                        </div>
                    {% endfor %}
                    <div class="clear-filters">
                        <span>{{ theme.settings.horizontal_filter_menu_choose }}</span>
                        {% if selected_filter_groups | length > 1 %}
                            <a href="javascript:void(0);"  data-selector="clear-filters">
                                <span>{{ theme.settings.horizontal_filter_menu_clear }}</span>
                            </a>
                        {% endif %}
                    </div>
                </div>
            {% endif %}
		</div>
	</div>
{% endif %}
```

### SCSS

```scss title="style.css"
/* Horizontal Filter Menu */
.horizontal-filter-menu {
    margin-bottom: var(--spacer-5);
    .horizontal-filter-menu-title {
        line-height: 20px;
        color: $color-text;
        font-size: var(--font-size-16);
        font-weight: 600;
        margin-bottom: var(--spacer-4);
        @include max($md) {
            display: none;
        }
    }
    .horizontal-filter-menu-content {
        padding: var(--spacer-4);
        padding-bottom: 0;
        margin-bottom: var(--spacer-4);
        border: 1px solid $color-border;
        border-radius: $border-radius;
        background-color: $color-white;
        @include max($md) {
            display: flex;
            flex-direction: column-reverse;
            padding: 0;
            border: none;
        }
    }
    .filter-menu-groups-wrapper {
        @include min($md) {
            display: flex;
            flex-wrap: wrap;
            margin-right: calc(-1*var(--spacer-2));
            margin-left: calc(-1*var(--spacer-2));
        }
        @include max($md) {
            padding: var(--spacer-4);
            border: 1px solid $color-border;
        }
    }
	.filter-menu-groups {
        padding-right: var(--spacer-2);
        padding-left: var(--spacer-2);
        @include max($md) {
            flex: 0 0 100%;
            padding: 0;
        }
		.filter-menu-group-selectbox {
            position: relative;
            margin-bottom: var(--spacer-4);
            > a {
                display: flex;
                align-items: center;
                justify-content: space-between;
                height: 44px;
                line-height: 20px;
                color: $color-text;
                font-size: var(--font-size-14);
                font-weight: 400;
                padding: 4px 4px 4px 16px;
                border-radius: $border-radius;
                border: 1px solid $color-border;
                background-color: #fff;
                span {
                    padding-right: 16px;
                }
                @include max($md) {
                    font-size: var(--font-size-16);
                    font-weight: 600;
                    padding: 4px 0;
                    border: none;
                    border-bottom: 1px solid $color-border;
                    svg {
                        display: none;
                    }
                }
            }
            .filter-menu-group-selectbox-content {
                position: absolute;
                top: calc(100% - 1px);
                left: 0;
                z-index: 101;
                overflow: auto;
                display: none;
                width: 220px;
                max-height: 174px;
                padding: var(--spacer-4);
                background-color: #fff;
                border-radius: $border-radius;
                border: 1px solid $color-border;
                &::-webkit-scrollbar {
                    width: 5px;
                }
                &::-webkit-scrollbar-track {
                    background: lighten($color-border, 5%);
                }
                &::-webkit-scrollbar-thumb {
                    background: darken($color-border, 5%);
                }
                @include max($md) {
                    position: static;
                    top: 0;
                    display: block;
                    width: 100%;
                    padding-left: 0;
                    border: none;
                    border-radius: 0;
                    margin-top: var(--spacer-4);
                }
                > a {
                    position: relative;
                    display: block;
                    line-height: 20px;
                    color: $color-text;
                    font-size: var(--font-size-14);
                    padding-left: 36px;
                    margin-bottom: var(--spacer-5);
                    transition: $transition;
                    span {
                        color: $color-sub-text;
                        padding-left: 4px;
                    }
                    &:last-child {
                        margin-bottom: 0;
                    }
                    &:after {
                        content: '';
                        position: absolute;
                        left: 0;
                        top: 0;
                        width: 20px;
                        height: 20px;
                        border-radius: $border-radius;
                        border: 1px solid $color-border;
                        background-color: #fff;
                        transition: $transition;
                    }
                    &:before {
                        content: '';
                        position: absolute;
                        left: 7px;
                        top: 2px;
                        z-index: 1;
                        opacity: 0;
                        visibility: hidden;
                        display: inline-block;
                        width: 6px;
                        height: 12px;
                        border-bottom: 2px solid $color-primary;
                        border-right: 2px solid $color-primary;
                        transform: rotate(45deg);
                        transition: $transition;
                    }
                    &:hover,
                    &.checked {
                        color: $color-primary;
                        span {
                            color: $color-primary;
                        }
                        &:after {
                            border-color: $color-primary;
                        }
                        &:before {
                            opacity: 1;
                            visibility: visible;
                        }
                    }
                }
            }
            > a.active + .filter-menu-group-selectbox-content {
                display: block;
            }
        }
	}
    .filter-menu-selected-items {
        @include min($md) {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            > div {
                margin-right: var(--spacer-4);
                &:last-child {
                    margin-right: 0;
                }
            }
        }
        @include max($md) {
            display: flex;
            flex-direction: column;
            > div {
                margin-bottom: var(--spacer-4);
                &.clear-filters {
                    order: 1;
                }
                &.filter-menu-selected-group {
                    order: 2;
                }
            }
        }
        .filter-menu-selected-group {
            @include min($md) {
                display: flex;
                align-items: center;
                flex-wrap: wrap;
            }
            .filter-menu-selected-item {
                @include min($md) {
                    margin-bottom: var(--spacer-4);
                    margin-right: var(--spacer-4);
                    &:last-child {
                        margin-right: 0;
                    }
                }
                a {
                    display: flex;
                    align-items: center;
                    line-height: 20px;
                    color: $color-text;
                    font-size: var(--font-size-14);
                    font-weight: 400;
                    background-color: #fff;
                    border-radius: $border-radius;
                    border: 1px solid $color-border;
                    transition: $transition;
                    svg {
                        path {
                            transition: $transition;
                        }
                    }
                    span {
                        position: relative;
                        margin: 0 12px;
                        &:after {
                            content: '';
                            position: absolute;
                            left: 0;
                            right: 0;
                            top: 50%;
                            transform: translateY(-51%);
                            width: 0;
                            height: 1px;
                            margin: 0 auto;
                            background-color: $color-primary;
                            transition: $transition;
                        }
                    }
                    i {
                        @include center;
                        width: 34px;
                        height: 34px;
                        background-color: $color-background;
                        border-right: 1px solid $color-border;
                    }
                    &:hover {
                        color: $color-primary;
                        svg {
                            path {
                                stroke: $color-primary;
                            }
                        }
                        span {
                            &:after {
                                width: 100%;
                            }
                        }
                    }
                }
            }
        }
        .clear-filters {
            margin-left: var(--spacer-2);
            margin-bottom: var(--spacer-4);
            @include max($md) {
                display: flex;
                align-items: center;
                justify-content: space-between;
            }
            > span {
                line-height: 20px;
                color: $color-text;
                font-size: var(--font-size-16);
                font-weight: 600;
                @include min($md) {
                    display: none;
                }
            }
            @include max($md) {
                margin-left: 0;
            }
            a {
                display: flex;
                align-items: center;
                height: 36px;
                line-height: 20px;
                color: $color-text;
                font-size: var(--font-size-14);
                font-weight: 400;
                transition: $transition;
                &:hover {
                    color: $color-primary;
                }
                @include max($md) {
                    color: $color-primary;
                    font-weight: 600;
                }
            }
        }
    }
}
```

### JSON

```json title="index.js"
"horizontal_filter_menu_title": {
    "type": "text",
    "default_value": "Filtrele",
    "label": "Yatay Filtre Başlığı"
},
"horizontal_filter_menu_clear": {
    "type": "text",
    "default_value": "Tümünü Kaldır",
    "label": "Yatay Filtre Tümünü Kaldır"
},
"horizontal_filter_menu_choose": {
    "type": "text",
    "default_value": "Seçiminiz",
    "label": "Yatay Filtre Seçiminiz"
},
```

### JAVASCRİPT

```js title="index.js"
/* After init'e eklenmesi gereken kod */
this.hasFilterOption();
/* Method olarak eklenmesi gereken kod */
hasFilterOption: function(){
    if (IdeaApp['product-list']) {
        IdeaApp['product-list'].filter.checkFilterMenu = function(){
            if (!IdeaApp.helpers.matchMedia('(max-width: 991px)')) {
                $('.filter-options-title').parents('#filter-wrapper').removeClass('has-filter-option');
                return;
            }
            if ($('.filter-menu .filter-menu-groups').length > 0 || $('.horizontal-filter-menu .filter-menu-groups').length > 0) {
                $('.filter-options-title').parents('#filter-wrapper').addClass('has-filter-option');
                var selectedItemCount = $('.filter-menu-selected-item').length;
                if (selectedItemCount > 0) {
                    $('.filter-options-title span').text('(' + selectedItemCount + ')');
                }
            }
        }
    }
},
```

Javascript kodu Ideasoft Front-end Framework template yapısında mevcuttur. Bu özelliğin bulunmadığı siteler için eklenmesi gerekir.
