diff --git a/src/page-components/scheme/M2Scheme.tsx b/src/page-components/scheme/M2Scheme.tsx
index fd2521c..a18d2c3 100644
--- a/src/page-components/scheme/M2Scheme.tsx
+++ b/src/page-components/scheme/M2Scheme.tsx
@@ -2,6 +2,8 @@ import { isEqual, isNil } from 'lodash-es';
import { useState } from 'react';
import { Tab } from '../../components/Tab';
import { SchemeExport } from './Export';
+import { M2SchemeBuilder } from './m2-scheme/Builder';
+import { M2SchemePreview } from './m2-scheme/Preview';
const tabOptions = [
{ title: 'Overview', id: 'overview' },
@@ -21,8 +23,10 @@ export function M2Scheme({ scheme }: M3SchemeProps) {
return (
<>
- {isEqual(activeTab, 'overview') &&
Preview
}
- {isEqual(activeTab, 'builder') && Builder
}
+ {isEqual(activeTab, 'overview') && }
+ {isEqual(activeTab, 'builder') && (
+ setActiveTab('overview')} />
+ )}
{isEqual(activeTab, 'export') && }
>
);
diff --git a/src/page-components/scheme/m2-scheme/Preview.module.css b/src/page-components/scheme/m2-scheme/Preview.module.css
new file mode 100644
index 0000000..157e54f
--- /dev/null
+++ b/src/page-components/scheme/m2-scheme/Preview.module.css
@@ -0,0 +1,41 @@
+@layer pages {
+ .preview_layout {
+ padding: var(--spacing-s) var(--spacing-m);
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: stretch;
+ gap: var(--spacing-m);
+ }
+ .preview_block {
+ width: inherit;
+ padding: var(--spacing-m) var(--spacing-m);
+ display: flex;
+ flex-direction: column;
+ gap: var(--spacing-m);
+ font-size: var(--font-size-s);
+ line-height: 1.1em;
+ h4 {
+ font-size: var(--font-size-m);
+ font-weight: bold;
+ line-height: 1.7em;
+ }
+ }
+ .horizontal_set {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-evenly;
+ align-items: stretch;
+ gap: 0;
+ }
+ .color_block {
+ padding: var(--spacing-s) var(--spacing-xs);
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: var(--spacing-xs);
+ .wacg {
+ font-size: var(--font-size-xxs);
+ }
+ }
+}
diff --git a/src/page-components/scheme/m2-scheme/Preview.tsx b/src/page-components/scheme/m2-scheme/Preview.tsx
new file mode 100644
index 0000000..c6c05a4
--- /dev/null
+++ b/src/page-components/scheme/m2-scheme/Preview.tsx
@@ -0,0 +1,94 @@
+import { useMemo } from 'react';
+import { useColorFunction } from '../../../ColorFunctionContext';
+import { ScrollArea } from '../../../components/ScrollArea';
+import { Baseline, ColorSet, MaterialDesign2SchemeStorage } from '../../../material-2-scheme';
+import { SchemeContent } from '../../../models';
+import styles from './Preview.module.css';
+
+type M2SchemeFunctionColorProps = {
+ title: string;
+ color: ColorSet;
+};
+
+function M2SchemeFunctionColor({ title, color }: M2SchemeFunctionColorProps) {
+ const { colorFn } = useColorFunction();
+ const rootWacgRatio = useMemo(() => {
+ try {
+ return colorFn?.wacg_relative_contrast(color.on, color.root) ?? null;
+ } catch (e) {
+ console.error('[calc root wacg]', e);
+ }
+ return null;
+ }, [colorFn, color.on, color.root]);
+ const variantWacgRatio = useMemo(() => {
+ try {
+ return colorFn?.wacg_relative_contrast(color.on, color.variant) ?? null;
+ } catch (e) {
+ console.error('[calc variant wacg]', e);
+ }
+ return null;
+ }, [colorFn, color.on, color.variant]);
+
+ return (
+
+
+ {title}
+ WACG: {rootWacgRatio?.toFixed(2)}
+
+
+ {title} Variant
+ WACG: {variantWacgRatio?.toFixed(2)}
+
+
+ On {title}
+
+
+ );
+}
+
+type PreviewBlockProps = {
+ title: string;
+ baseline: Baseline;
+};
+
+function PreviewBlock({ title, baseline }: PreviewBlockProps) {
+ return (
+
+
{title} Scheme
+
+
+
+
+
+ {Object.entries(baseline.custom_colors).map(([name, set], index) => (
+
+ ))}
+
+ );
+}
+
+type M2SchemePreviewProps = {
+ scheme: SchemeContent;
+};
+
+export function M2SchemePreview({ scheme }: M2SchemePreviewProps) {
+ return (
+
+
+
+ );
+}