1.2.2 • Published 2 years ago

@cityelectricalfactors/cef_search-view v1.2.2

Weekly downloads
1
License
MIT
Repository
bitbucket
Last release
2 years ago

CEF Search View Component

This component is to be used in conjunction with the CEF Search Gem.

Important info regarding the component.

This is the generic pack file example for our components.

Once you have pulled this in via yarn (yarn add 'cef_component-name') please change the import name and from to the component name.

You will also need to wrap the javascript_pack_tag call with a class to match the component name, for example component = cef_search-view, class = .cef_search-view.

import { render } from "react-dom";
import React from "react";
import SearchViewComponent from "@cityelectricalfactors/cef_search-view";

document.addEventListener("DOMContentLoaded", () => {
  if (document.querySelector(".search-view")) {
    const node = document.querySelector(".search-view");
    const searchTerm = node.getAttribute("data-search-term");
    const siteName = node.getAttribute("data-site-name");
    const requestPath = node.getAttribute("data-request-path");
    const mode = node.getAttribute("data-mode");
    

    const config = {
      searchUrl: `${requestPath}.json`,
      showSidebar: true,
      showHeader: true,
      showContent: true,
      showPagination: true,
      searchTerm: searchTerm,
      sidebarType: "filters || categories",
      flexDirection: "row",
      contentFlexDirection: "row",
      mode: mode,
      showAddToFavourites: false,
      showBrandImage: true,
      showCompare: true,
      showPrice: true,
      showAddToBasket: true,
      siteName: siteName,
      compareAmount: 5
    };
    render(
      <SearchViewComponent config={config} />,
      document.querySelector(".search-view")
    );
  }
});

Inside your Rails view you'll then need to call the component. This can be done by using the following. The data-attributes are required by the component above.

%section.search-view{'data-search-term': params[:q], 'data-site-name': t("general.site_name"), "data-mode": "search", "data-request-path": request.path}
  = javascript_pack_tag("COMPONENTNAME")
1.2.2

2 years ago

1.2.1

3 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.64

6 years ago

0.0.63

6 years ago

0.0.62

6 years ago

0.0.61

6 years ago

0.0.60

6 years ago

0.0.59

6 years ago

0.0.58

6 years ago

0.0.57

6 years ago

0.0.56

6 years ago

0.0.54

6 years ago

0.0.53

6 years ago

0.0.52

6 years ago

0.0.51

6 years ago

0.0.50

6 years ago

0.0.49

6 years ago

0.0.48

6 years ago

0.0.47

6 years ago

0.0.46

6 years ago

0.0.45

6 years ago

0.0.44

6 years ago

0.0.43

6 years ago

0.0.42

6 years ago

0.0.34

6 years ago

0.0.33

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.15

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago