import {Component} from 'preact'; import {useContext} from 'preact/hooks'; import {html} from 'htm/preact'; import {AppContext} from '../context.js'; export type SettingProps = { children: TRXComponent | undefined; class: string; enabled: boolean; feature: string; title: string; }; class Header extends Component { render() { const {props} = this; const context = useContext(AppContext); const enabled = props.enabled ? 'Enabled' : 'Disabled'; return html`

${props.title}

`; } } // A base component for all the settings, this adds the header and the // enable/disable buttons. This can also be used as a placeholder for new // settings when you're still developing them. export function Setting(props: SettingProps): TRXComponent { const children = props.children === undefined ? html`

This setting still needs a component!

` : props.children; const enabled = (props.enabled ? 'Enabled' : 'Disabled').toLowerCase(); return html`
<${Header} ...${props} />
${children}
`; }