@empathyco/x-components
Version:
Empathy X Components
142 lines (111 loc) • 3.56 kB
Markdown
---
title: PromotedsList
---
# PromotedsList
It renders a ItemsList of promoteds from SearchState.promoteds.
The component provides a default slot which wraps the whole component with the `promoteds`
plus the `injectedListItems` which also contains the injected list items from
the ancestor.
It also provides the parent slots to customize the items.
## Props
| Name | Description | Type | Default |
| ---------------------- | --------------------------------------------------------------- | -------------------------- | ----------------- |
| <code>animation</code> | Animation component that will be used to animate the promoteds. | <code>AnimationProp</code> | <code>'ul'</code> |
## Events
This component doesn't emit events.
## See it in action
<!-- prettier-ignore-start -->
:::warning Backend service required
To use this component, the Search service must be implemented.
:::
<!-- prettier-ignore-end -->
Here you have a basic example of how the PromotedsList is rendered.
_Type any term in the input field to try it out!_
```vue live
<template>
<div>
<SearchInput />
<PromotedsList />
</div>
</template>
<script setup>
import { PromotedsList } from "@empathyco/x-components/search";
import { SearchInput } from "@empathyco/x-components/search-box";
</script>
```
### Play with the animation
```vue
<template>
<div>
<SearchInput />
<PromotedsList :animation="fadeAndSlide" />
</div>
</template>
<script setup>
import { PromotedsList } from "@empathyco/x-components/search";
import { FadeAndSlide } from "@empathyco/x-components/animations";
import { SearchInput } from "@empathyco/x-components/search-box";
const fadeAndSlide = FadeAndSlide;
</script>
```
### Overriding default content
```vue
<template>
<div>
<SearchInput />
<PromotedsList #default="{ items, animation }">
<BaseGrid :items="items" :animation="animation">
<template #promoted="{ item }">
<span>Promoted: {{ item.title }}</span>
</template>
<template #default="{ item }">
<span>Default: {{ item }}</span>
</template>
</BaseGrid>
</PromotedsList>
</div>
</template>
<script setup>
import { PromotedsList } from "@empathyco/x-components/search";
import { SearchInput } from "@empathyco/x-components/search-box";
import { BaseGrid } from "@empathyco/x-components";
</script>
```
### Overriding promoted content
```vue
<template>
<div>
<SearchInput />
<PromotedsList #promoted="{ item }">
<span class="promoted">
{{ item.title }}
</span>
</PromotedsList>
</div>
</template>
<script setup>
import { PromotedsList } from "@empathyco/x-components/search";
import { SearchInput } from "@empathyco/x-components/search-box";
</script>
```
### Data injection
Starting with the `ResultsList` component as root element, you can concat the list of list items
using `BannersList`, `PromotedsList`, `BaseGrid` or any component that injects the `listItems`
value.
```vue
<template>
<div>
<SearchInput />
<ResultsList>
<PromotedsList>
<template #promoted="{ item }">Promoted: {{ item.id }}</template>
<template #result="{ item }">Result: {{ item.id }}</template>
</PromotedsList>
</ResultsList>
</div>
</template>
<script setup>
import { ResultsList, PromotedsList } from "@empathyco/x-components/search";
import { SearchInput } from "@empathyco/x-components/search-box";
</script>
```