Skip to content

Commit

Permalink
Patch utility builtin tag
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bertran committed Jul 12, 2024
1 parent 942e0c6 commit f869423
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/builtin/utility/components/tags.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="tags">
<div class="tags" ref="tags">
<template
v-for="el of $props.list"
:key="el.id"
Expand All @@ -16,12 +16,16 @@
<div
v-for="item in el.els"
:key="item.name"
class="element"
:class="{
element: true,
tag: item.type === 'tags'
}"
@click="copyToClipboard($q, $t, item.name)"
>
<a
v-if="item.type === 'tags'"
:href="el.tag"
:href="item.tag"
@click="toTag"
>
{{ item.name }}
</a>
Expand All @@ -44,7 +48,7 @@
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType, ref } from 'vue';
import { toPublic, path } from '@/app/plugins/app';
import { copyToClipboard, repUnderscore } from './lib';
import type { tabsType, tags, tagEl } from './lib';
Expand All @@ -63,6 +67,7 @@ export default defineComponent({
}
},
setup () {
const tags = ref<HTMLDivElement | null>(null);
const genPath = (el: tagEl, type: tabsType) => {
switch (type) {
case 'blocks':
Expand All @@ -80,10 +85,20 @@ export default defineComponent({
}
};
const toTag = (e: MouseEvent) => {
e.preventDefault();
e.stopImmediatePropagation();
tags.value
?.querySelector((e.target as HTMLLinkElement).getAttribute('href') ?? '#nope')
?.scrollIntoView(true);
};
return {
tags,
copyToClipboard,
repUnderscore,
genPath
genPath,
toTag
};
}
});
Expand Down Expand Up @@ -112,6 +127,12 @@ export default defineComponent({
justify-content: center;
cursor: pointer;
}
.tags .element.tag {
width: fit-content;
padding-left: .5em;
padding-right: .5em
}
.tags img {
width: 100%;
height: inherit;
Expand Down

0 comments on commit f869423

Please sign in to comment.