<div id="root"></div>
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
background-color: #10375c;
display: flex;
align-items: center;
justify-content: center;
}
@mixin plus-minus {
font-size: 60px;
color: #ffff;
cursor: pointer;
user-select: none;
}
.container {
display: flex;
justify-content: center;
}
.plus {
@include plus-minus;
}
.minus {
@include plus-minus;
}
.num {
margin: 0 50px 0 50px;
color: lighten(red, 20%);
font-size: 60px;
}
View Compiled
const { useState } = React;
const Counter = () => {
const [count, setCount] = useState(0);
return (
<div className="container">
{count >= 10 || (
<div className="plus" onClick={() => setCount(count + 1)}>
+
</div>
)}
<div className="num">{count}</div>
{count > 0 && (
<div className="minus" onClick={() => setCount(count - 1)}>
-
</div>
)}
</div>
);
};
ReactDOM.render(
<div>
<Counter />
<Counter />
<Counter />
</div>,
document.querySelector("#root")
);
View Compiled
This Pen doesn't use any external CSS resources.