parent
512f9d4e13
commit
3f05452f1a
@ -1,28 +1,26 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
|
||||||
export default function ColorGen() {
|
export default function ColorGen() {
|
||||||
let str = '0123456789abcdef';
|
|
||||||
let hexColor = () => {
|
let hexcolor = () => {
|
||||||
let color = '';
|
let color = '';
|
||||||
|
let str = '0123456789abcdef';
|
||||||
for (let i = 0; i < 6; i++) {
|
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];
|
color += str[hex];
|
||||||
}
|
}
|
||||||
return '#' + color;
|
return '#' + color;
|
||||||
}
|
}
|
||||||
let style = {
|
let arr = Array(6).fill(0);
|
||||||
backgroundColor: '{hexColor}',
|
|
||||||
}
|
let sixColor = arr.map((i) => <div className="color" style={{ backgroundColor: `${hexcolor()}` }}>
|
||||||
|
<h1>{ hexcolor()}</h1>
|
||||||
|
</div>);
|
||||||
|
// console.log(hexcolor());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="colorGen">
|
<section className="colorGen">
|
||||||
<div className="colorContainer" style={style}
|
{sixColor}
|
||||||
>
|
|
||||||
{hexColor()}
|
|
||||||
</div>
|
|
||||||
<button>Genarate</button>
|
|
||||||
</section>
|
</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