Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

feat(queryRules): add QueryRuleCustomData widget [part 2] #2212

Merged

Conversation

francoischalifour
Copy link
Member

@francoischalifour francoischalifour commented Mar 21, 2019

This is the 2nd PR in the series "Merchandized Query Rules".

Summary

This creates the QueryRuleCustomData widget, responsible for showing custom data (userData) coming from Query Rules.

Motivation

Read RFC →

Usage

Basic

<QueryRuleCustomData>
  {({ items }) =>
    items.map(({ banner, title, link }) => {
      if (!banner) {
        return null;
      }

      return (
        <section key={title}>
          <h2>{title}</h2>

          <a href={link}>
            <img src={banner} alt={title} />
          </a>
        </section>
      );
    })
  }
</QueryRuleCustomData>

With default banner

<QueryRuleCustomData
  transformItems={items => {
    if (items.length > 0) {
      return items;
    }

    return [
      {
        title: 'Kill Bill',
        banner: 'http://static.bobatv.net/IMovie/mv_2352/poster_2352.jpg',
        link: 'https://www.netflix.com/title/60031236',
      },
    ];
  }}
>
  {({ items }) =>
    items.map(({ banner, title, link }) => {
      if (!banner) {
        return null;
      }

      return (
        <section key={title}>
          <h2>{title}</h2>

          <a href={link}>
            <img src={banner} alt={title} />
          </a>
        </section>
      );
    })
  }
</QueryRuleCustomData>

Stories

See stories →

Related

@francoischalifour francoischalifour requested review from samouss and a team March 21, 2019 17:53
@francoischalifour francoischalifour force-pushed the feat/mqr-queryRuleCustomData branch from ade2c95 to c143145 Compare March 21, 2019 17:59
@algolia algolia deleted a comment from algobot Mar 21, 2019
@algobot
Copy link
Contributor

algobot commented Mar 21, 2019

Deploy preview for react-instantsearch ready!

Built with commit e83ca8e

https://deploy-preview-2212--react-instantsearch.netlify.com

@algolia algolia deleted a comment from algobot Mar 21, 2019
@francoischalifour francoischalifour force-pushed the feat/mqr-queryRuleCustomData branch from 8ba3e7c to 495d577 Compare April 2, 2019 11:42
@francoischalifour francoischalifour changed the title feat(queryRules): add QueryRuleCustomData widget feat(queryRules): add QueryRuleCustomData widget [part 2] Apr 3, 2019
storybook/webpack.config.js Show resolved Hide resolved
* feat(queryRules): add context features to connector [part 3]

* feat(queryRules): add QueryRuleContext widget [part 4] (#2259)
@francoischalifour francoischalifour merged commit acff3eb into feat/mqr-connectQueryRules Apr 8, 2019
@francoischalifour francoischalifour deleted the feat/mqr-queryRuleCustomData branch April 8, 2019 11:29
francoischalifour added a commit that referenced this pull request Apr 8, 2019
* feat(queryRules): add connectQueryRules connector [part 1] (#2210)

* feat(queryRules): add QueryRuleCustomData widget [part 2] (#2212)

* feat(queryRules): add context features to connector [part 3] (#2258)

* feat(queryRules): add QueryRuleContext widget [part 4] (#2259)
francoischalifour added a commit that referenced this pull request Apr 8, 2019
* feat(queryRules): add connectQueryRules connector [part 1] (#2210)

* feat(queryRules): add QueryRuleCustomData widget [part 2] (#2212)

* feat(queryRules): add context features to connector [part 3] (#2258)

* feat(queryRules): add QueryRuleContext widget [part 4] (#2259)
francoischalifour added a commit that referenced this pull request Apr 8, 2019
* feat(queryRules): add connectQueryRules connector [part 1] (#2210)

* feat(queryRules): add QueryRuleCustomData widget [part 2] (#2212)

* feat(queryRules): add context features to connector [part 3] (#2258)

* feat(queryRules): add QueryRuleContext widget [part 4] (#2259)
francoischalifour added a commit that referenced this pull request Apr 8, 2019
* feat(queryRules): add connectQueryRules connector [part 1] (#2210)

* feat(queryRules): add QueryRuleCustomData widget [part 2] (#2212)

* feat(queryRules): add context features to connector [part 3] (#2258)

* feat(queryRules): add QueryRuleContext widget [part 4] (#2259)
Haroenv pushed a commit that referenced this pull request Apr 9, 2019
* feat(queryRules): add connectQueryRules connector [part 1] (#2210)

* feat(queryRules): add QueryRuleCustomData widget [part 2] (#2212)

* feat(queryRules): add context features to connector [part 3] (#2258)

* feat(queryRules): add QueryRuleContext widget [part 4] (#2259)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants