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

Migrate mt data table filter to custom i18n #355

Merged
merged 6 commits into from
Nov 4, 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
5 changes: 5 additions & 0 deletions .changeset/nervous-countries-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": patch
---

Add missing translation for data table filters
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
{{ filter.label }}
</mt-text>

<mt-text size="2xs" color="color-text-secondary-default" class="mt-data-table-filter__rule"
>is</mt-text
>
<mt-text size="2xs" color="color-text-secondary-default" class="mt-data-table-filter__rule">
{{ t("is") }}
</mt-text>

<mt-popover class="mt-data-table-filter__option" title="Manufactuer">
<template #trigger="{ toggleFloatingUi }">
Expand Down Expand Up @@ -34,7 +34,7 @@

<button
class="mt-data-table-filter__remove-button"
:aria-label="$t('mt-data-table-filter.remove-button')"
:aria-label="t('removeButton')"
@keydown.delete="$emit('removeFilter')"
@click="$emit('removeFilter')"
>
Expand All @@ -43,57 +43,44 @@
</div>
</template>

<script lang="ts">
<script setup lang="ts">
import MtIcon from "@/components/icons-media/mt-icon/mt-icon.vue";
import MtPopover from "@/components/overlay/mt-popover/mt-popover.vue";
import MtPopoverItem from "@/components/overlay/mt-popover-item/mt-popover-item.vue";
import { defineComponent, type PropType } from "vue";
import type { Filter, Option } from "../../mt-data-table.interfaces";
import MtText from "@/components/content/mt-text/mt-text.vue";
import { useI18n } from "@/composables/useI18n";

export default defineComponent({
name: "MtDataTableFilter",
defineEmits<{
(e: "removeOption", filterId: string, optionId: string): void;
(e: "addOption", filterId: string, optionId: string): void;
(e: "removeFilter"): void;
}>();

components: {
"mt-icon": MtIcon,
"mt-popover": MtPopover,
"mt-popover-item": MtPopoverItem,
"mt-text": MtText,
},
i18n: {
messages: {
en: {
"mt-data-table-filter.remove-button": "Remove filter",
},
de: {
"mt-data-table-filter.remove-button": "Filter entfernen",
},
},
},
emits: ["removeOption", "addOption", "removeFilter"],
props: {
filter: {
type: Object as PropType<Filter>,
required: true,
const props = defineProps<{
filter: Filter;
appliedOptions: Option[];
}>();

function isOptionSelected(optionId: string) {
return !!props.appliedOptions.find((option) => option.id === optionId);
}

const { t } = useI18n({
messages: {
en: {
is: "is",
removeButton: "Remove filter",
},
appliedOptions: {
type: Array as PropType<Option[]>,
required: true,
de: {
is: "ist",
removeButton: "Filter entfernen",
},
},
setup(props) {
function isOptionSelected(optionId: string) {
return !!props.appliedOptions.find((option) => option.id === optionId);
}

return {
isOptionSelected,
};
},
});
</script>

<style lang="scss" scoped>
<style scoped>
.mt-data-table-filter {
display: inline-flex;

Expand All @@ -102,71 +89,71 @@ export default defineComponent({
display: grid;
place-items: center;
}
}

.mt-data-table-filter__property {
border: 1px solid var(--color-border-primary-default);
border-right: 0 none;
border-top-left-radius: var(--border-radius-xs);
border-bottom-left-radius: var(--border-radius-xs);
color: var(--color-text-primary-default);
padding-inline: 8px;
}

.mt-data-table-filter__property {
border: 1px solid var(--color-border-primary-default);
border-right: 0 none;
border-top-left-radius: var(--border-radius-xs);
border-bottom-left-radius: var(--border-radius-xs);
color: var(--color-text-primary-default);
padding-inline: 8px;
.mt-data-table-filter__rule {
border-top: 1px solid var(--color-border-primary-default);
border-bottom: 1px solid var(--color-border-primary-default);
padding-right: 4px;
}

.mt-data-table-filter__option {
color: var(--color-text-primary-default);
font-size: var(--font-size-2xs);
font-family: var(--font-family-body);
line-height: var(--font-line-height-2xs);
border-top: 1px solid var(--color-border-primary-default);
border-bottom: 1px solid var(--color-border-primary-default);
padding-inline: 4px 8px;

& button {
outline: 0 none;
}

.mt-data-table-filter__rule {
border-top: 1px solid var(--color-border-primary-default);
border-bottom: 1px solid var(--color-border-primary-default);
padding-right: 4px;
&:has(button:hover) {
background-color: var(--color-interaction-secondary-hover);
}

.mt-data-table-filter__option {
color: var(--color-text-primary-default);
font-size: var(--font-size-2xs);
font-family: var(--font-family-body);
line-height: var(--font-line-height-2xs);
border-top: 1px solid var(--color-border-primary-default);
border-bottom: 1px solid var(--color-border-primary-default);
padding-inline: 4px 8px;

button {
outline: 0 none;
}

&:has(button:hover) {
background-color: var(--color-interaction-secondary-hover);
}

&:has(button:focus-visible) {
background-color: var(--color-background-brand-default);
outline: var(--color-border-brand-selected) solid 1px;
outline-offset: -1px;
}
&:has(button:focus-visible) {
background-color: var(--color-background-brand-default);
outline: var(--color-border-brand-selected) solid 1px;
outline-offset: -1px;
}
}

.mt-data-table-filter__remove-button {
color: var(--color-icon-primary-default);
border-top-right-radius: var(--border-radius-xs);
border-bottom-right-radius: var(--border-radius-xs);
border: 1px solid var(--color-border-primary-default);
outline: 0 none;
position: relative;
height: 24px;
width: 24px;

.mt-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

&:focus-visible {
background-color: var(--color-background-brand-default);
border-color: var(--color-border-brand-selected);
}

&:hover {
background-color: var(--color-interaction-secondary-hover);
}
.mt-data-table-filter__remove-button {
color: var(--color-icon-primary-default);
border-top-right-radius: var(--border-radius-xs);
border-bottom-right-radius: var(--border-radius-xs);
border: 1px solid var(--color-border-primary-default);
outline: 0 none;
position: relative;
height: 24px;
width: 24px;

& .mt-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

&:focus-visible {
background-color: var(--color-background-brand-default);
border-color: var(--color-border-brand-selected);
}

&:hover {
background-color: var(--color-interaction-secondary-hover);
}
}
</style>
Loading