Skip to content

Commit

Permalink
Merge pull request #5 from nft-login/random-colors
Browse files Browse the repository at this point in the history
preselect random colors on minting form
  • Loading branch information
venuswhispers committed Nov 9, 2021
2 parents 8fada03 + 25969ce commit 3a73cec
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/components/FormAndPreview/FormAndPreview.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
import React, { Component } from "react";
import CryptoBoyNFTImage from "../CryptoBoyNFTImage/CryptoBoyNFTImage";

// source: https://stackoverflow.com/questions/1484506/random-color-generator
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}

class FormAndPreview extends Component {
constructor(props) {
super(props);
this.state = {
userSelectedColors: [
{
cardBorderColor: "",
cardBackgroundColor: "",
headBorderColor: "",
headBackgroundColor: "",
leftEyeBorderColor: "",
rightEyeBorderColor: "",
leftEyeBackgroundColor: "",
rightEyeBackgroundColor: "",
leftPupilBackgroundColor: "",
rightPupilBackgroundColor: "",
mouthColor: "",
neckBackgroundColor: "",
neckBorderColor: "",
bodyBackgroundColor: "",
bodyBorderColor: "",
cardBorderColor: getRandomColor(),
cardBackgroundColor: getRandomColor(),
headBorderColor: getRandomColor(),
headBackgroundColor: getRandomColor(),
leftEyeBorderColor: getRandomColor(),
rightEyeBorderColor: getRandomColor(),
leftEyeBackgroundColor: getRandomColor(),
rightEyeBackgroundColor: getRandomColor(),
leftPupilBackgroundColor: getRandomColor(),
rightPupilBackgroundColor: getRandomColor(),
mouthColor: getRandomColor(),
neckBackgroundColor: getRandomColor(),
neckBorderColor: getRandomColor(),
bodyBackgroundColor: getRandomColor(),
bodyBorderColor: getRandomColor(),
},
],
cryptoBoyName: "",
Expand Down

0 comments on commit 3a73cec

Please sign in to comment.