All files / src/entities/brush/ui BrushFloatingPalette.tsx

100% Statements 5/5
100% Branches 0/0
100% Functions 3/3
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26              2x 8x 8x                   1x 2x          
import React from 'react';
import { ToolFloatingPalette } from '@/widgets/toolbar/ui';
import { TOOL_COLORS, TOOL_SIZES, UI_LABELS } from '@/shared/constants';
import { useAppDispatch, useAppSelector } from '@/store/hooks';
import { setBrushColor, setBrushSize } from '@/entities/brush/model/slice';
import { selectBrushState } from '@/entities/brush/model';
 
export const BrushFloatingPalette = React.memo(function BrushFloatingPalette() {
	const dispatch = useAppDispatch();
	const { color, size } = useAppSelector(selectBrushState);
 
	return (
		<ToolFloatingPalette
			title={UI_LABELS.BRUSH_TOOL}
			subtitle={UI_LABELS.BRUSH_TOOL_SUB}
			values={TOOL_SIZES}
			colors={TOOL_COLORS}
			selectedValue={size}
			selectedColor={color}
			onValueChange={(v) => dispatch(setBrushSize(v))}
			onColorChange={(c) => dispatch(setBrushColor(c))}
			position="bottom-19"
		/>
	);
});