saleor-dashboard/src/components/Shop/index.tsx

34 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-08-12 09:38:01 +00:00
import appleTouchIcon from "@assets/favicons/apple-touch-icon.png";
import favicon16 from "@assets/favicons/favicon-16x16.png";
import favicon32 from "@assets/favicons/favicon-32x32.png";
import safariPinnedTab from "@assets/favicons/safari-pinned-tab.svg";
import React from "react";
import Helmet from "react-helmet";
2019-06-19 14:40:52 +00:00
import { TypedShopInfoQuery } from "./query";
import { ShopInfo_shop } from "./types/ShopInfo";
type ShopContext = ShopInfo_shop;
2019-08-12 09:38:01 +00:00
export const ShopContext = React.createContext<ShopContext>(undefined);
2019-06-19 14:40:52 +00:00
2019-08-12 09:38:01 +00:00
export const ShopProvider: React.FC = ({ children }) => (
2019-06-19 14:40:52 +00:00
<TypedShopInfoQuery>
{({ data }) => (
2019-08-12 09:38:01 +00:00
<>
<Helmet>
<link rel="apple-touch-icon" sizes="180x180" href={appleTouchIcon} />
<link rel="icon" type="image/png" sizes="32x32" href={favicon32} />
<link rel="icon" type="image/png" sizes="16x16" href={favicon16} />
<link rel="mask-icon" href={safariPinnedTab} />
</Helmet>
<ShopContext.Provider value={data ? data.shop : undefined}>
{children}
</ShopContext.Provider>
</>
2019-06-19 14:40:52 +00:00
)}
</TypedShopInfoQuery>
);
2019-08-12 09:38:01 +00:00
export const Shop = ShopContext.Consumer;
2019-06-19 14:40:52 +00:00
export default Shop;