@nosto/nosto-react 0.1.0 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +0,0 @@
1
- import React, { useEffect } from "react";
2
-
3
- const NostoOther: React.FC = () => {
4
- useEffect(() => {
5
- // @ts-ignore
6
- window.nostojs((api) => {
7
- api
8
- .defaultSession()
9
- .setResponseMode("HTML")
10
- .viewOther()
11
- .setPlacements(api.placements.getPlacements())
12
- .load()
13
- .then((data: object) => {
14
- // @ts-ignore
15
- api.placements.injectCampaigns(data.recommendations);
16
- });
17
- });
18
- }, []);
19
-
20
- return (
21
- <>
22
- <div className="nosto_page_type" style={{ display: "none" }}>
23
- other
24
- </div>
25
- </>
26
- );
27
- };
28
-
29
- export default NostoOther;
@@ -1,12 +0,0 @@
1
- import { createContext } from "react";
2
-
3
- export interface NostoInterface {
4
- account: string;
5
- }
6
-
7
- /* tslint:disable:no-empty */
8
- export const NostoContext = createContext<NostoInterface>({
9
- // @ts-ignore
10
- account: undefined
11
- });
12
- /* tslint:enable:no-empty */
@@ -1,35 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { NostoContext } from "./context";
3
-
4
- interface NostoProviderProps {
5
- account: string;
6
- host: string;
7
- children: React.ReactElement;
8
- }
9
-
10
- const NostoProvider: React.FC<NostoProviderProps> = ({
11
- account,
12
- host,
13
- children,
14
- }) => {
15
- useEffect(() => {
16
- const script = document.createElement("script");
17
- script.type = "text/javascript";
18
- script.src = "//" + (host || "connect.nosto.com") + "/include/" + account;
19
- script.async = true;
20
- document.head.appendChild(script);
21
-
22
- window.nostojs = (cb: Function) =>
23
- (window.nostojs.q = window.nostojs.q || []).push(cb);
24
- // @ts-ignore
25
- window.nostojs((api) => api.setAutoLoad(false));
26
- }, []);
27
-
28
- return (
29
- <NostoContext.Provider value={{ account }}>
30
- {children}
31
- </NostoContext.Provider>
32
- );
33
- };
34
-
35
- export default NostoProvider;
@@ -1,32 +0,0 @@
1
- import React, { useEffect } from "react";
2
-
3
- const NostoSearch: React.FC<{ query: string }> = ({ query }) => {
4
- useEffect(() => {
5
- // @ts-ignore
6
- window.nostojs((api) => {
7
- api
8
- .defaultSession()
9
- .setResponseMode("HTML")
10
- .viewSearch(query)
11
- .setPlacements(api.placements.getPlacements())
12
- .load()
13
- .then((data: object) => {
14
- // @ts-ignore
15
- api.placements.injectCampaigns(data.recommendations);
16
- });
17
- });
18
- }, []);
19
-
20
- return (
21
- <>
22
- <div className="nosto_page_type" style={{ display: "none" }}>
23
- search
24
- </div>
25
- <div className="nosto_search" style={{ display: "none" }}>
26
- {query}
27
- </div>
28
- </>
29
- );
30
- };
31
-
32
- export default NostoSearch;