Skip to content

Commit

Permalink
refactor: refator variables names
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramargar committed Dec 17, 2024
1 parent b865f6b commit b23fbb3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<button
@click="toggleSuggestion(index)"
class="x-related-prompt__button"
:class="[{ 'x-related-prompt-selected__button': isSelected(index) }]"
:class="[{ 'x-related-prompt-selected__button': isSelected }]"
>
<slot name="related-prompt-button-info">
<div class="x-related-prompt__button-info">
<span
class="x-typewritter-initial"
:class="[{ 'x-typewritter-animation': isVisible }]"
:class="[{ 'x-typewritter-animation': arePromptsVisible }]"
:style="{
animationDelay: `${index * 0.4 + 0.05}s`,
'--suggestion-text-length': relatedPrompt.suggestionText.length
Expand All @@ -17,8 +17,8 @@
{{ relatedPrompt.suggestionText }}
</span>
</div>
<CrossTinyIcon v-if="isSelected(index)" class="x-icon-lg" />
<PlusIcon v-else class="x-icon-neutral-80 x-icon-lg" />
<CrossTinyIcon v-if="isSelected" class="x-icon-lg" />
<PlusIcon v-else class="x-icon-lg" />
</slot>
</button>
</template>
Expand Down Expand Up @@ -49,7 +49,11 @@
type: Object as PropType<RelatedPrompt>,
required: true
},
isVisible: {
arePromptsVisible: {
type: Boolean,
default: false
},
isSelected: {
type: Boolean,
default: false
},
Expand All @@ -66,14 +70,10 @@
x.emit('UserSelectedARelatedPrompt', index);
};
const isSelected = (index: number): boolean => selectedPrompt.value === index;
return {
isSelected,
selectedPrompt,
toggleSuggestion
};
}
});
</script>
<style lang="css"></style>
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@
}"
class="x-related-prompt x-staggered-initial"
:class="[
{ 'x-staggered-animation': isVisible },
{ 'x-hidden': shouldHideButton(index) },
{ 'x-staggered-animation': arePromptsVisible },
{ 'x-hidden': hidePrompt(index) },
{ 'x-related-prompt-selected': isSelected(index) }
]"
data-test="related-prompt-item"
>
<slot name="related-prompt-button" v-bind="{ suggestion, index, isVisible }">
<RelatedPrompt :related-prompt="suggestion" :index="index" :is-visible="isVisible" />
<slot
name="related-prompt-button"
v-bind="{ suggestion, index, arePromptsVisible, isSelected }"
>
<RelatedPrompt
:related-prompt="suggestion"
:index="index"
:are-prompts-visible="arePromptsVisible"
:is-selected="isSelected(index)"
/>
</slot>
</div>
</div>
Expand Down Expand Up @@ -68,10 +76,10 @@
]);
const slidingPanelContent = ref<Element>();
const isVisible = ref(false);
const arePromptsVisible = ref(false);
const observer = new IntersectionObserver(([entry]) => {
isVisible.value = entry.isIntersecting;
arePromptsVisible.value = entry.isIntersecting;
});
onMounted(() => {
Expand All @@ -84,12 +92,12 @@
const isSelected = (index: number): boolean => selectedPrompt.value === index;
const shouldHideButton = (index: number): boolean =>
const hidePrompt = (index: number): boolean =>
selectedPrompt.value !== -1 && selectedPrompt.value !== index;
return {
isVisible,
shouldHideButton,
arePromptsVisible,
hidePrompt,
isSelected,
relatedPrompts,
selectedPrompt,
Expand Down

0 comments on commit b23fbb3

Please sign in to comment.