All files launcher.tsx

45.45% Statements 5/11
0% Branches 0/9
0% Functions 0/3
45.45% Lines 5/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 433x 3x   3x                         3x                                                 3x  
import * as React from 'react'
import { observer } from 'mobx-react'
import { Store } from './store'
import { getKernel } from '@code-202/kernel'
 
export interface Props {
    storeId?: string
    className?: string
    content?: (store: Store) => React.ReactNode
    alwaysShown?: boolean
}
 
export interface State {
 
}
 
export class Launcher extends React.Component<Props, State> {
    protected store: Store
 
    constructor(props: Props) {
        super(props)
 
        this.store = getKernel().container.get(props.storeId !== undefined ? props.storeId : 'cookie-consent') as Store
    }
 
    render (): React.ReactNode {
        Iif (!this.props.alwaysShown && this.store.noCookie !== false) {
            return null
        }
 
        return <>
            <button
                className={ this.props.className !== undefined ? this.props.className : 'm-1 border-0' }
                onClick={() => this.store.toggleDialog()}
                >
                { this.props.content !== undefined ? this.props.content(this.store) : 'Manage cookie consent' }
            </button>
        </>
    }
}
 
export default observer(Launcher)