Skip to content

Commit

Permalink
Merge pull request #423 from Lemoncode/feature/#195-Add-a-new-prop-to…
Browse files Browse the repository at this point in the history
…-select-the-color-of-the-selected-item-band-on-the-list-box

feature/#195 Add a new prop to select the color of the selected item band on the list box
  • Loading branch information
brauliodiez authored Oct 11, 2024
2 parents c501455 + 3ccef86 commit 9f10ad5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ export const ListBoxShape = forwardRef<any, ListBoxShapeProps>((props, ref) => {

const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;

const { stroke, strokeStyle, fill, borderRadius, textColor } = useShapeProps(
otherProps,
BASIC_SHAPE
);
const {
stroke,
strokeStyle,
fill,
borderRadius,
textColor,
selectedBackgroundColor,
} = useShapeProps(otherProps, BASIC_SHAPE);

const commonGroupProps = useGroupShapeProps(
props,
Expand Down Expand Up @@ -106,8 +110,10 @@ export const ListBoxShape = forwardRef<any, ListBoxShapeProps>((props, ref) => {
y={0 + index * singleHeaderHeight}
width={restrictedWidth}
height={singleHeaderHeight}
fill={selectedItem === index ? 'lightblue' : fill}
stroke={selectedItem === index ? 'skyblue' : 'transparent'}
fill={selectedItem === index ? selectedBackgroundColor : fill}
stroke={
selectedItem === index ? selectedBackgroundColor : 'transparent'
}
strokeWidth={selectedItem === index ? 1 : 0}
/>
<Text
Expand Down
6 changes: 6 additions & 0 deletions src/common/components/shapes/use-shape-props.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export const useShapeProps = (
return typeof prog === 'string' ? parseFloat(prog) : prog;
}, [otherProps?.progress]);

const selectedBackgroundColor = useMemo(
() => otherProps?.selectedBackgroundColor ?? '#add8e6',
[otherProps?.selectedBackgroundColor]
);

return {
stroke,
fill,
Expand All @@ -50,5 +55,6 @@ export const useShapeProps = (
borderRadius,
isOn,
progress,
selectedBackgroundColor,
};
};
1 change: 1 addition & 0 deletions src/core/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export interface OtherProps {
progress?: string;
borderRadius?: string;
activeElement?: number;
selectedBackgroundColor?: string;
}

export const BASE_ICONS_URL = '/icons/';
Expand Down
8 changes: 7 additions & 1 deletion src/pods/canvas/canvas.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ export const generateDefaultOtherProps = (
};
case 'button':
case 'textarea':
case 'listbox':
case 'vertical-menu':
case 'horizontal-menu':
return {
Expand Down Expand Up @@ -444,6 +443,13 @@ export const generateDefaultOtherProps = (
strokeStyle: [],
borderRadius: `${INPUT_SHAPE.DEFAULT_CORNER_RADIUS}`,
};
case 'listbox':
return {
stroke: '#000000',
backgroundColor: '#ffffff',
textColor: '#000000',
selectedBackgroundColor: '#add8e6',
};

case 'circle':
case 'star':
Expand Down
9 changes: 9 additions & 0 deletions src/pods/properties/properties.pod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ export const PropertiesPod = () => {
}
/>
)}
{selectedShapeData?.otherProps?.selectedBackgroundColor != undefined && (
<ColorPicker
label="Selected Background"
color={selectedShapeData.otherProps.selectedBackgroundColor}
onChange={color =>
updateOtherPropsOnSelected('selectedBackgroundColor', color)
}
/>
)}
</div>
);
};

0 comments on commit 9f10ad5

Please sign in to comment.