empathyco / x

Commerce Search & Discovery frontend web components
Apache License 2.0
80 stars 19 forks source link

fix(list-components): fix list components, migrate infinite-scroll directive and deprecated layouts #1576

Closed joseacabaneros closed 1 month ago

joseacabaneros commented 1 month ago

3 things done here:

  1. Getting rid of NoElement usage in -list components (ResultsList, PromotedsList, BannersList and NextQueriesList). It fixes warnings regarding attrs inheritance to the root node.
    <template>
    <NoElement>
    <!--
      @slot Customize ResultsList.
        @binding {Result[]} items - Results to render.
        @binding {Vue | string} animation - Animation to animate the elements.
    -->
    <slot v-bind="{ items, animation }">
      <ItemsList :animation="animation" :items="items">
        <template v-for="(_, slotName) in slots" v-slot:[slotName]="{ item }">
          <slot :name="slotName" :item="item" />
        </template>
      </ItemsList>
    </slot>
    </NoElement>
    </template>

    is the same as the following render function

    return () => {
    const innerProps = { items: items.value, animation: props.animation };
    return slots.default?.(innerProps)[0] ?? h(ItemsList, innerProps);
    };
  2. Removing UseLayouts composable and refactor all deprecated layouts implied
    • Revert Home to use again MultiColumnMaxWidthLayout
  3. Migrate InfiniteScroll directive and make it simpler. Now, it doesn't depend on the component instance to emit UserReachedResultsListEnd event so onInfiniteScrollEnd function in ResultsList is no longer necessary.