31 lines
977 B
TypeScript
31 lines
977 B
TypeScript
import { isEqual, isNil } from 'lodash-es';
|
|
import { useState } from 'react';
|
|
import { Tab } from '../../components/Tab';
|
|
import { MaterialDesign3SchemeStorage } from '../../material-3-scheme';
|
|
import { SchemeExport } from './Export';
|
|
|
|
const tabOptions = [
|
|
{ title: 'Overview', id: 'overview' },
|
|
{ title: 'Builder', id: 'builder' },
|
|
{ title: 'Exports', id: 'export' },
|
|
];
|
|
|
|
type M3SchemeProps = {
|
|
scheme: SchemeContent<MaterialDesign3SchemeStorage>;
|
|
};
|
|
|
|
export function M3Scheme({ scheme }: M3SchemeProps) {
|
|
const [activeTab, setActiveTab] = useState<(typeof tabOptions)[number]['id']>(() =>
|
|
isNil(scheme.schemeStorage.scheme) ? 'builder' : 'overview',
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<Tab tabs={tabOptions} activeTab={activeTab} onActive={setActiveTab} />
|
|
{isEqual(activeTab, 'overview') && <div>Preview</div>}
|
|
{isEqual(activeTab, 'builder') && <div>Builder</div>}
|
|
{isEqual(activeTab, 'export') && <SchemeExport scheme={scheme} />}
|
|
</>
|
|
);
|
|
}
|