import headerStyles from '../common/Header.module.css';
import styles from './SettingsView.module.css';
import { version as wasmVersion } from 'objdiff-wasm';
import {
CONFIG_SCHEMA,
type ConfigPropertyBoolean,
type ConfigPropertyChoice,
} from '../../shared/config';
import {
inVsCode,
openSettings,
setConfigProperty,
useAppStore,
useExtensionStore,
} from '../state';
const BooleanProperty = ({
property,
value,
}: { property: ConfigPropertyBoolean; value: boolean }) => (
{
const value = e.target.checked;
if (value === property.default) {
setConfigProperty(property.id, undefined);
} else {
setConfigProperty(property.id, value);
}
}}
/>
);
const ChoiceProperty = ({
property,
value,
}: { property: ConfigPropertyChoice; value: string }) => (
);
const SettingsView = () => {
const setCurrentView = useAppStore((state) => state.setCurrentView);
const configProperties = useExtensionStore((state) => state.configProperties);
const items = [];
for (const group of CONFIG_SCHEMA.groups) {
items.push(
{group.name}
,
);
for (const id of group.properties) {
const property = CONFIG_SCHEMA.properties.find((p) => p.id === id);
if (!property) {
continue;
}
const value = configProperties[property.id] ?? property.default;
switch (property.type) {
case 'boolean':
items.push(
,
);
break;
case 'choice':
items.push(
,
);
break;
}
}
}
return (
<>
{inVsCode && (
)}
About
{window.webviewProps?.extensionVersion && (
Extension version:{' '}
{window.webviewProps.extensionVersion}
)}
objdiff version: {wasmVersion()}
Settings
{items}
>
);
};
export default SettingsView;