traxxx-web/components/filters/filters.vue

478 lines
6.9 KiB
Vue
Raw Normal View History

<template>
<div class="filters-frame">
<div
v-show="showFilters"
class="filters-container"
:class="{ show: showFiltersCompact }"
@click="toggleFilters(false)"
>
<div class="filters-sidebar">
<form
class="filters"
:class="{ loading }"
@submit.prevent
@click.stop
>
<slot />
</form>
<button
v-if="typeof results === 'number'"
class="button results"
>Show {{ results }} {{ results > 1 ? 'results' : 'result' }}</button>
</div>
<div
class="filters-toggle close"
:class="{ 'show-full': showFilters, 'show-compact': showFiltersCompact }"
@click.stop="toggleFilters(false)"
>
<Icon
icon="arrow-left3"
class="arrow"
/>
<Icon
icon="cross2"
class="cross"
/>
</div>
</div>
<div
class="filters-toggle open"
:class="{ 'show-full': !showFilters, 'show-compact': !showFiltersCompact }"
@click.stop="toggleFilters(true)"
><Icon icon="filter" /></div>
</div>
</template>
<script setup>
import { ref } from 'vue';
defineProps({
results: {
type: Number,
default: null,
},
loading: {
type: Boolean,
default: false,
},
});
// desktop defaults to open, compact defaults to closed
// we can't measure viewframe in SSR, so use separate toggles
const showFilters = ref(true);
const showFiltersCompact = ref(false);
function toggleFilters(state) {
showFilters.value = state ?? !showFilters.value;
showFiltersCompact.value = state ?? !showFiltersCompact.value;
}
</script>
2024-01-07 22:44:33 +00:00
<style>
2024-01-08 01:21:57 +00:00
.filter {
padding: .5rem;
.input {
width: 100%;
}
&:not(:last-child) {
border-bottom: solid 1px var(--glass-weak-30);
2024-01-08 01:21:57 +00:00
}
}
.filter.search-container {
display: flex;
align-items: stretch;
.input {
flex-grow: 1;
}
.icon {
height: auto;
display: flex;
align-items: center;
padding-left: .5rem;
fill: var(--glass);
&:hover {
cursor: pointer;
fill: var(--primary);
}
}
}
2024-01-07 22:44:33 +00:00
.filter-mode {
width: 100%;
color: var(--glass);
2024-01-07 22:44:33 +00:00
background: none;
padding: .75rem;
margin: 0 0 .5rem 0;
font-size: 1rem;
border: none;
border-bottom: solid 1px var(--glass-weak-40);
2024-01-07 22:44:33 +00:00
option {
color: var(--text-dark);
}
}
2024-01-08 01:21:57 +00:00
.filters-sort {
display: flex;
border-bottom: solid 1px var(--glass-weak-30);
2024-01-08 01:21:57 +00:00
}
.filters-search {
flex-grow: 1;
border-bottom: none;
width: 0;
}
2024-01-07 22:44:33 +00:00
.filter-clear {
display: flex;
align-items: center;
justify-content: space-between;
padding: .5rem 1rem;
color: var(--glass-weak-10);
2024-01-07 22:44:33 +00:00
text-decoration: none;
cursor: default;
.icon {
fill: var(--glass-weak-30);
2024-01-07 22:44:33 +00:00
margin: 0 0 0 1rem;
}
&.active {
color: var(--glass);
2024-01-07 22:44:33 +00:00
.icon {
fill: var(--glass-weak-10);
2024-01-07 22:44:33 +00:00
}
&:hover {
color: var(--text);
background: var(--glass-weak-30);
2024-01-07 22:44:33 +00:00
cursor: pointer;
.icon {
fill: var(--alert);
}
}
}
}
2024-01-08 01:21:57 +00:00
.filter-items {
max-height: 15rem;
overflow-y: auto;
&.selected {
box-shadow: 0 -1px 3px var(--shadow-weak-30);
}
&.available {
box-shadow: inset 0 -1px 3px var(--shadow-weak-30);
}
}
2024-01-07 22:44:33 +00:00
.filter-items .filter-item {
display: flex;
align-items: stretch;
&:hover {
background: var(--glass-weak-30);
2024-01-07 22:44:33 +00:00
cursor: pointer;
}
&.selected {
.filter-include {
.filter-add {
fill: var(--success);
}
&:hover {
.filter-add {
display: none;
}
.filter-remove {
display: inline-block;
}
}
}
}
2024-01-26 00:31:15 +00:00
&.disabled {
opacity: .5;
pointer-events: none;
.filter-include {
visibility: hidden;
}
}
2024-01-07 22:44:33 +00:00
}
.filter-name {
min-width: 8rem;
display: flex;
justify-content: space-between;
align-items: center;
flex-grow: 1;
padding: .25rem 0 .25rem .25rem;
2024-01-07 22:44:33 +00:00
color: var(--text);
text-decoration: none;
}
.filter-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
2024-01-07 22:44:33 +00:00
.filter-include {
display: flex;
align-items: center;
.icon {
width: 1rem;
padding: 0 .75rem;
fill: var(--glass-weak-30);
2024-01-07 22:44:33 +00:00
}
.filter-remove {
display: none;
fill: var(--alert);
}
&:hover {
cursor: pointer;
}
}
.filter-include:hover,
.filter-name:hover {
background: var(--glass-weak-30);
2024-01-07 22:44:33 +00:00
}
2024-01-08 01:21:57 +00:00
.filter-sort {
display: flex;
flex-shrink: 0;
align-items: center;
align-self: stretch;
justify-content: center;
padding: 0 .25rem;
2024-01-08 01:21:57 +00:00
cursor: pointer;
font-weight: bold;
color: var(--glass);
2024-01-08 01:21:57 +00:00
&.order {
padding: 0 .5rem 0 .25rem;
2024-01-08 01:21:57 +00:00
}
.icon {
fill: var(--glass);
2024-01-08 01:21:57 +00:00
}
&:hover {
color: var(--primary);
.icon {
fill: var(--primary);
}
}
}
.filter-details {
display: flex;
align-items: stretch;
margin-left: .5rem;
.filter-remove.icon {
padding: .25rem .6rem;
fill: var(--glass);
&:hover {
fill: var(--alert);
}
}
}
2024-01-08 01:21:57 +00:00
.filter-count {
width: 1.75rem;
2024-01-08 01:21:57 +00:00
display: flex;
align-items: center;
justify-content: flex-end;
2024-01-08 01:21:57 +00:00
padding: 0 .25rem;
overflow: hidden;
color: var(--glass-weak-10);
2024-01-08 01:21:57 +00:00
font-size: .9rem;
}
2024-02-22 04:08:06 +00:00
.filter-empty {
padding: .5rem;
color: var(--glass);
2024-02-22 04:08:06 +00:00
font-style: italic;
}
.filter-disclaimer {
background: var(--notice);
color: var(--highlight-strong-30);
padding: .25rem .5rem;
box-shadow: inset 0 0 3px var(--shadow-weak-30);
line-height: 1.25;
font-size: .9rem;
}
@media (--compact) {
.filter {
border-right: solid 1px var(--glass-weak-30);
}
}
2024-01-07 22:44:33 +00:00
</style>
<style scoped>
.filters-frame {
position: relative;
}
.filters-container {
display: flex;
height: 100%;
}
.filters-sidebar {
height: 100%;
display: flex;
flex-direction: column;
background: var(--background);
}
.filters {
width: 17rem;
flex-grow: 1;
position: relative;
box-sizing: border-box;
2024-01-07 22:44:33 +00:00
padding: 0 0 .5rem 0;
background: var(--background);
box-shadow: 0 0 3px var(--shadow-weak-30);
&::-webkit-scrollbar {
display: none;
}
}
.filters-toggle {
min-width: 2rem;
height: 2.5rem;
display: none;
justify-content: center;
align-items: center;
padding: 0 .25rem;
position: absolute;
top: .35rem;
right: -2.5rem;
border-radius: 0 .5rem .5rem 0;
background: var(--background);
color: var(--glass);
font-weight: bold;
box-shadow: inset 0 0 3px var(--shadow-weak-30);
&.open {
left: 0;
right: auto;
}
&.show-full {
display: flex;
}
&.close .cross {
display: none;
}
.icon {
fill: var(--glass);
}
&:hover {
cursor: pointer;
.icon {
fill: var(--primary);
}
}
}
.results {
display: none;
justify-content: center;
background: var(--primary);
color: var(--text-light);
border-radius: 0;
}
.loading {
opacity: .3;
pointer-events: none;
}
@media (--compact) {
.filters-container {
display: none;
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 500;
background: var(--background-dim);
&.show {
display: flex;
}
}
.filters {
width: 20rem;
border-right: solid 1.5rem var(--background);
overflow-y: auto;
}
.filters-toggle {
&.show-full {
display: none;
}
&.show-compact {
display: flex;
&.close {
2024-06-13 00:26:34 +00:00
background: var(--background-base-20);
position: relative;
right: 0;
}
}
&.close .cross {
display: flex;
}
&.close .arrow {
display: none;
}
}
.compact-hide {
display: none;
}
.results {
display: flex;
}
}
</style>