Question
I am trying to convert some of my jQuery projects over to use ReactJS. I would like to add/remove individual classes for background color, border, shape, size, etc. I want to be able to use many options (like 20 colors). If I add a background color, I want to remove the current background color without removing the current border, shape, or size classes. Is there a way to do this?
Research
I have read many posts on altering the buttons on hover, on toggling a class on/off, and changing out one class for another, but these have not pointed me in the right direction.
Image
More Details
If I click the bg_blue button, I would like the background to change without loosing the red border. If I click the border_gray button, I would like it to change without loosing the current background color.
Start Code
import React from 'react';
var classNames = require( 'classnames' );
export class Body extends React.Component {
render() {
const red = {
backgroundColor: "red"
};
const gray = {
backgroundColor: "gray"
};
const blue = {
backgroundColor: "blue"
};
const border_red = {
borderWidth: 3,
borderColor: "red",
borderStyle: "solid"
};
const border_gray = {
borderWidth: 3,
borderColor: "gray",
borderStyle: "solid"
};
const border_blue = {
borderWidth: 3,
borderColor: "blue",
borderStyle: "solid"
};
return (
<div className="App-body">
<div className="start-shape" style= {border_red} ></div>
<button className="button" onClick="">bg_Red</button>
<button className="button">bg_Gray</button>
<button className="button">bg_Blue</button>
<button className="button">border_Red</button>
<button className="button">border_Gray</button>
<button className="button">border_Blue</button>
</div>
);
}
}
