完成Swatch Scheme的构建基本功能。
This commit is contained in:
@@ -1,3 +1,35 @@
|
||||
export function SwatchScheme() {
|
||||
return <div>Swatch Scheme</div>;
|
||||
import { isEqual, isNil } from 'lodash-es';
|
||||
import { useState } from 'react';
|
||||
import { Tab } from '../../components/Tab';
|
||||
import { SchemeContent } from '../../models';
|
||||
import { SwatchSchemeStorage } from '../../swatch_scheme';
|
||||
import { SchemeExport } from './Export';
|
||||
import { SwatchSchemeBuilder } from './swatch-scheme/Builder';
|
||||
import { SwatchSchemePreview } from './swatch-scheme/Preview';
|
||||
|
||||
const tabOptions = [
|
||||
{ title: 'Overview', id: 'overview' },
|
||||
{ title: 'Builder', id: 'builder' },
|
||||
{ title: 'Exports', id: 'export' },
|
||||
];
|
||||
|
||||
type SwatchSchemeProps = {
|
||||
scheme: SchemeContent<SwatchSchemeStorage>;
|
||||
};
|
||||
|
||||
export function SwatchScheme({ scheme }: SwatchSchemeProps) {
|
||||
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') && <SwatchSchemePreview scheme={scheme} />}
|
||||
{isEqual(activeTab, 'builder') && (
|
||||
<SwatchSchemeBuilder scheme={scheme} onBuildCompleted={() => setActiveTab('overview')} />
|
||||
)}
|
||||
{isEqual(activeTab, 'export') && <SchemeExport scheme={scheme} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user