aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-tools-pages/ts/components/withContext.tsx
blob: d38c0afe48582ed32461948dd157f4ba44c8fb36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as React from 'react';

import ThemeContext from '../context';

interface Props {
    title?: string;
    name?: string;
    subtitle?: string;
    tagline?: string;
    icon?: React.ReactNode;
    colors?: any;
}

function withContext(WrappedComponent: any) {
    function ComponentWithContext(props: any) {
        return <ThemeContext.Consumer>{data => <WrappedComponent {...data} {...props} />}</ThemeContext.Consumer>;
    }

    return ComponentWithContext;
}

export default withContext;
export { withContext, Props };