diff --git a/src/page-components/tones/ToneSeries.tsx b/src/page-components/tones/ToneSeries.tsx
deleted file mode 100644
index 8d6624d..0000000
--- a/src/page-components/tones/ToneSeries.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { useMemo } from 'react';
-import { useColorFunction } from '../../ColorFunctionContext';
-import { FlexColorStand } from '../../components/FlexColorStand';
-
-type ToneSeresProps = {
- color?: string;
- expand?: number;
- step?: number;
- valueMode?: 'hex' | 'rgb' | 'hsl' | 'lab' | 'oklch';
-};
-
-export function LightenSeries({
- color = '000000',
- expand = 3,
- step = 10,
- valueMode = 'hex',
-}: ToneSeresProps) {
- const { colorFn } = useColorFunction();
- const colors = useMemo(() => {
- try {
- const lightenColors = colorFn!.tonal_lighten_series(color, expand, step / 100);
- return lightenColors;
- } catch (e) {
- console.error('[Expand lighten colors]', e);
- }
- return Array.from({ length: expand }, () => color);
- }, [color, expand, step]);
-
- return (
- <>
- {colors.map((c, index) => (
-
- ))}
- >
- );
-}
-
-export function DarkenSeries({
- color = '000000',
- expand = 3,
- step = 10,
- valueMode = 'hex',
-}: ToneSeresProps) {
- const { colorFn } = useColorFunction();
- const colors = useMemo(() => {
- try {
- const darkenColors = colorFn!.tonal_darken_series(color, expand, step / 100);
- return darkenColors;
- } catch (e) {
- console.error('[Expand darken colors]', e);
- }
- return Array.from({ length: expand }, () => color);
- }, [color, expand, step]);
-
- return (
- <>
- {colors.map((c, index) => (
-
- ))}
- >
- );
-}
diff --git a/src/pages/Tones.tsx b/src/pages/Tones.tsx
index 1b28dd8..e68d6bc 100644
--- a/src/pages/Tones.tsx
+++ b/src/pages/Tones.tsx
@@ -1,21 +1,40 @@
import cx from 'clsx';
import { useAtom } from 'jotai';
import { toInteger } from 'lodash-es';
-import { useState } from 'react';
+import { useMemo, useState } from 'react';
+import { useColorFunction } from '../ColorFunctionContext';
import { ColorPicker } from '../components/ColorPicker';
import { FlexColorStand } from '../components/FlexColorStand';
import { HSegmentedControl } from '../components/HSegmentedControl';
import { LabeledPicker } from '../components/LabeledPicker';
-import { DarkenSeries, LightenSeries } from '../page-components/tones/ToneSeries';
import { currentPickedColor } from '../stores/colors';
import styles from './Tones.module.css';
export function Tones() {
+ const { colorFn } = useColorFunction();
const [selectedColor, setSelectedColor] = useAtom(currentPickedColor);
const [steps, setSteps] = useState(10);
const [tones, setTones] = useState(3);
const [seedBias, setSeedBias] = useState(0);
const [mode, setMode] = useState<'hex' | 'rgb' | 'hsl' | 'lab' | 'oklch'>('hex');
+ const colors = useMemo(() => {
+ try {
+ const lightenColors = colorFn!.tonal_lighten_series(
+ selectedColor,
+ tones - seedBias,
+ steps / 100,
+ );
+ const darkenColors = colorFn!.tonal_darken_series(
+ selectedColor,
+ tones + seedBias,
+ steps / 100,
+ );
+ return [...darkenColors, selectedColor, ...lightenColors];
+ } catch (e) {
+ console.error('[Expand colors]', e);
+ }
+ return Array.from({ length: tones * 2 + 1 }, () => selectedColor);
+ }, [selectedColor, tones, seedBias, steps]);
return (
@@ -43,7 +62,7 @@ export function Tones() {
}}
/>
-
-
-
+ {colors.map((c, index) => (
+
+ ))}