parent
512f9d4e13
commit
3f05452f1a
@ -1,28 +1,26 @@
|
||||
import React from "react";
|
||||
|
||||
|
||||
export default function ColorGen() {
|
||||
let str = '0123456789abcdef';
|
||||
let hexColor = () => {
|
||||
|
||||
let hexcolor = () => {
|
||||
let color = '';
|
||||
let str = '0123456789abcdef';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
let hex = Math.floor(Math.random() * str.length);
|
||||
let hex = Math.floor(Math.random() * str.length );
|
||||
color += str[hex];
|
||||
}
|
||||
return '#' + color;
|
||||
}
|
||||
let style = {
|
||||
backgroundColor: '{hexColor}',
|
||||
}
|
||||
let arr = Array(6).fill(0);
|
||||
|
||||
let sixColor = arr.map((i) => <div className="color" style={{ backgroundColor: `${hexcolor()}` }}>
|
||||
<h1>{ hexcolor()}</h1>
|
||||
</div>);
|
||||
// console.log(hexcolor());
|
||||
|
||||
return (
|
||||
<section className="colorGen">
|
||||
<div className="colorContainer" style={style}
|
||||
>
|
||||
{hexColor()}
|
||||
</div>
|
||||
<button>Genarate</button>
|
||||
{sixColor}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
// I DO NOT KNOW WHAT I AM DONING WRONG IN MY CODE. BUT ICAN'T SEE THE CHANGE OF BACKGROUND COLOR AFTER GIVING THE HEIGHT AND WIDTH TO THE COLOR CONTAINER
|
Loading…
Reference in new issue