Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migrate renderless and simple filter components to composition API #1529

Merged
merged 17 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/_vue3-migration-test/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TestCrossFade,
TestElementsList,
TestFacets,
TestFilters,
TestFade,
TestFadeAndSlide,
TestScroll,
Expand Down Expand Up @@ -111,6 +112,11 @@ const routes = [
name: 'Facets',
component: TestFacets
},
{
path: '/filters',
name: 'Filters',
component: TestFilters
},
{
path: '/scroll',
name: 'Scroll',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as TestFacets } from './test-facets.vue';
export { default as TestFilters } from './test-filters.vue';
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<h2>Simple Filter</h2>
<div>
<h3>As it is</h3>
<SimpleFilter
:filter="filter"
:cssClasses="innerCssClasses"
class="this-is-not-inherited-in-vue3-use-cssClasses-prop-instead"
data-custom="this-is-not-inherited-in-vue3"
/>
</div>
<div>
<h3>Label slot content</h3>
<SimpleFilter :filter="filter" :cssClasses="innerCssClasses">
<template #label>🚗 {{ filter.label }} ({{ filter.totalResults }})</template>
</SimpleFilter>
</div>
<div>
<h3>Default slot content</h3>
<SimpleFilter
v-slot="{ filter, clickFilter, cssClasses }"
:filter="filter"
:cssClasses="innerCssClasses"
>
<label :class="cssClasses" for="filter" class="LABEL-CLASS">
<input @change="clickFilter" id="filter" :checked="filter.selected" type="checkbox" />
{{ filter.label }}
</label>
</SimpleFilter>
</div>
</template>

<script setup lang="ts">
import { SimpleFilter as SimpleFilterModel } from '@empathyco/x-types';
import { computed, ref, Ref } from 'vue';
import SimpleFilter from '../../../../../x-components/src/x-modules/facets/components/filters/simple-filter.vue';

const filter: Ref<SimpleFilterModel> = ref({
modelName: 'SimpleFilter',
label: 'My Filter',
totalResults: 10,
facetId: 'facet1',
id: 'filter1',
selected: false
});

const innerCssClasses = computed(() => [
'MOT-CUSTOM',
{ 'MOT-CUSTOM--SELECTED': filter.value.selected }
]);
</script>

<style>
.MOT-CUSTOM--SELECTED {
background-color: greenyellow;
}
</style>
Loading
Loading