Assignment - Template and Color

Having trouble getting the page layout to look nice (never done anything with html/css before this), but here’s the cat + color sliders:

index.html

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy kitties </title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <script src="assets/bootstrap/js/popper.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/mystyle.css">
  <link rel="stylesheet" href="assets/css/cats.css">
  <link rel="stylesheet" href="assets/css/colors.css">
  <link rel="stylesheet" href="assets/css/factory.css">
  <link rel="stylesheet" href="assets/css/frontend.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Kitties-Factory</h1>
        <p class="c-white">Create your custom Kitty</p>
    </div>
        <div class="row">
            <!-- <div class="col-lg-4 catBox m-2 light-b-shadow"> -->
                <div class="cat" style= top:-60px;>

                  <div class="cat__ear">
                    <div id="left ear" class="cat__ear_left">
                      <div class="cat__inner_ear_left"></div>
                    </div>
                    <div id="right ear" class="cat__ear_right">
                      <div class="cat__inner_ear_right"></div>
                    </div>
                  </div>

                  <div class="cat__body">
                    <div class="cat__chest"></div>

                    <div id="bodystripes" class="cat__body_stripes"></div>
                    <div class="cat__body_stripes cat__left_stripe1"></div>
                    <div class="cat__body_stripes cat__left_stripe2"></div>
                    <div class="cat__body_stripes cat__left_stripe3"></div>
                    <div class="cat__body_stripes cat__right_stripe1"></div>
                    <div class="cat__body_stripes cat__right_stripe2"></div>
                    <div class="cat__body_stripes cat__right_stripe3"></div>

                    <div id="belly" class="cat__belly"></div>

                    <div class="cat__backpaw cat__right_back_paw">
                      <div class="cat__fingers"></div>
                    </div>
                    <div class="cat__backpaw cat__left_back_paw">
                      <div class="cat__fingers"></div>
                    </div>

                    <!-- <div class="right_arm"></div>
                    <div class="left_arm"></div> -->

                    <div class="cat__frontpaw cat__right_front_paw">
                      <div class="cat__fingers"></div>
                    </div>
                    <div class="cat__frontpaw cat__left_front_paw">
                      <div class="cat__fingers"></div>
                    </div>

                    <div id="tail" class="cat__tail"></div>

                  </div>



                  <div id="head" class="cat__head">
                    <div id="headstripes" class="cat__head_stripes"></div>
                    <div class="cat__head_stripes cat__head_stripe1"></div>
                    <div class="cat__head_stripes cat__head_stripe2"></div>
                    <div class="cat__head_stripes cat__head_stripe3"></div>

                    <div class="cat__eye"></div>
                    <div class="cat__eye_left">
                      <div class="cat__pupil_left">
                        <div class="cat__glint_left"></div>
                        <div class="cat__glint2_left"></div>
                        <div class="cat__glint3_left"></div>
                      </div>
                      <div id="eyelidL" class="cat__eyelid_left"></div>
                    </div>

                    <div class="cat__eye_right">
                      <div class="cat__pupil_right">
                        <div class="cat__glint_right"></div>
                        <div class="cat__glint2_right"></div>
                        <div class="cat__glint3_right"></div>
                      </div>
                      <div id="eyelidR" class="cat__eyelid_right"></div>
                    </div>

                    <div class="cat__jowls_left"></div>
                    <div class="cat__jowls_right"></div>

                    <div class="cat__nose">
                      <div class="cat__nostril_left"></div>
                      <div class="cat__nostril_right"></div>
                    </div>

                    <div class="cat__whiskers_left"></div>
                    <div class="cat__whiskers_right"></div>

                  </div>


                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnaear"></span>
                         <span id="dnaeyes"></span>
                         <span id="dnaears"></span>

                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            <!-- </div> -->
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
<div id="catColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Ears</b><span class="badge badge-dark ml-2" id="earcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earcolor">
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Paws and tail</b><span class="badge badge-dark ml-2" id="pawscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="pawscolor">
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Stripes</b><span class="badge badge-dark ml-2" id="stripescode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="stripescolor">
                </div>

            </div>

            </div>

            </div>
            <br>

        </div>



    </div>
    <!-- <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer> -->

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

cats.css

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}
html {
    box-sizing: border-box;
    overflow-y: scroll;
}
body {
    background: #607d8b;

}


.cat__ear {
    position: relative;
}
.cat__ear_left, .cat__ear_right {
    position: absolute;
    top: 33px;
    width: 150px;
    height: 150px;
    border: 5px solid transparent;
    border-radius: 90% 0 90% 0;
    background: #41adf0;
    display: flex;
    justify-content: center;
    align-items: center;
}
.cat__ear_left {
    transform: scale(-1, 1) rotate(160deg);
    left: -14px;

}
.cat__ear_right {
    transform: rotate(160deg);
    left: 94px;
}
.cat__inner_ear_left, .cat__inner_ear_right {
    width: 108px;
    height: 108px;
    background: #274b61;
    border-radius: 90% 0 90% 0;
    border: 5px solid transparent;
}



.cat__head {
    position: relative;
    top: 60px;
    width: 230px;
    height: 200px;
    border: 5px solid transparent;
    -webkit-border-radius: 50% 50% 50% 50%;
    border-radius: 50% 50% 50% 50%;
    background: #41adf0;
/*     z-index: 20; */
}

.cat__eye {
    position: absolute;
/*     top: 35px; */
/*     left: -16px; */
/*     display: flex; */
}
.cat__eye_left, .cat__eye_right {
    width: 55px;
    height: 57px;
    background: #ffffff;
    border-radius: 50% 50% 50% 50%;
/*     margin: 38px; */
/*     z-index: 100; */
}
.cat__eye_left {
    top: 50px;
    left: 30px;
    position: absolute;
}
.cat__eye_right {
    top: 50px;
    right: 30px;
    position: absolute;
}
.cat__pupil_left, .cat__pupil_right {
    position: absolute
    width: 55px;
    height: 57px;
    border-radius: 50%;
    background-color: #000000;
    transform: scale(.85);
}
.cat__glint_left, .cat__glint_right {
    position: absolute;
    right: 8px;
    top: 9px;
    width: 20px;
    height: 22px;
    border-radius: 50%;
    background-color: #ffffff;
}
.cat__glint2_left, .cat__glint2_right {
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ffffff;
    opacity: 85%;
}
.cat__glint3_left, .cat__glint3_right {
    position: absolute;
    left: 14px;
    bottom: 11px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: #ffffff;
    opacity: 15%;
}
.cat__eyelid_right, .cat__eyelid_left {
    position: absolute;
    height: 16px;
    width: 57px;
    border-top-left-radius: 57px;
    border-top-right-radius: 57px;
    top: 0px;
    background-color: #274b61;
    opacity: 0%;
}

.cat__nose {
    position: absolute;
    top: 99px;
    left: 91px;

    width: 0;
    height: 0;
    border-right: 20px solid rgba(255, 255, 255, 0);
    border-left: 20px solid rgba(255, 255, 255, 0);
    border-top: 15px solid #e57373;
    border-radius: 40%;
/*     z-index: 100; */

}

.cat__nostril_left, .cat__nostril_right {
    position: absolute;
    width: 6px;
    height: 3px;
    background-color: #274b61;
    border-radius: 50%;
    z-index: 100;
}
.cat__nostril_left {
    top: -9px;
    right: 2px;
}
.cat__nostril_right {
    top: -9px;
    left: 2px;
}

.cat__jowls_left, .cat__jowls_right {
    position: absolute;
    width: 45px;
    height: 39px;
    background-color: #d9c79c;
    border-radius: 50%;
    opacity: 50%;
}
.cat__jowls_left {
    bottom: 47px;
    left: 66px
}
.cat__jowls_right {
    bottom: 47px;
    right: 64px;
}

.cat__whiskers_left, .cat__whiskers_right {
    position: relative;
}
.cat__whiskers_left, .cat__whiskers_right, .cat__whiskers_left::after, .cat__whiskers_right::after, .cat__whiskers_left::before, .cat__whiskers_right::before {
    width: 60px;
    height: 2px;
    background: #373737;
}
.cat__whiskers_left::before, .cat__whiskers_right::before, .cat__whiskers_left::after, .cat__whiskers_right::after {
    content: '';
    position: absolute;
    left: 0;
}
.cat__whiskers_left {
    top: 123px;
    left: 19px;
}
.cat__whiskers_left::before {
    top: -12px;
    transform: rotate(12deg);
}
.cat__whiskers_left::after {
    top: 12px;
    transform: rotate(-12deg);
}
.cat__whiskers_right {
    top: 123px;
    left: 144px;
}
.cat__whiskers_right::before {
    top: -12px;
    transform: rotate(-12deg);
}
.cat__whiskers_right::after {
    top: 12px;
    transform: rotate(12deg);
}

.cat__body {
    position: absolute;
}
.cat__chest {
    position: absolute;
    left: 36px;
    top: 230px;
    width: 150px;
    height: 140px;
    background: #3a9fde;
    border: 5px solid  transparent;
    border-radius: 50% 50% 40% 40%;
    border: solid 1px;
    border-color: #274b61;
/*     z-index: -3; */
}
.cat__belly {
    content: '';
    position: absolute;
    top: 300px;
    left: 70px;
    width: 88px;
    height: 69px;
    border-radius: 50%;
    background: #fff3e0;
/*     z-index: 4; */
    opacity: 85%;
}

.cat__backpaw {
    position: absolute;
    background-color: #3a9fde;
    border: solid 1px;
    border-color: #274b61;
    width: 43px;
    height: 30px;
    border-radius: 60% 60% 40% 40%;
    z-index: -3;
}
.cat__left_back_paw {
    top: 346px;
    left: 28px;
}
.cat__right_back_paw {
    top: 346px;
    left: 152px;
}

.cat__fingers {
    position: absolute;
    width: 16px;
    height: 22px;
    border: solid 4px #ffffff;
    border-color: rgb(20 20 20 / 0%) rgb(20 20 20 / 35%) rgb(80 70 40 / 0%);
    border-radius:  60px 60px 30px 30px;
    left: 13px;
    bottom: -3px;
}

.cat__frontpaw {
    position: absolute;
    background-color: #41adf0;
    border: solid 2px;
    border-color: #274b61;
    width: 43px;
    height: 30px;
    border-radius: 60% 60% 40% 40%;
/*     z-index: -3; */
}
.cat__right_front_paw {
    top: 346px;
    left: 116px;
}
.cat__left_front_paw {
    top: 346px;
    left: 66px;
}
.cat__tail {
    position: absolute;
    top: 300px;
    left: 160px;
    width: 90px;
    height: 23px;
    background: #3a9fde;
    border: 3px solid transparent;
    border-radius: 45%;
    z-index: -2;
    transform: rotate(-40deg);
}

.cat__body_stripes {
    background: #5735f0;
    opacity: 20%;
}
.cat__left_stripe1 {
    position: absolute;
    content: '';
    width: 43px;
    height: 8px;
    top: 271px;
    left: 41px;
    border-radius: 70% 90% 90% 70%;
}
.cat__left_stripe2 {
    position: absolute;
    content: '';
    width: 34px;
    height: 9px;
    top: 286px;
    left: 38px;
    border-radius: 70% 90% 90% 70%;
}
.cat__left_stripe3 {
    position: absolute;
    content: '';
    width: 30px;
    height: 8px;
    top: 302px;
    left: 36px;
    border-radius: 70% 90% 90% 70%;
}
.cat__right_stripe1 {
    position: absolute;
    content: '';
    width: 43px;
    height: 8px;
    top: 271px;
    left: 138px;
    border-radius: 90% 70% 70% 90%;
}
.cat__right_stripe2 {
    position: absolute;
    content: '';
    width: 34px;
    height: 9px;
    top: 286px;
    left: 150px;
    border-radius: 90% 70% 70% 90%;
}
.cat__right_stripe3 {
    position: absolute;
    content: '';
    width: 30px;
    height: 8px;
    top: 302px;
    left: 155px;
    border-radius: 90% 70% 70% 90%;
}

.cat__head_stripes {
    background: #5735f0;
    opacity: 20%;
}
.cat__head_stripe1 {
    position: absolute;
    left: 105px;
    height: 44px;
    top: -2px;
    width: 12px;
    -webkit-border-radius: 0 0 50% 50%;
    border-radius: 0 0 50% 50%;
}

.cat__head_stripe2 {
    position: absolute;
    content: '';
    top: -2px;
    width: 10px;
    height: 33px;
    left: 90px;
    border-radius: 50% 0 50% 50%;
}
.cat__head_stripe3 {
    position: absolute;
    content: '';
    top: -2px;
    width: 10px;
    height: 33px;
    left: 121px;
    border-radius: 0 50% 50% 50%;
}

catSettings.js


var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "earcolor" : 10,
    "pawscolor" : 10,
    "stripescolor" : 10,

    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnaear').html(defaultDNA.earColor);
  $('#dnapaws').html(defaultDNA.pawsColor);
  $('#dnastripes').html(defaultDNA.stripesColor);

//   $('#dnashape').html(defaultDNA.eyesShape)
//   $('#dnadecoration').html(defaultDNA.decorationPattern)
//   $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
//   $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
//   $('#dnaanimation').html(defaultDNA.animation)
//   $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnaear').html()
    dna += $('#dnapaws').html()
    dna += $('#dnastripes').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)
    earColor(colors[dna.earcolor],dna.earcolor)
    $('#earcolor').val(dna.earcolor)
    pawsColor(colors[dna.pawscolor],dna.pawscolor)
    $('#pawscolor').val(dna.pawscolor)
    stripesColor(colors[dna.stripescolor],dna.stripescolor)
    $('#stripescolor').val(dna.stripescolor)
}

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})

$('#earcolor').change(()=>{
    var colorVal = $('#earcolor').val()
    earColor(colors[colorVal],colorVal)
})

$('#pawscolor').change(()=>{
    var colorVal = $('#pawscolor').val()
    pawsColor(colors[colorVal],colorVal)
})

$('#stripescolor').change(()=>{
    var colorVal = $('#stripescolor').val()
    stripesColor(colors[colorVal],colorVal)
})

catFactory.js


//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.cat__head, .cat__chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function earColor(color,code) {
    $('.cat__ear_left, .cat__ear_right').css('background', '#' + color)  //This changes the color of the cat
    $('#earcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaear').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function pawsColor(color,code) {
    $('.cat__backpaw, .cat__frontpaw, .cat__tail').css('background', '#' + color)  //This changes the color of the cat
    $('#pawscode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnapaws').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function stripesColor(color,code) {
    $('.cat__body_stripes, .cat__head_stripes').css('background', '#' + color)  //This changes the color of the cat
    $('#stripescode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnastripes').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(num) {

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
    }
}

async function normalEyes() {
    await $('.cat__eye').find('span').css('border', 'none')
}

async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

In the video showing off the slider and the cat’s color-changing dna property, Fillip mentions that having the minimum slider value as 110 would be difficult to implement in Solidity.

Why would it be difficult to implement in Solidity?

Thanks,
David

Here’s my Crypto Fishies update! I’ve left the file names in their original form for now, and will “fishify” everything later. :slightly_smiling_face:

index.html
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy fishies </title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <script src="assets/bootstrap/js/popper.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/mystyle.css">
  <link rel="stylesheet" href="assets/css/cats.css">
  <link rel="stylesheet" href="assets/css/colors.css">
  <link rel="stylesheet" href="assets/css/factory.css">
  <link rel="stylesheet" href="assets/css/frontend.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Fishies-Factory</h1>
        <p class="c-white">Create your custom Fishy</p>
        </div>
        <div class="row">
            <div class="col-lg-4 catBox m-2 light-b-shadow">
                <div class="fish">
                    <div class="fins">
                        <div id="leftFin" class="fish__fin--left"></div>
                        <div id="rightFin" class="fish__fin--right"></div>
                        <div id="topFin" class="fish__tailFin--top"></div>
                        <div id="bottomFin" class="fish__tailFin--bottom"></div>
                        <div id="dorsalFin" class="fish__stableFin--dorsal"></div>
                        <div id="st_leftFin" class="fish__stableFin--left"></div>
                        <div id="st_rightFin" class="fish__stableFin--right"></div>
                    </div>

                    <div id="body" class="fish__body">
                        <div class="fish__eye">
                            <div class="fish__eye--left">
                                <div class="pupil-left"></div>
                            </div>
                            <div class="fish__eye--right">
                                <div class="pupil-right"></div>
                            </div>
                        </div>
                        <div class="fish__mouth"></div>
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnaside"></span>
                         <span id="dnatail"></span>
                         <span id="dnastablizer"></span>
                         <span id="dnaeye"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
            <div id="catColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Side Fins</b><span class="badge badge-dark ml-2" id="sideFinCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="sideFinColor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Tail Fins</b><span class="badge badge-dark ml-2" id="tailcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="tailFinColor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Stabilizer Fins</b><span class="badge badge-dark ml-2" id="stablizercode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="stableFinColor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyeColor">
                </div>
            </div>

            </div>

        </div>
        <br>

    </div>



    </div>
    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>
cats.css
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}
html {
    box-sizing: border-box;
    overflow-y: scroll;
}
body {
    background: #607d8b;
 
}

.fish__body {
    background-color: rgb(79, 153, 153);
    width: 180px;
    height: 200px;
    border-radius: 50%;
    position: relative;
    left: 25px;
    top:30px;
    z-index: 20;
}

.fish__eye--left, .fish__eye--right {
    background-color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    position: absolute;
    top: 45px;
    display: flex;
}

.fish__eye--left {
    left: 25px;
}

.fish__eye--right {
    left: 105px;
}

.pupil-left, .pupil-right {
    background-color: black;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin: 20px;
    margin-top: 18px;
    position: absolute;
}


.fish__mouth {
    background-color: black;
    width: 40px;
    height: 55px;
    border-radius: 50%;
    position: absolute;
    left: 70px;
    top: 120px;
}

.fins{
    position: relative;
}

.fish__fin--left, .fish__fin--right{
    border-radius: 50px 10px 50px 10px;
    background-color: rgb(104, 168, 147);
    transform: rotate(25deg);
    height: 65px;
    width: 100px;
    position: absolute;
    top: 130px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 5px solid  transparent;
}

.fish__fin--left {
    transform: scale(1,-1) rotate(25deg);
    right: 236px;
}

.fish__fin--right {
    left: 185px;
}

.fish__tailFin--top, .fish__tailFin--bottom {
    border-radius: 5px 150px 5px 90px;
    background-color: rgb(80, 116, 136);
    height: 125px;
    width: 100px;
    position: absolute;
    left: -10px;
}

.fish__tailFin--top {
    top: -40px;
}

.fish__tailFin--bottom {
    transform: scale(1,-1) rotate(-1deg);
    top: 190px;
}

.fish__stableFin--dorsal, .fish__stableFin--left, .fish__stableFin--right {
    border-radius: 90px 1px 75px 1px;
    background-color: rgb(51, 79, 94);
    height: 125px;
    width: 80px;
    position: absolute;
}

.fish__stableFin--dorsal {
    left: 70px;
    top: -20px;
    transform: rotate(-25deg);
}

.fish__stableFin--left {
    transform: rotate(-1deg);
    top: 120px; left: 45px;
}

.fish__stableFin--right {
    transform: scale(1,-1) rotate(-1deg);
    top: 120px; left: 105px;
}


.cat__head {
    position: relative;
    width: 230px;
    height: 200px;
    border: 6px solid transparent;
    -webkit-border-radius: 50% 50% 45% 45%;
    border-radius: 50% 50% 45% 45%;
    background: #ffcc80;
    z-index: 20;
}
.cat__head-dots {
    position: absolute;
    left: 101px;
    height: 48px;
    top: 1px;
    width: 14px;
    background: #ffb74d;
    -webkit-border-radius: 0 0 50% 50%;
    border-radius: 0 0 50% 50%;
}

 .cat__head-dots_first {
    position: absolute;
    content: '';
    top: 1px;
    width: 14px;    
    height: 35px;
    background: #ffb74d;
    left: -20px;
    border-radius: 50% 0 50% 50%;
}
.cat__head-dots_second {
    position: absolute;
    content: '';
    top: 1px;
    width: 14px;    
    height: 35px;
    background: #ffb74d;
    left: 20px;
    border-radius: 0 50% 50% 50%;
}

.cat__ear {
    position: relative;
}
.cat__ear--left, .cat__ear--right {
    position: absolute;
    top: -8px;
    width: 150px;
    height: 150px;
    border: 5px solid  transparent;
    border-radius: 90% 0 90% 0;
    background: #ffcc80;
    display: flex;
    justify-content: center;
    align-items: center;
}
.cat__ear--left {
    transform: scale(-1, 1) rotate(170deg);
    left: -14px;
}
.cat__ear--right {
    transform: rotate(170deg);
    left: 94px;
}
.cat__ear--left-inside, .cat__ear--right-inside {
    width: 108px;
    height: 108px;
    border-radius: 90% 0 90% 0;
    background: #e57373;
}
.cat__eye {
    position: absolute;
    top: 35px;
    left: -16px;
    display: flex;
}
.cat__eye--left, .cat__eye--right {
    width: 49px;
    height: 49px;
    background: #fff;
    border-radius: 50%;
    margin: 38px;
    z-index: 100;
}
.cat__eye span {
    position: absolute;
    top: 41px;
    width: 42px;
    height: 42px;
    background: #373737;
    border-radius: 50%;
    z-index: 200;
}
.cat__eye span::after {
    content: '';
    top: 8px;
    left: 8px;
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
}
.cat__eye span::before {
    content: '';
    top: 20px;
    left: 8px;
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}
.cat__eye span.pupil-left {
    left: 42px;
}
.cat__eye span.pupil-right {
    left: 166px;
}
.cat__nose {
    position: absolute;
    top: 115px;
    left: 95px;
    width: 0;
    height: 0;
    border-right: 14px solid rgba(255, 255, 255, 0);
    border-left: 14px solid rgba(255, 255, 255, 0);
    border-top: 14px solid #e57373;
    border-radius: 40%;
    z-index: 100;
}
.cat__mouth-contour {
    position: absolute;
    top: 97px;
    left: 19px;
    background: #fff3e0;
    width: 180px;
    height: 90px;
    -webkit-border-radius: 55% 55% 60% 60%;
    border-radius: 55% 55% 60% 60%;
}
.cat__mouth-left, .cat__mouth-right {
    position: absolute;
    top: 120px;
    width: 23px;
    height: 23px;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    border: 4px solid  #373737;
    border-right: 3px solid rgba(255, 255, 255, 0);
    border-top: 3px solid rgba(255, 255, 255, 0);
    transform: rotate(-45deg);
}
.cat__mouth-left {
    left: 88px;
}
.cat__mouth-right {
    left: 108px;
}
.cat__whiskers-left, .cat__whiskers-right {
    position: relative;
}
.cat__whiskers-left, .cat__whiskers-right, .cat__whiskers-left::after, .cat__whiskers-right::after, .cat__whiskers-left::before, .cat__whiskers-right::before {
    width: 32px;
    height: 5px;
    background: #373737;
}
.cat__whiskers-left::before, .cat__whiskers-right::before, .cat__whiskers-left::after, .cat__whiskers-right::after {
    content: '';
    position: absolute;
    left: 0;
}
.cat__whiskers-left {
    top: 112px;
    left: -18px;
}
.cat__whiskers-left::before {
    top: -16px;
    transform: rotate(15deg);
}
.cat__whiskers-left::after {
    top: 16px;
    transform: rotate(-15deg);
}
.cat__whiskers-right {
    top: 108px;
    left: 205px;
}
.cat__whiskers-right::before {
    top: -16px;
    transform: rotate(-15deg);
}
.cat__whiskers-right::after {
    top: 16px;
    transform: rotate(15deg);
}
.cat__body {
    position: relative;
}
.cat__chest {
    position: absolute;
    left: 54px;
    top: -48px;
    width: 120px;
    height: 120px;
    background: #ffcc80;
    border: 5px solid  transparent;
    border-radius: 50% 50% 40% 40%;
    z-index: 3;
}
.cat__chest_inner {
    content: '';
    position: absolute;
    top: 30px;
    left: 70px;
    width: 88px;
    height: 35px;
    border-radius: 50%;
    background: #fff3e0;
    z-index: 4;
}
.cat__paw-left, .cat__paw-right {
    position: absolute;
    top: 24px;
    width: 28px;
    height: 48px;
    background: #ffcc80;
    border: none;
    border-bottom: 5px solid transparent;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    z-index: 5;
}

.cat__paw-right_inner {
    content: '';
    position: absolute;
    top: 40px;
    left: 148px;
    width: 35px;
    height: 32px;
    background: #ffcc80;
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: 2;
}

.cat__paw-left_inner {
    content: '';
    position: absolute;
    top: 40px;
    left: 48px;
    width: 35px;
    height: 32px;
    background: #ffcc80;
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: 2;
}
.cat__paw-left {
    left: 78px;
    border-radius: 0 0 45% 35%;
}
.cat__paw-left::after {
    left: -32px;
}
.cat__paw-right {
    left: 122px;
    border-radius: 0 0 35% 45%;
}
.cat__paw-right::after {
    left: 16px;
}
.cat__tail {
    position: absolute;
    top: 20px;
    left: 130px;
    width: 90px;
    height: 23px;
    background: #ffcc80;
    border: 5px solid transparent;
    border-radius: 45%;
    z-index: 1;
    transform: rotate(-45deg);
}
/* .cursor {
    position: absolute;
    height: 23px;
    width: 23px;
    border: none;
    border-radius: 50%;
    background: #b40660;
    transform: translateX(-50%) translateY(-50%);
    z-index: 4000;
} */

catFactory.js

//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat/fish code.
function headColor(color,code) {
    $('.fish__body').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

//Side Fin color function
function sideFinColor(color,code) {
    $('.fish__fin--left, .fish__fin--right').css('background', '#' + color)  //This changes the color of the side fins
    $('#sideFinCode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaside').html(code) //This updates the side fin color part of the DNA that is displayed below the fish
}

//Tail Fin color function
function tailFinColor(color,code) {
    $('.fish__tailFin--top, .fish__tailFin--bottom').css('background', '#' + color)  //This changes the color of the tailfin
    $('#tailcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnatail').html(code) //This updates the tail fin color part of the DNA that is displayed below the fish
}

//Stabilizer Fin color function
function stableFinColor(color,code) {
        //This changes the color of the stabilizer fins
    $('.fish__stableFin--dorsal, .fish__stableFin--left, .fish__stableFin--right').css('background', '#' + color)  
    $('#stablizercode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnastablizer').html(code) //This updates the stabilizer fin color part of the DNA that is displayed below the fish
}

//Eye color function
function eyeColor(color,code) {
    $('.fish__eye--left, .fish__eye--right').css('background', '#' + color)  //This changes the color of the cat
    $('#eyecode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaeye').html(code) //This updates the eye color part of the DNA that is displayed below the cat
}

//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(num) {

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
    }
}

async function normalEyes() {
    await $('.cat__eye').find('span').css('border', 'none')
}

async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

catSettings.js

var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "sideColor" : 13,
    "tailColor" : 96,
    "stablizerColor" : 10,
    "eyeColor" : 10,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnaside').html(defaultDNA.sideColor);
  $('#dnatail').html(defaultDNA.tailColor);
  $('#dnastablizer').html(defaultDNA.stablizerColor);
  $('#dnaeye').html(defaultDNA.eyeColor);
    
//   $('#dnashape').html(defaultDNA.eyesShape)
//   $('#dnadecoration').html(defaultDNA.decorationPattern)
//   $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
//   $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
//   $('#dnaanimation').html(defaultDNA.animation)
//   $('#dnaspecial').html(defaultDNA.lastNum)

  renderFish(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnaside').html()
    dna += $('#dnatail').html()
    dna += $('#dnastablizer').html()
    dna += $('#dnaeye').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderFish(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)
}

// Changing fish colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})

// Changing fish colors, side fins
$('#sideFinColor').change(()=>{
  var colorVal = $('#sideFinColor').val()
  sideFinColor(colors[colorVal],colorVal)
})

// Changing fish colors, tail fins
$('#tailFinColor').change(()=>{
  var colorVal = $('#tailFinColor').val()
  tailFinColor(colors[colorVal],colorVal)
})

// Changing fish colors, stabilizer fins
$('#stableFinColor').change(()=>{
  var colorVal = $('#stableFinColor').val()
  stableFinColor(colors[colorVal],colorVal)
})

// Changing fish colors, eyes
$('#eyeColor').change(()=>{
  var colorVal = $('#eyeColor').val()
  eyeColor(colors[colorVal],colorVal)
})
1 Like

This is more of a javascript question than anything else:

I’m having an issue with my page updating in response to a form submit event, but each time the changes being made just quickly flash on the screen, and then the original default state reloads.

I ripped out all the sliders, and am instead hashing a text (presumably the name of their new Kritter) that the user will input. The output hash is set to have all sorts of fun uses with my program, but I can’t get the screen to stop re-loading after my changes are applied to my SVG.

Here is what my html form looks like currently:

<form id="form_user_input" onsubmit="manifestNewKritter(); return false;">
        <input id="text_user_input" type="text" placeholder='Enter name to meet your new Kritter!'>
        <button type='submit'>Yay!!</button>
      </form>

Ok, full story: The ‘return false;’ after the function call within the “onsubmit” property value DID work for a moment. When my DOM manipulations were taking place inside of the manifestNewKritter() function, the changes remained on the screen until the user input we re-updated.

HOWEVER, I’ve started building functions to apply changes to parts of the body, and the functions that are called from within manifestNewKritter() have DOM manipulations within them. So, now that I have functions INSIDE my manifestNewKritter() function, which was called by the ‘onsubmit’ property of my form, the browser reloads immediately after the changes take place. See below:

This works:

function manifestNewKritter(){
    let userInput = document.getElementById('text_user_input').value;
    let colorArray = hashToColorArray(sha256(userInput));
    document.getElementById('whole_figure_uniqueId').style.stroke = colorArray[3];
    document.getElementById('g_head').style.fill = colorArray[0];
}

However, this does’t work:

function manifestNewKritter(){
    let userInput = document.getElementById('text_user_input').value;
    let colorArray = hashToColorArray(sha256(userInput));
    changeHeadFill(colorArray[0]);
    changeStrokeColor(colorArray[1]);
    changeBellyFill(colorArray[3]);
}

Even when I get wacky and try adding ‘return false;’ to the ends of the functions being called:

const changeStrokeColor = (newStrokeColorNumber) => {
    let allStrokes = document.getElementById('whole_figure_uniqueId');
    allStrokes.style.stroke = newStrokeColorNumber;
    allStrokes.style.strokeWidth = '5px';
    return false;
}

There are many other things I could ask volumes about. But if someone could clue me in on why I can’t get this browser to stop reloading when I have my multi-function function set up, I’d appreciate it.

I’ll keep plugging away with my less-than-optimal method that’s working for me, but we all want that finesse, you know?

Thanks,
David

p.s. After some more digging, I think it may have to do with a concept called event bubbling/propagation.

hey @Melshman the issue here is on the form submition is reloading the page because that is the default behave.

What you have to do is to set just onsubmit=“return false;” and use the manifestNewKritter() directly on the submit button with onclick property

So you have to do like this

<form id="form_user_input" onsubmit="return false;">
        <input id="text_user_input" type="text" placeholder='Enter name to meet your new Kritter!'>
        <button onclick="manifestNewKritter();" type='submit'>Yay!!</button>
      </form>

Let me know if this solve your issue.

I have been struggling with getting my own code to work so I went with Filip’s code:

index.html:

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy kitties </title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <script src="assets/bootstrap/js/popper.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/mystyle.css">
  <link rel="stylesheet" href="assets/css/cats.css">
  <link rel="stylesheet" href="assets/css/colors.css">
  <link rel="stylesheet" href="assets/css/factory.css">
  <link rel="stylesheet" href="assets/css/frontend.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Kitties-Factory</h1>
        <p class="c-white">Create your custom Kitty</p>
    </div>
        <div class="row">
            <div class="col-lg-4 catBox m-2 light-b-shadow">
                <div class="cat">
                    <div class="cat__ear">
                        <div id="leftEar" class="cat__ear--left">
                            <div class="cat__ear--left-inside"></div>
                        </div>
                        <div id="rightEar" class="cat__ear--right">
                            <div class="cat__ear--right-inside"></div>
                        </div>
                    </div>

                    <div id="head" class="cat__head">
                        <div id="midDot" class="cat__head-dots">
                            <div id="leftDot" class="cat__head-dots_first"></div>
                            <div id="rightDot" class="cat__head-dots_second"></div>
                        </div>
                        <div class="cat__eye">
                            <div class="cat__eye--left">
                                <span class="pupil-left"></span>
                            </div>
                            <div class="cat__eye--right">
                                <span class="pupil-right"></span>
                            </div>
                        </div>
                        <div class="cat__nose"></div>

                        <div class="cat__mouth-contour"></div>
                        <div class="cat__mouth-left"></div>
                        <div class="cat__mouth-right"></div>

                        <div class="cat__whiskers-left"></div>
                        <div class="cat__whiskers-right"></div>
                    </div>

                    <div class="cat__body">

                        <div class="cat__chest"></div>

                        <div class="cat__chest_inner"></div>


                        <div class="cat__paw-left"></div>
                        <div class="cat__paw-left_inner"></div>


                        <div class="cat__paw-right"></div>
                        <div class="cat__paw-right_inner"></div>


                        <div id="tail" class="cat__tail"></div>
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnamouth"></span>
                         <span id="dnaeyes"></span>
                         <span id="dnaears"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
<div id="catColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Mouth and Tail</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earscolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyescode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyescolor">
                </div>
            </div>

            </div>

            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

catfactory.js:

function headColor(color,code) {
    $('.cat__head, .cat__chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function mouthColor(color,code) {
    $('.cat__mouth-contour, .cat__tail').css('background', '#' + color)
    $('#mouthcode').html('code: ' + code)
    $('#dnamouth').html(code)
}
function earsColor(color,code) {
    $('.cat__ear--left, .cat__ear--right').css('background', '#' + color)
    $('#earscode').html('code: ' + code)
    $('#dnaears').html(code)
}
function eyesColor(color,code) {
    $('.cat__eye--left, .cat__eye--right').css('background', '#' + color)
    $('#eyescode').html('code: ' + code)
    $('#dnaeyes').html(code)
}

cats.css:

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}
html {
    box-sizing: border-box;
    overflow-y: scroll;
}
body {
    background: #607d8b;
 
}

.cat__head {
    position: relative;
    width: 230px;
    height: 200px;
    border: 6px solid transparent;
    -webkit-border-radius: 50% 50% 45% 45%;
    border-radius: 50% 50% 45% 45%;
    background: #ffcc80;
    z-index: 20;
}
.cat__head-dots {
    position: absolute;
    left: 101px;
    height: 48px;
    top: 1px;
    width: 14px;
    background: #ffb74d;
    -webkit-border-radius: 0 0 50% 50%;
    border-radius: 0 0 50% 50%;
}

 .cat__head-dots_first {
    position: absolute;
    content: '';
    top: 1px;
    width: 14px;    
    height: 35px;
    background: #ffb74d;
    left: -20px;
    border-radius: 50% 0 50% 50%;
}
.cat__head-dots_second {
    position: absolute;
    content: '';
    top: 1px;
    width: 14px;    
    height: 35px;
    background: #ffb74d;
    left: 20px;
    border-radius: 0 50% 50% 50%;
}

.cat__ear {
    position: relative;
}
.cat__ear--left, .cat__ear--right {
    position: absolute;
    top: -8px;
    width: 150px;
    height: 150px;
    border: 5px solid  transparent;
    border-radius: 90% 0 90% 0;
    background: #ffcc80;
    display: flex;
    justify-content: center;
    align-items: center;
}
.cat__ear--left {
    transform: scale(-1, 1) rotate(170deg);
    left: -14px;
}
.cat__ear--right {
    transform: rotate(170deg);
    left: 94px;
}
.cat__ear--left-inside, .cat__ear--right-inside {
    width: 108px;
    height: 108px;
    border-radius: 90% 0 90% 0;
    background: #e57373;
}
.cat__eye {
    position: absolute;
    top: 35px;
    left: -16px;
    display: flex;
}
.cat__eye--left, .cat__eye--right {
    width: 49px;
    height: 49px;
    background: #fff;
    border-radius: 50%;
    margin: 38px;
    z-index: 100;
}
.cat__eye span {
    position: absolute;
    top: 41px;
    width: 42px;
    height: 42px;
    background: #373737;
    border-radius: 50%;
    z-index: 200;
}
.cat__eye span::after {
    content: '';
    top: 8px;
    left: 8px;
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
}
.cat__eye span::before {
    content: '';
    top: 20px;
    left: 8px;
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}
.cat__eye span.pupil-left {
    left: 42px;
}
.cat__eye span.pupil-right {
    left: 166px;
}
.cat__nose {
    position: absolute;
    top: 115px;
    left: 95px;
    width: 0;
    height: 0;
    border-right: 14px solid rgba(255, 255, 255, 0);
    border-left: 14px solid rgba(255, 255, 255, 0);
    border-top: 14px solid #e57373;
    border-radius: 40%;
    z-index: 100;
}
.cat__mouth-contour {
    position: absolute;
    top: 97px;
    left: 19px;
    background: #fff3e0;
    width: 180px;
    height: 90px;
    -webkit-border-radius: 55% 55% 60% 60%;
    border-radius: 55% 55% 60% 60%;
}
.cat__mouth-left, .cat__mouth-right {
    position: absolute;
    top: 120px;
    width: 23px;
    height: 23px;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    border: 4px solid  #373737;
    border-right: 3px solid rgba(255, 255, 255, 0);
    border-top: 3px solid rgba(255, 255, 255, 0);
    transform: rotate(-45deg);
}
.cat__mouth-left {
    left: 88px;
}
.cat__mouth-right {
    left: 108px;
}
.cat__whiskers-left, .cat__whiskers-right {
    position: relative;
}
.cat__whiskers-left, .cat__whiskers-right, .cat__whiskers-left::after, .cat__whiskers-right::after, .cat__whiskers-left::before, .cat__whiskers-right::before {
    width: 32px;
    height: 5px;
    background: #373737;
}
.cat__whiskers-left::before, .cat__whiskers-right::before, .cat__whiskers-left::after, .cat__whiskers-right::after {
    content: '';
    position: absolute;
    left: 0;
}
.cat__whiskers-left {
    top: 112px;
    left: -18px;
}
.cat__whiskers-left::before {
    top: -16px;
    transform: rotate(15deg);
}
.cat__whiskers-left::after {
    top: 16px;
    transform: rotate(-15deg);
}
.cat__whiskers-right {
    top: 108px;
    left: 205px;
}
.cat__whiskers-right::before {
    top: -16px;
    transform: rotate(-15deg);
}
.cat__whiskers-right::after {
    top: 16px;
    transform: rotate(15deg);
}
.cat__body {
    position: relative;
}
.cat__chest {
    position: absolute;
    left: 54px;
    top: -48px;
    width: 120px;
    height: 120px;
    background: #ffcc80;
    border: 5px solid  transparent;
    border-radius: 50% 50% 40% 40%;
    z-index: 3;
}
.cat__chest_inner {
    content: '';
    position: absolute;
    top: 30px;
    left: 70px;
    width: 88px;
    height: 35px;
    border-radius: 50%;
    background: #fff3e0;
    z-index: 4;
}
.cat__paw-left, .cat__paw-right {
    position: absolute;
    top: 24px;
    width: 28px;
    height: 48px;
    background: #ffcc80;
    border: none;
    border-bottom: 5px solid transparent;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    z-index: 5;
}

.cat__paw-right_inner {
    content: '';
    position: absolute;
    top: 40px;
    left: 148px;
    width: 35px;
    height: 32px;
    background: #ffcc80;
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: 2;
}

.cat__paw-left_inner {
    content: '';
    position: absolute;
    top: 40px;
    left: 48px;
    width: 35px;
    height: 32px;
    background: #ffcc80;
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: 2;
}
.cat__paw-left {
    left: 78px;
    border-radius: 0 0 45% 35%;
}
.cat__paw-left::after {
    left: -32px;
}
.cat__paw-right {
    left: 122px;
    border-radius: 0 0 35% 45%;
}
.cat__paw-right::after {
    left: 16px;
}
.cat__tail {
    position: absolute;
    top: 20px;
    left: 130px;
    width: 90px;
    height: 23px;
    background: #ffcc80;
    border: 5px solid transparent;
    border-radius: 45%;
    z-index: 1;
    transform: rotate(-45deg);
}
/* .cursor {
    position: absolute;
    height: 23px;
    width: 23px;
    border: none;
    border-radius: 50%;
    background: #b40660;
    transform: translateX(-50%) translateY(-50%);
    z-index: 4000;
} */

catSettings.js:

function renderCat(dna){
    headColor(colors[dna.headColor],dna.headColor)
    $('#bodycolor').val(dna.headColor)
    mouthColor(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthcolor').val(dna.mouthColor)
    eyesColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyescolor').val(dna.eyesColor)
    earsColor(colors[dna.earsColor],dna.earsColor)
    $('#earscolor').val(dna.earsColor)
}

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})
$('#mouthcolor').change(()=>{
  var colorVal = $('#mouthcolor').val()
  mouthColor(colors[colorVal],colorVal)
})
$('#eyescolor').change(()=>{
  var colorVal = $('#eyescolor').val()
  eyesColor(colors[colorVal],colorVal)
})
$('#earscolor').change(()=>{
  var colorVal = $('#earscolor').val()
  earsColor(colors[colorVal],colorVal)
})
1 Like

catFactory.js

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.cat__head, .body').css('background', '#' + color)  //This changes the color of the cat
    $('.tail_1').css('borderTopColor', '#' + color)
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


function innerBodyColor(color,code) {
    $('.inner_body, .left_inner_ear, .right_inner_ear').css('background', '#' + color)  //This changes the color of the cat
    $('#innerbody').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnainnerbody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function eyeColor(color,code) {
    $('.eye').css('background', '#' + color)  //This changes the color of the cat
    $('#eye').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaeyes').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function earsColor(color,code) {
    $('.ear, .paw').css('background', '#' + color)  //This changes the color of the cat
    $('#ears').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaears').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

catSettings.js

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor);
    innerBodyColor(colors[dna.innerColor],dna.innerColor)
    $('#innerbodycolor').val(dna.innerColor);
    eyeColor(colors[dna.eyescolor],dna.eyescolor)
    $('#eyeColor').val(dna.eyescolor);
    earsColor(colors[dna.earscolor],dna.earscolor)
    $('#earColor').val(dna.earscolor);
}






// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})

$('#innerbodycolor').change(()=>{
  var colorVal = $('#innerbodycolor').val()
 innerBodyColor(colors[colorVal],colorVal)
})

$('#eyeColor').change(()=>{
  var colorVal = $('#eyeColor').val()
 eyeColor(colors[colorVal],colorVal)
})

$('#earColor').change(()=>{
  var colorVal = $('#earColor').val()
 earsColor(colors[colorVal],colorVal)
})

2 Likes

I’ve had the same issue

hey @ntyrlych if you are usin visual code editior, my advise is to use live server plugin.
Otherwise you can install a python version in your pc and look for the command to run a http server on that python version. Make sure to be inside of the project folder where you wish to run it.

Code:

index.html
<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

<script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>

<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">

<script src="assets/bootstrap/js/popper.js"></script>

<script src="assets/bootstrap/js/bootstrap.min.js"></script>

<link rel="stylesheet" href="assets/css/mystyle.css">

<link rel="stylesheet" href="assets/css/cats.css">

<link rel="stylesheet" href="assets/css/colors.css">

<link rel="stylesheet" href="assets/css/factory.css">

<link rel="stylesheet" href="assets/css/frontend.css">
<div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">

    <div align="center">

        <h1 class="c-black">Kitties-Factory</h1>

        <p class="c-black">Create your custom Kitty</p>

    </div>

    <div class="row">

        <div class="col-lg-4 catBox m-2 light-b-shadow">

            <div id="cs-container">

                <div id="tail"></div>

                <div id="tail-mask"></div>

                <div id="tail-end"></div>

               

                <div id="body">

                    <div class="ear" id="ear-left">

                        <div class="ear-inner" id="ear-inner-left"></div>

                    </div>

                    <div class="ear" id="ear-right">

                        <div class="ear-inner" id="ear-inner-right"></div>

                    </div>

                   

                    <div id="mask"></div>

                   

                    <div id="patch">

                        <div class="fur"></div>

                        <div class="fur"></div>

                        <div class="fur"></div>

                    </div>

                   

                    <div id="eyes">

                        <div class="eye" id="eye-left">

                        <div class="shine" id="shine-left"></div>

                        </div>

                        <div class="eye" id="eye-right">

                        <div class="shine" id="shine-right"></div>

                        </div>

                    </div>

                   

                    <div id="whisk-left">

                        <div class="whisker" id="whisk-one"></div>

                        <div class="whisker"></div>

                        <div class="whisker" id="whisk-three"></div>

                    </div>

                   

                    <div id="nose"></div>

                   

                    <div id="whisk-right">

                        <div class="whisker" id="whisk-four"></div>

                        <div class="whisker"></div>

                        <div class="whisker" id="whisk-six"></div>

                    </div>

                   

                    <div id="smile">

                        <div id="smile-left-align">

                            <div id="smile-left"></div>

                            <div id="mask-left"></div>

                        </div>

                       

                        <div id="smile-right-align">

                            <div id="smile-right"></div>

                            <div id="mask-right"></div>

                        </div>

                    </div>

                   

                    <div id="tongue"></div>

                    <div id="tummy"></div>

                </div>

            </div>

            <br>

            <div class="dnaDiv" id="catDNA">

                <b>

                    DNA:

                    <!-- Colors -->

                    <span id="dnabody"></span>

                    <span id="dnamouth"></span>

                    <span id="dnaeyes"></span>

                    <span id="dnaears"></span>

                   

                    <!-- Cattributes -->

                    <span id="dnashape"></span>

                    <span id="dnadecoration"></span>

                    <span id="dnadecorationMid"></span>

                    <span id="dnadecorationSides"></span>

                    <span id="dnadanimation"></span>

                    <span id="dnaspecial"></span>

                </b>

            </div>

        </div>

        <div class="col-lg-7 cattributes m-2 light-b-shadow">

            <!-- Cat colors -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">

                </div>

            </div>

        </div>

    </div>

    <br/>

   

</div>

<footer align="left">

    <p>Angnima Sherpa - 2022</p>

</footer>
cats.css

#cs-container {

position: relative;

margin: auto;

height: 175px;

width: 170px;

}

#tail {

position: absolute;

margin-left: 66px;

margin-top: 70px;

height: 60px;

width: 80px;

border: 15px solid #63594d;

border-radius: 50px;

display: inline-block;

z-index: 0;

}

#tail-mask {

position: absolute;

margin-top: 60px;

margin-left: 100px;

height: 30px;

width: 75px;

background-color: #fff;

z-index: 0;

}

#tail-end {

position: absolute;

margin-top: 80px;

margin-left: 127px;

height: 17px;

width: 17px;

border-radius: 50%;

background-color: #63594d;

z-index: 1;

}

#body {

position: relative;

height: 130px;

width: 110px;

background-color: #63594d;

border-radius: 22px;

display: inline-block;

overflow: hide;

z-index: 1;

}

.ear {

position: absolute;

margin-top: -25px;

height: 45px;

width: 50px;

background-color: #63594d;

display: inline-block;

z-index: 2;

}

#ear-left {

clip-path: polygon(0 0, 0% 100%, 100% 60%);

}

#ear-right {

right:0;

clip-path: polygon(100% 0, 0% 60%, 100% 100%);

}

.ear-inner {

position: relative;

height: 30px;

width: 50px;

background-color: #999187;

z-index: 3;

}

#ear-inner-left {

margin-top: 8px;

margin-left: 5px;

clip-path: polygon(0 0, 100% 90%, 0 100%);

}

#ear-inner-right {

margin-top: 8px;

margin-left: -4px;

clip-path: polygon(100% 0%, 100% 100%, 0 90%);

}

#mask {

position: relative;

background-color: #63594d;

margin-top: -2px;

height: 50px;

width: 110px;

border-radius: 50%;

z-index: 4;

}

#patch {

position: relative;

margin-top: -50px;

z-index: 5;

}

.fur {

width: 5px;

background-color: #948a7c;

display: inline-block;

}

.fur:first-of-type {

margin-left: 40%;

height: 15px;

float: left;

}

.fur:nth-of-type(2) {

margin-left: 4px;

height: 5px;

float: left;

}

.fur:nth-of-type(3) {

margin-left: 4px;

height: 10px;

float: left;

}

#eyes {

position: relative;

margin-top: 30%;

z-index: 5;

}

.eye {

height: 18px;

width: 18px;

border-radius: 50%;

background-color: #554D44;

display: inline-block;

}

#eye-left {

margin-left: 27%;

}

#eye-right {

margin-left: 10%;

}

.shine {

height: 7px;

width: 7px;

border-radius: 50%;

background-color: #fff;

margin-top: 2px;

margin-left: 1px;

}

#whisk-left {

display: inline-block;

}

.whisker {

height: 3px;

width: 25px;

background-color: #8a7c6c;

margin-bottom: 6px;

}

#whisk-one {

transform: rotate(15deg);

}

#whisk-three {

transform: rotate(-15deg);

}

#nose {

position: absolute;

margin-left: 15%;

height: 17px;

width: 18px;

background-color: #554D44;

clip-path: ellipse(40% 22% at 50% 50%);

display: inline-block;

z-index: 6;

}

#whisk-right {

display: inline-block;

margin-left: 54px;

}

#whisk-four {

transform: rotate(-15deg);

}

#whisk-six {

transform: rotate(15deg);

}

#smile {

position: relative;

margin-left: 31%;

margin-top: -19%;

z-index: 5;

}

#smile-left-align {

display: inline-block;

position: absolute;

margin-left: 0;

}

#smile-left {

height: 10px;

width: 22px;

border-radius: 0 0 10px 10px;

background-color: #63594d;

border: 2px solid #554D44;

}

#mask-left {

margin-top: -58%;

height: 4px;

width: 22px;

background-color: #63594d;

}

#smile-right-align {

display: inline-block;

margin-left: 21px;

position: absolute;

}

#smile-right {

height: 10px;

width: 22px;

border-radius: 0 0 10px 10px;

background-color: #63594d;

border: 2px solid #554D44;

}

#mask-right {

margin-top: -50%;

height: 4px;

width: 24px;

background-color: #63594d;

}

#tongue {

position: relative;

margin-top: 5px;

margin-left: auto;

margin-right: auto;

height: 17px;

width: 15px;

border-radius: 25px;

background-color: #FC90A5;

z-index: 4;

}

#tummy {

margin-top: 9%;

margin-left: auto;

margin-right: auto;

height: 30px;

width: 60px;

border-radius: 50px 50px 0 0;

background-color: #918c86;

}

#credit {

position: absolute;

font-family: sans-serif;

font-size: 12px;

color: #B9B9B9;

margin-top: 70px;

left: 20px;

}

a,

a:visited {

text-decoration: none;

color: #FC90A5;

}

a:focus,

a:hover {

color: #DC7E91;

}

/* .cursor {

position: absolute;

height: 23px;

width: 23px;

border: none;

border-radius: 50%;

background: #b40660;

transform: translateX(-50%) translateY(-50%);

z-index: 4000;

} */

factory.css

.catBox {

background-color: #fff;

border-radius: 10px;

padding:50px;

padding-right: 0;

}

.cattributes {

padding: 25px;

background-color: #ededed;

border-radius: 10px;

}

.dnaDiv {

position: absolute;

left:20px;

bottom: 5px;

}

myStyle.css

@font-face {

font-family: “Poppins”;

src : url(“Poppins-Light.ttf”);

}

body {

font-family: Poppins;

font-weight: 500;

letter-spacing: 1px;

}

.navbar-light {

background: #ffffff;

}

.fit-content {

width: fit-content;

}

html {

overflow-x: hidden;

}

.abs-center {

display : flex;

align-items : center;

justify-content: center;

min-height : 80vh;

text-align : center;

}

p {

letter-spacing: 1px;

}

#message {

margin : 10px;

position: fixed;

bottom : 4rem;

z-index : 2000;

right : 10px;

}

.pointer {

cursor: pointer;

}

/* Alignment */

.no-wrap {

flex-wrap: nowrap;

}

.item-c {

align-items: center;

}

.t-inline {

white-space: nowrap;

}

td,

th {

vertical-align: text-top;

}

.va-0 {

vertical-align: unset;

}

.scale-2 {

transform: scale(1.6);

}

.table td,

.table th {

border: none;

}

.hidden {

transition: all .2s ease-in-out;

display : none;

}

.dflex {

display: flex;

}

.dblock {

display: block;

}

.show-block {

display: inline-block;

}

/* SIZING */

.minw-05 {

width: 5%;

}

.minw-10 {

width: 10%;

}

.minw-20 {

width: 20%;

}

.minw-15 {

width: 15%;

}

.minw-30 {

width: 30%;

}

.minw-40 {

width: 40%;

}

.minw-50 {

width: 50%;

}

.minw-60 {

width: 60%;

}

.minw-70 {

width: 70%;

}

.minw-80 {

width: 80%;

}

.minw-90 {

width: 80%;

}

.minw-100 {

width: 100%;

}

.vh-100 {

min-height: 100vh;

}

.vh-10 {

min-height: 10vh;

}

.vh-15 {

min-height: 15vh;

}

/* BOXES */

#results {

margin : 10px;

position: fixed;

bottom : 10px;

z-index : 2000;

right : 10px;

}

/* TOOLTIP */

.tooltip-btn {

padding-left : 5px;

padding-right : 5px;

padding-bottom : 0px;

padding-top : 0px;

color : #721c24;

background-color: #f8d7da;

border-color : #f5c6cb;

}

.tooltip-inner {

background: #cce5ff;

color : #004085;

padding : 10px;

}

.tooltip.show {

opacity: 1;

}

.arrow::before,

.bs-tooltip-right .arrow::before,

.bs-tooltip-left .arrow::before,

.bs-tooltip-top .arrow::before {

border-top-color: #cce5ff;

}

/* opacity */

.opacity-on {

opacity: 0;

}

.opacity-9 {

opacity: 0.9;

}

.opacity-8 {

opacity: 0.8;

}

.opacity-7 {

opacity: 0.7;

}

.opacity-6 {

opacity: 0.6;

}

/* TEXT ALIGMENT */

.underline {

text-decoration: underline;

}

.ta-l {

text-align: left;

}

.ta-c {

text-align: center;

}

.ta-r {

text-align: right;

}

.tsp-1 {

letter-spacing: 1px;

}

.tsp-2 {

letter-spacing: 2px;

}

/* SHADOW*/

.light-shadow {

text-shadow: 1px 2px 3px #8e8e8e;

}

.light-b-shadow {

box-shadow: 0px 5px 7px 0px #444444;

}

/BORDER/

.none-border {

border: none;

}

.radius-50 {

border-radius: 50%;

}

.radius-10 {

border-radius: 10px;

}

/* TRANSITIONS */

.trans-fast {

transition: all .75s ease;

}

.trans-normal {

transition: all 1s ease;

}

.trans-slow {

transition: all 1.5s ease;

}

/* Text size */

h4 {

font-size: 1rem;

}

.fs-50 {

font-size: 50%;

}

/* Margin and padding */

.m-0 {

margin: 0px;

}

.m-1 {

margin: 5px;

}

.mt-0 {

margin-top: 0px;

}

.mt-05 {

margin-top: 5px;

}

.mt-1 {

margin-top: 10px;

}

.mt-2 {

margin-top: 30px;

}

.mt-3 {

margin-top: 50px;

}

.mt-4 {

margin-top: 80px;

}

.mb-0 {

margin-bottom: 5px;

}

.mb-1 {

margin-bottom: 10px;

}

.mb-2 {

margin-bottom: 30px;

}

.mb-3 {

margin-bottom: 50px;

}

.mb-4 {

margin-bottom: 80px;

}

.ml-1 {

margin-left: 10px;

}

.ml-2 {

margin-left: 20px;

}

.ml-3 {

margin-left: 30px;

}

.ml-4 {

margin-left: 45px;

}

.mr-1 {

margin-right: 10px;

}

.mr-2 {

margin-right: 20px;

}

.mr-3 {

margin-right: 30px;

}

.mr-4 {

margin-right: 45px;

}

.p-1 {

padding: 1px;

}

.p-2 {

padding: 10px;

}

.p-3 {

padding: 15px;

}

.p-4 {

padding: 20px;

}

.p-5 {

padding: 25px;

}

.pt-0 {

padding-top: 0px;

}

.pt-05 {

padding-top: 5px;

}

.pt-1 {

padding-top: 10px;

}

.pt-2 {

padding-top: 20px;

}

.pt-3 {

padding-top: 30px;

}

.pt-4 {

padding-top: 40px;

}

.pt-5 {

padding-bottom: 50px;

}

.pb-1 {

padding-bottom: 10px;

}

.pb-2 {

padding-bottom: 20px;

}

.pb-3 {

padding-bottom: 30px;

}

.pb-4 {

padding-bottom: 40px;

}

.pb-5 {

padding-bottom: 50px;

}

/* EFFECTS ANIMATIONS */

.reflex-box {

-webkit-box-reflect: below 5px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0%, transparent), to(rgba(250, 250, 250, 0.2)))

}

.grow {

transition: all .2s ease-in-out;

}

.grow:hover {

transform: scale(1.1);

}

.fadeoutleft {

opacity : 0;

overflow : hidden;

transform: translateX(-90%);

}

.myfadeOut {

opacity : 0;

transition: all 0.5s ease-in-out;

}

.fadeinright {

opacity : 0;

overflow : hidden;

transform: translateX(90%);

}

Here is my code:

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy Penguin </title>
  <script type="text/javascript" src="/Penguin NFT Marketplace/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="/Penguin NFT Marketplace/bootstrap/css/bootstrap.min.css">
  <script src="/Penguin NFT Marketplace/bootstrap/js/popper.js"></script>
  <script src="/Penguin NFT Marketplace/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/mystyle.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/penguin.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/colors.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/factory.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/frontend.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Penguin-Factory</h1>
        <p class="c-white">Create your custom Penguin</p>
    </div>
        <div class="row">
            <div class="col-lg-4 penguinBox m-2 light-b-shadow">
                <div class="penguin">
                    <div class="penguin-bottom">
                    <div class="right-hand"></div> 
                    <div class="left-hand"></div>
                    <div class="right-feet"></div>
                    <div class="left-feet"></div>
                    </div>

                    <div id="head" class="penguin-top">
                      <div class="belly"></div>
                        
                        <div class="left-cheek"></div>
                        <div class="right-cheek"></div>
                        <div class="beak-bottom"></div>
                        <div class="beak-top"></div>
                        <div class="blush-left"></div>
                        <div class="blush-right"></div>
                        <div class="left-eye">
                          <div class="sparkle"></div>
                        </div>
                        <div class="right-eye">
                          <div class="sparkle"></div>
                        </div>
                        

                    </div>



                    
                </div>
                <br>
                <div class="dnaDiv" id="penguinDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnabelly"></span>
                         <span id="dnaface"></span>
                         <span id="dnahand"></span>
                        
                         <!-- attributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 attributes m-2 light-b-shadow">

<!-- Penguin colors -->
<div id="penguinColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Belly</b><span class="badge badge-dark ml-2" id="bellycode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bellycolor">
                </div>  
                <div class="form-group">
                  <label for="formControlRange"><b>Face</b><span class="badge badge-dark ml-2" id="facecode"></span></label>
                  <input type="range" min="10" max="98" class="form-control-range" id="facecolor">
                </div>
                <div class="form-group">
                  <label for="formControlRange"><b>Hands</b><span class="badge badge-dark ml-2" id="handcode"></span></label>
                  <input type="range" min="10" max="98" class="form-control-range" id="handcolor">
                </div>
            </div>

            </div>

            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="/Penguin NFT Marketplace/js/colors.js"></script>
  <script src="/Penguin NFT Marketplace/js/penguinFactory.js"></script>
  <script src="/Penguin NFT Marketplace/js/penguinSettings.js"></script>

</html>

//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat code.
function headColor(color, code) {
    $('.penguin-bottom, .penguin-top').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function bellyColor(color, code) {
    $('.belly').css('background', '#' + color)
    $('#bellycode').html('code: '+code)
    $('#dnabelly').html(code)
}
function faceColor(color, code) {
    $('.left-cheek, .right-cheek').css('background', '#' + color)
    $('#facecode').html('code: '+code)
    $('#dnaface').html(code)
}
function handColor(color, code) {
    $('.left-hand, .right-hand').css('background', '#' + color)
    $('#handcode').html('code: '+code)
    $('#dnahand').html(code)
}

//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(num) {

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
    }
}

async function normalEyes() {
    await $('.cat__eye').find('span').css('border', 'none')
}

async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}


var colors = Object.values(allColors())

var defaultDNA = {
    "headColor" : 10,
    "bellyColor" : 13,
    "faceColor" : 13,
    "handColor" : 10,
    
    //attributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnabelly').html(defaultDNA.bellyColor);
  $('#dnaface').html(defaultDNA.faceColor);
  $('#dnahand').html(defaultDNA.handColor);
    
//   $('#dnashape').html(defaultDNA.eyesShape)
//   $('#dnadecoration').html(defaultDNA.decorationPattern)
//   $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
//   $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
//   $('#dnaanimation').html(defaultDNA.animation)
//   $('#dnaspecial').html(defaultDNA.lastNum)

  renderPenguin(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnabelly').html()
    dna += $('#dnaface').html()
    dna += $('#dnahand').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderPenguin(dna){
    headColor(colors[dna.headColor],dna.headColor)
    $('#bodycolor').val(dna.headColor)
    bellyColor(colors[dna.bellyColor],dna.bellyColor)
    $('#bellycolor').val(dna.bellyColor)
    faceColor(colors[dna.faceColor],dna.faceColor)
    $('#facecolor').val(dna.faceColor)
    handColor(colors[dna.handColor],dna.handColor)
    $('#handcolor').val(dna.handColor)
}

// Changing penguin colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})

$('#bellycolor').change(()=>{
    var colorVal = $('#bellycolor').val()
    bellyColor(colors[colorVal],colorVal)
})

$('#facecolor').change(()=>{
    var colorVal = $('#facecolor').val()
    faceColor(colors[colorVal],colorVal)
})

$('#handcolor').change(()=>{
    var colorVal = $('#handcolor').val()
    handColor(colors[colorVal],colorVal)
})
1 Like

the code

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Academy kitties </title>

  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>

  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">

  <script src="assets/bootstrap/js/popper.js"></script>

  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/mystyle.css">

  <link rel="stylesheet" href="assets/css/cats.css">

  <link rel="stylesheet" href="assets/css/colors.css">

  <link rel="stylesheet" href="assets/css/factory.css">

  <link rel="stylesheet" href="assets/css/frontend.css">

</head>

  <body>

    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">

        <div align="center">

        <h1 class="c-white">Kitties-Factory</h1>

        <p class="c-white">Create your custom Kitty</p>

    </div>

        <div class="row">

            <div class="col-lg-4 catBox m-2 light-b-shadow">

                <div class="cat">

                    <div class="ears">

                        <div class="ear left_ear">

                            <div class="ear left_ear_inner"></div>

                            </div>

                            <div class="ear right_ear"><div class="ear right_ear_inner"></div>

                            </div>

                    </div>

                   

           <div id="head">

           

           <div class = "nose"></div>

           <div class = "mouth"></div>

           <div class = "facehairs">

               <div class = "facehair1left"></div>

               <div class = "facehair2left"></div>

               <div class = "facehair3left"></div>

               <div class = "facehair1right"></div>

               <div class = "facehair2right"></div>

               <div class = "facehair3right"></div>

       

           </div>

       

            <div class = "eyes">

                <div class="eye">

                   <div class="pupils"></div>

                </div>

               

                <div class="eye">

                   <div class="pupils"></div>

                </div>

                </div>

               </div>

               <div id="body"></div>

                                  

           </div>

                <br>

                <div class="dnaDiv" id="catDNA">

                    <b>

                        DNA:

                        <!-- Colors -->

                         <span id="dnabody"></span>

                         <span id="dnamouth"></span>

                         <span id="dnaeyes"></span>

                         <span id="dnaears"></span>

                       

                         <!-- Cattributes -->

                         <span id="dnashape"></span>

                         <span id="dnadecoration"></span>

                         <span id="dnadecorationMid"></span>

                         <span id="dnadecorationSides"></span>

                         <span id="dnadanimation"></span>

                         <span id="dnaspecial"></span>

                    </b>

                </div>

            </div>

            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->

<div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">

                    <label for="formControlRange"><b>Mouth</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">

                    <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">

                    <label for="formControlRange"><b>Ears</b><span class="badge badge-dark ml-2" id="earcode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="earcolor">

                </div>

            </div>

            </div>

            </div>

            <br>

        </div>

    </div>

    <footer align="left">

        <p>Ivan on Tech Academy Bootcamp July 2020</p>

    </footer>

  </body>

  <script src="assets/js/colors.js"></script>

  <script src="assets/js/catSettings.js"></script>

  <script src="assets/js/catFactory.js"></script>

</html>
var colors = Object.values(allColors())

var defaultDNA = {

    "headcolor" : 10,

    "mouthColor" : 13,

    "eyesColor" : 96,

    "earsColor" : 10,

    //Cattributes

    "eyesShape" : 1,

    "decorationPattern" : 1,

    "decorationMidcolor" : 13,

    "decorationSidescolor" : 13,

    "animation" :  1,

    "lastNum" :  1

    }

// when page load

$( document ).ready(function() {

  $('#dnabody').html(defaultDNA.headColor);

  $('#dnamouth').html(defaultDNA.mouthColor);

  $('#dnaeyes').html(defaultDNA.eyesColor);

  $('#dnaears').html(defaultDNA.earsColor);

   

//   $('#dnashape').html(defaultDNA.eyesShape)

//   $('#dnadecoration').html(defaultDNA.decorationPattern)

//   $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)

//   $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)

//   $('#dnaanimation').html(defaultDNA.animation)

//   $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)

});

function getDna(){

    var dna = ''

    dna += $('#dnabody').html()

    dna += $('#dnamouth').html()

    dna += $('#dnaeyes').html()

    dna += $('#dnaears').html()

    dna += $('#dnashape').html()

    dna += $('#dnadecoration').html()

    dna += $('#dnadecorationMid').html()

    dna += $('#dnadecorationSides').html()

    dna += $('#dnaanimation').html()

    dna += $('#dnaspecial').html()

    return parseInt(dna)

}

function renderCat(dna){

    headColor(colors[dna.headcolor],dna.headcolor)

    $('#bodycolor').val(dna.headcolor)

    mouthColor(colors[dna.mouthColor],dna.mouthColor)

    $('#mouthcolor').val(dna.mouthColor)

    eyesColor(colors[dna.eyesColor],dna.eyesColor)

    $('#eyecolor').val(dna.eyesColor)

    earsColor(colors[dna.earsColor],dna.earsColor)

    $('#earcolor').val(dna.earsColor)

}

// Changing cat colors

$('#bodycolor').change(()=>{

    var colorVal = $('#bodycolor').val()

    headColor(colors[colorVal],colorVal)

})

$('#mouthcolor').change(()=>{

  var colorVal = $('#mouthcolor').val()

  mouthColor(colors[colorVal],colorVal)

})

$('#eyecolor').change(()=>{

  var colorVal = $('#eyecolor').val()

  eyesColor(colors[colorVal],colorVal)

})

$('#earcolor').change(()=>{

  var colorVal = $('#earcolor').val()

  earsColor(colors[colorVal],colorVal)

})
//Random color

function getColor() {

    var randomColor = Math.floor(Math.random() * 16777215).toString(16);

    return randomColor

}

function genColors(){

    var colors = []

    for(var i = 10; i < 99; i ++){

      var color = getColor()

      colors[i] = color

    }

    return colors

}

//This function code needs to modified so that it works with Your cat code.

function headColor(color,code) {

    $('#head, #body, .ear').css('background', '#' + color)  //This changes the color of the cat

    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider

    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat

}

function mouthColor(color,code) {

    $('.mouth').css('background', '#' + color)  //This changes the color of the cat

    $('#mouthcode').html('code: '+code) //This updates text of the badge next to the slider

    $('#dnamouth').html(code) //This updates the body color part of the DNA that is displayed below the cat

}

function eyesColor(color,code) {

    $('.eye').css('background', '#' + color)  //This changes the color of the cat

    $('#eyecode').html('code: '+code) //This updates text of the badge next to the slider

    $('#dnaeyes').html(code) //This updates the body color part of the DNA that is displayed below the cat

}

function earsColor(color,code) {

    $('.left_ear_inner, .right_ear_inner').css('background', '#' + color)  //This changes the color of the cat

    $('#earcode').html('code: '+code) //This updates text of the badge next to the slider

    $('#dnaears').html(code) //This updates the body color part of the DNA that is displayed below the cat

}

//###################################################

//Functions below will be used later on in the project

//###################################################

function eyeVariation(num) {

    $('#dnashape').html(num)

    switch (num) {

        case 1:

            normalEyes()

            $('#eyeName').html('Basic')

            break

    }

}

function decorationVariation(num) {

    $('#dnadecoration').html(num)

    switch (num) {

        case 1:

            $('#decorationName').html('Basic')

            normaldecoration()

            break

    }

}

async function normalEyes() {

    await $('.cat__eye').find('span').css('border', 'none')

}

async function normaldecoration() {

    //Remove all style from other decorations

    //In this way we can also use normalDecoration() to reset the decoration style

    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })

    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })

    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })

}

It took me a day and a half to realize that my browser was randomly, not updating my code and using cached versions. I say random because, it would update my code for a while, then randomly, start using a cached version. Once I realized this, I checked the ‘disable cache’ box in the inspect panel (Network>Disable Cache) and, the whole process became easier. :crazy_face:

Code:

Index.html
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy kitties </title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <script src="assets/bootstrap/js/popper.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/mystyle.css">
  <link rel="stylesheet" href="assets/css/cats1.css">
  <link rel="stylesheet" href="assets/css/colors.css">
  <link rel="stylesheet" href="assets/css/factory2.css">
  <link rel="stylesheet" href="assets/css/frontend.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Kitties-Factory</h1>
        <p class="c-white">Create your custom Kitty</p>
    </div>
        <div class="row">
            <div class="col-lg-4 catBox m-2 light-b-shadow">
                <div class="cat">
                    <div class="ears">
                        <div class="ear left_ear">
                            <div class="inner_ear left_inner_ear"></div>
                        </div>
                        <div class="ear right_ear">
                            <div class="inner_ear right_inner_ear"></div>
                        </div>
                    </div>
                    <div class="head">
                        <div class="eyes">
                            <div class="eye left_eye">
                                <div class="irus"></div>
                             
                                <div class="reflection_1"></div>
                                <div class="reflection_2"></div>
                            </div>
                            <div class="eye right_eye">
                                <div class="irus"></div>
                       
                                <div class="reflection_1"></div>
                                <div class="reflection_2"></div>
                            </div>
                        </div>
                        <div class="chest"></div>
                        <div class="stomach"></div>
                        <div class="snout"></div>
                        <div class="nose"></div>
                        <div class="mouth-left"></div>
                        <div class="mouth-right"></div>
                        <div class="forehead_markings_middle"></div>
                        <div class="forehead_markings_left"></div>
                        <div class="forehead_markings_right"></div>
                        <div class="whisker whisker_mid_left"></div>
                        <div class="whisker whisker_top_left"></div>
                        <div class="whisker whisker_bottom_left"></div>
                        <div class="whisker whisker_mid_right"></div>
                        <div class="whisker whisker_top_right"></div>
                        <div class="whisker whisker_bottom_right"></div>
                        
                        <div class="paw_front_left">
                            <div class="paw_stripe"></div>
                            <div class="paw_stripe bottom_stripe"></div>
                        </div>
                        <div class="paw_front_right">
                            <div class="paw_stripe"></div>
                            <div class="paw_stripe bottom_stripe"></div>
                        </div>
                        <div class="paw_back_right"></div>
                        <div class="paw_back_left"></div>
                        <div class="tail">
                            <div class="tail_markings top_marking"></div>
                            <div class="tail_markings bottom_marking"></div>
                        </div>                
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnapaw"></span>
                         <span id="dnamarking"></span>
                         <span id="dnasnout"></span>
                         <span id="dnaeye"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
<div id="catColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears, Paws and Tail</b><span class="badge badge-dark ml-2" id="pawcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="pawcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Markings</b><span class="badge badge-dark ml-2" id="markingcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="markingcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Snout and Stomach</b><span class="badge badge-dark ml-2" id="snoutcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="snoutcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
                </div>

            </div>

            </div>

            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="assets/js/colors2.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

cats1.css
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}
html {
    box-sizing: border-box;
    overflow-y: scroll;
}
body {
    background: #607d8b;
 
}

.head {
    background: #bd8d25;
    top: 10px;
    width: 225px;
    height: 175px;
    border: 6px solid transparent;
    border-radius: 50%;
    position: relative;
}
.eyes{
    top: 30px;
    display: flex;
}
.eye{
    background-color: white;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    position: relative;
    top: 70px;

}
.left_eye{
    left: 41px;
}
.right_eye{
    left:98px;
}


.irus{
    background-color: #5c976b;
    width: 33px;
    height: 33px;
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 3px;
}
.pupils{
    background-color: #18331d;
    width: 15px;
    height: 30px;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 12px;
}
.reflection_1{
    background-color: white;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 9px;
}
.reflection_2{
    background-color: white;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    position: absolute;
    top: 15px;
    left: 8px;
}
.ears{
    position: relative;
}
.ear{
    background: #928466;
    width: 100px;
    height: 100px;
    position: absolute;
    top: -13px;
}
.left_ear{
    border-radius: 10px 134px 10px 11px;
    left: 11px;
}
.right_ear{
    border-radius: 88px 6px 10px 10px;
    left: 118px;
}
.inner_ear{
    background: #b5a583;
    width: 53px;
    height: 98px;
    position: absolute;
}
.left_inner_ear{
    border-radius: 6px 462px 186px 281px;
    top: 13px;
    left: 7px;
    transform: rotate(4deg);
}
.right_inner_ear{
    border-radius: 288px 6px 43px 1px;
    left: 39px;
    top: 12px;
    transform: rotate(356deg);
}

.snout{
    background: #fff3e0;
    width: 132px;
    height: 64px;
    margin-top: 61px;
    margin-left: 40px;
    border-radius: 55% 55% 60% 60%;
}
.nose {
    position: absolute;
    top: 105px;
    left: 94px;
    width: 0;
    height: 0;
    border-right: 12px solid rgba(255, 255, 255, 0);
    border-left: 12px solid rgba(255, 255, 255, 0);
    border-top: 12px solid #e57373;
    border-radius: 40%;
    z-index: 100;
}
.mouth-left, .mouth-right {
    position: absolute;
    top: 106px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid #373737;
    border-right: 3px solid rgba(255, 255, 255, 0);
    border-top: 3px solid rgba(255, 255, 255, 0);
    transform: rotate(-45deg);
}
.mouth-left {
    left: 88px;
}
.mouth-right {
    left: 105px;
}
.forehead_markings_middle{
    position: absolute;
    left: 99px;
    height: 45px;
    top: -5px;
    width: 13px;
    background: #d7c3a3;
    border-radius: 10% 10% 50% 50%;
}
.forehead_markings_left{
    position: absolute;
    top: -3px;
    width: 12px;
    height: 32px;
    background: rgb(214 194 162);
    left: 78px;
    border-radius: 50% 20% 50% 50%;
    transform: rotate(343deg);
}
.forehead_markings_right{
    position: absolute;
    top: -3px;
    width: 12px;
    height: 32px;
    background: rgb(214 194 162);
    left: 122px;
    border-radius: 20% 50% 50% 50%;
    transform: rotate(24deg);
}
.whisker_mid_left{
    position: absolute;
    width: 32px;
    height: 4px;
    background: #373737;
    top: 111px;
    left: -10px;
}
.whisker_top_left{
    position: absolute;
    width: 32px;
    height: 4px;
    background: #373737;
    top: 98px;
    left: -10px;
    transform: rotate(12deg);
}
.whisker_bottom_left{
    position: absolute;
    width: 32px;
    height: 4px;
    background: #373737;
    top: 123px;
    left: -9px;
    transform: rotate(347deg);
}
.whisker_mid_right{
    position: absolute;
    width: 32px;
    height: 4px;
    background: #373737;
    top: 111px;
    left: 192px;
}
.whisker_top_right{
    position: absolute;
    width: 32px;
    height: 4px;
    background: #373737;
    top: 98px;
    left: 192px;
    transform: rotate(347deg);
}
.whisker_bottom_right{
    position: absolute;
    width: 32px;
    height: 4px;
    background: #373737;
    top: 123px;
    left: 192px;
    transform: rotate(12deg);
}

.chest {
    position: absolute;
    left: 46px;
    top: 135px;
    width: 127px;
    height: 120px;
    background: rgb(146, 132, 102);
    border: 5px solid transparent;
    border-radius: 50% 50% 40% 40%;
    z-index: -1;
}
.stomach{
    position: absolute;
    top: 214px;
    left: 63px;
    width: 96px;
    height: 35px;
    border-radius: 50%;
    background: #fff3e0;
    z-index: 4;
}

.paw_front_left{
    position: absolute;
    top: 206px;
    width: 29px;
    height: 54px;
    background: rgb(146 132 102);
    z-index: 5;
    left: 73px;
    border-radius: 0 0 45% 35%;
}
.paw_front_right{
    position: absolute;
    top: 206px;
    width: 29px;
    height: 54px;
    background: rgb(146 132 102);
    z-index: 5;
    left: 119px;
    border-radius: 0 0 35% 45%;
}
.paw_stripe{
    background: rgb(214 194 162);
    width: 29px;
    height: 8px;
    position: absolute;
    top: 6px;
}
.bottom_stripe{
    top: 20px;
}
.paw_back_right {
    position: absolute;
    top: 225px;
    left: 143px;
    width: 39px;
    height: 32px;
    background: rgb(146 132 102);
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: -2;
}
.paw_back_left {
    position: absolute;
    top: 225px;
    left: 39px;
    width: 37px;
    height: 32px;
    background: rgb(146 132 102);
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: -2;
}
.tail {
    position: absolute;
    top: 184px;
    left: 137px;
    width: 90px;
    height: 26px;
    background: rgb(146 132 102);
    border: 5px solid transparent;
    border-radius: 45%;
    z-index: -5;
    transform: rotate(-45deg);
}
.tail_markings{
    background: rgb(214 194 162);
    position: relative;
}
.top_marking{
    width: 7px;
    height: 26px;
    top: -5px;
    left: 49px;
}
.bottom_marking{
    width: 7px;
    height: 27px;
    top: -32px;
    left: 36px;
}
/* .cursor {
    position: absolute;
    height: 23px;
    width: 23px;
    border: none;
    border-radius: 50%;
    background: #b40660;
    transform: translateX(-50%) translateY(-50%);
    z-index: 4000;
} */

catFactory.js

//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.head, .chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html(code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function pawColor(color,code) {
    $('.paw_front_left, .paw_front_right, .paw_back_right, .paw_back_left, .tail, .ear').css('background', '#' + color)  //This changes the color of the cat
    $('#pawcode').html(code) //This updates text of the badge next to the slider
    $('#dnapaw').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function markingColor(color,code) {
    $('.forehead_markings_middle, .forehead_markings_left, .forehead_markings_right, .paw_stripe, .bottom_stripe, .tail_markings').css('background', '#' + color)  //This changes the color of the cat
    $('#markingcode').html(code) //This updates text of the badge next to the slider
    $('#dnamarking').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function snoutColor(color,code) {
    $('.snout').css('background', '#' + color)  //This changes the color of the cat
    $('#snoutcode').html(code) //This updates text of the badge next to the slider
    $('#dnasnout').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function eyeColor(color,code) {
    $('.irus').css('background', '#' + color)  //This changes the color of the cat
    $('#eyecode').html(code) //This updates text of the badge next to the slider
    $('#dnaeye').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(num) {

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
    }
}

async function normalEyes() {
    await $('.cat__eye').find('span').css('border', 'none')
}

async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

catSettings.js
type or paste code here
var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "pawcolor" : 10,
    "markingcolor" : 20,
    "snoutcolor" : 30,
    "eyecolor" : 40,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {

  
  $('#dnabody').html(defaultDNA.headcolor);
  $('#dnapaw').html(defaultDNA.pawcolor);
  $('#dnamarking').html(defaultDNA.markingcolor);
  $('#dnasnout').html(defaultDNA.snoutcolor);
  $('#dnaeye').html(defaultDNA.eyecolor);
    
//   $('#dnashape').html(defaultDNA.eyesShape)
//   $('#dnadecoration').html(defaultDNA.decorationPattern)
//   $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
//   $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
//   $('#dnaanimation').html(defaultDNA.animation)
//   $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnapaw').html()
    dna += $('#dnamarking').html()
    dna += $('#dnasnout').html()
    dna += $('#dnaeye').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)

    pawColor(colors[dna.pawcolor],dna.pawcolor)
    $('#pawcolor').val(dna.pawcolor)

    markingColor(colors[dna.markingcolor],dna.markingcolor)
    $('#markingcolor').val(dna.markingcolor)

    snoutColor(colors[dna.snoutcolor],dna.snoutcolor)
    $('#snoutcolor').val(dna.snoutcolor)

    eyeColor(colors[dna.eyecolor],dna.eyecolor)
    $('#eyecolor').val(dna.eyecolor)
}



// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})
$('#pawcolor').change(()=>{
  var colorVal = $('#pawcolor').val()
  pawColor(colors[colorVal],colorVal)
})
$('#markingcolor').change(()=>{
  var colorVal = $('#markingcolor').val()
  markingColor(colors[colorVal],colorVal)
})
$('#snoutcolor').change(()=>{
  var colorVal = $('#snoutcolor').val()
  snoutColor(colors[colorVal],colorVal)
})
$('#eyecolor').change(()=>{
  var colorVal = $('#eyecolor').val()
  eyeColor(colors[colorVal],colorVal)
})
colors2.js

var colors = {
    00: "ae494f",
    01: "9a3031",
    02: "8cd42e",
    03: "a0417a",
    04: "91c656",
    05: "299f7a",
    06: "c65d1e",
    07: "b2bbd6",
    08: "2d4024",
    9: "4b5715",
    10: "928466",
    11: "3f1174",
    12: "b22a90",
    13: "fff3e0",
    14: "4c858b",
    15: "18bebe",
    16: "b5044b",
    17: "d6b1d4",
    18: "fecb40",
    19: "748882",
    20: "d7c3a3",
    21: "482916",
    22: "267bf0",
    23: "5af7e2",
    24: "adeacc",
    25: "cf2b03",
    26: "b3c459",
    27: "353f9",
    28: "5d4993",
    29: "ba8d15",
    30: "fff3e0",
    31: "ff17fe",
    32: "d6e81d",
    33: "daf2db",
    34: "19b510",
    35: "18e26f",
    36: "b7c36a",
    37: "8cb175",
    38: "bdce32",
    39: "f2e0ba",
    40: "5c976b",
    41: "64bf50",
    42: "f1a771",
    43: "4982a9",
    44: "f66c41",
    45: "2fe802",
    46: "bda142",
    47: "8342ff",
    48: "2b4ab4",
    49: "ad4595",
    50: "d6c39b",
    51: "b76d01",
    52: "8e8207",
    53: "285b9f",
    54: "c4422a",
    55: "f1eaa7",
    56: "e3a0cc",
    57: "65c116",
    58: "656ccf",
    59: "7c25f4",
    60: "8b7440",
    61: "688a7d",
    62: "1fe786",
    63: "425716",
    64: "4ac043",
    65: "547836",
    66: "24a216",
    67: "fd9bba",
    68: "24894d",
    69: "c54b03",
    70: "695937",
    71: "cff1dd",
    72: "8805fb",
    73: "fe99d2",
    74: "c52f14",
    75: "e31c54",
    76: "d010eb",
    77: "b83436",
    78: "c294b6",
    79: "564a6c",
    80: "531bcf",
    81: "c04b8c",
    82: "3cd2ef",
    83: "82286c",
    84: "aa2639",
    85: "86be6c",
    86: "e62102",
    87: "5471fc",
    88: "624c1d",
    89: "703c75",
    90: "9a8e8f",
    91: "8b9307",
    92: "fcbc82",
    93: "ea5978",
    94: "b8e370",
    95: "43474b",
    96: "262d2b",
    97: "ddd67e",
    98: "344867"
}

function allColors(){

    return colors;
}
1 Like

yeah that can be so annoying sometimes when using vanillajs. lol

1 Like

index.html Cat colors section:

            <!-- Cat colors -->
            <div id="catColors">
                <div class="form-group">
                    <label for="formControlRangeBody"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>

                <div class="form-group">
                    <label for="formControlRangeMouth"><b>Mouth</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">
                </div>

                <div class="form-group">
                    <label for="formControlRangeEyes"><b>Eye</b><span class="badge badge-dark ml-2" id="eyescode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyescolor">
                </div>

                <div class="form-group">
                    <label for="formControlRangeEars"><b>Ear</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earscolor">
                </div>
            </div>

catFactory.js update:

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.cat__head, .cat__chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function mouthColor(color,code) {
    $('.cat__mouth-contour').css('background', '#' + color)
    $('#mouthcode').html('code: '+code)
    $('#dnamouth').html(code)
}

function eyesColor(color,code) {
    $('.cat__eye--left, .cat__eye--right').css('background', '#' + color)
    $('#eyescode').html('code: '+code)
    $('#dnaeyes').html(code)
}

function earsColor(color,code) {
    $('.cat__ear--left, .cat__ear--right').css('background', '#' + color)
    $('#earscode').html('code: '+code)
    $('#dnaears').html(code)
}

catSettings.js update:


var colors = Object.values(allColors())

var defaultDNA = {
    "headColor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 96,
    "earsColor" : 10,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnamouth').html(defaultDNA.mouthColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
  $('#dnaears').html(defaultDNA.earsColor);
    
//   $('#dnashape').html(defaultDNA.eyesShape)
//   $('#dnadecoration').html(defaultDNA.decorationPattern)
//   $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
//   $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
//   $('#dnaanimation').html(defaultDNA.animation)
//   $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnamouth').html()
    dna += $('#dnaeyes').html()
    dna += $('#dnaears').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderCat(dna){
    headColor(colors[dna.headColor],dna.headColor)
    $('#bodycolor').val(dna.headColor)

    mouthColor(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthcolor').val(dna.mouthColor)

    eyesColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyescolor').val(dna.eyesColor)

    earsColor(colors[dna.earsColor],dna.earsColor)
    $('#earscolor').val(dna.earsColor)
  }

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})

$('#mouthcolor').change(()=>{
  var colorVal = $('#mouthcolor').val()
  mouthColor(colors[colorVal],colorVal)
})

$('#eyescolor').change(()=>{
  var colorVal = $('#eyescolor').val()
  eyesColor(colors[colorVal],colorVal)
})

$('#earscolor').change(()=>{
  var colorVal = $('#earscolor').val()
  earsColor(colors[colorVal],colorVal)
})
1 Like

Hello everyone,
I continue to write my code using react and change some parts.
GeneratorNft

import { Container,Box,Text } from '@chakra-ui/react'
import React,{useState} from 'react'
import styled from 'styled-components'


export default function GeneratorNFT({color1,color2,color3,power,lifepoint,stamina,speed}){
        const Body = styled.div`
            background-color: rgb(${color1}, ${color2}, ${color3});
            height: 200px;
            width: 180px;
            border-radius: 50%
        `
        const Eyes = styled.div`
                position: relative;
                top: 17px;
                display: flex;
                left: 14px;
        `
        const Eye = styled.div`
            background-color: white;
            border-radius: 50%;
            height:40px;
            width: 40px;
            margin: 18px;
            
            
        `
        const Pupils = styled.div`
                background-color: black;
                border-radius: 50%;
                height: 20px;
                width: 20px;
                top: 100px;
                left: 52px;
        `

        const Ears = styled.div`
              position:relative;
        `
        const Ears_left = styled.div`
                background-color: rgb(${color1}, ${color2}, ${color3});
                border-radius: 90% 0px 90% 0px;
                height: 100px;
                width: 100px;
                position: absolute;
                transform: scale(1.1) rotate(171deg) translate(-3px,15px) skew(7deg,10deg);


        `
        const Ears_right = styled.div`
                 background-color: rgb(${color1}, ${color2}, ${color3});
                border-radius: 90% 0px 90% 0px;
                height: 100px;
                width: 100px;
                position: absolute;
                transform: scale(1.1) rotate(100deg) translate(-7px,87px) skew(9deg,10deg);
        `

        const Nose = styled.div`
            position:relative;
            background-color: black;
            border-radius: 50%;
            height: 32px;
            width: 49px;
            margin-left: 65px;
     
        `


    return (
        <Box maxW='sm' borderWidth='1px' borderRadius='lg' overflow='hidden' maxWidth={1000}>
    <Container className='Cat' centerContent marginTop={100} width={400} maxWidth={1000}>
        <Ears >
            <Ears_left></Ears_left>
            <Ears_right></Ears_right>
        </Ears>
        <Body>
            <Eyes>
                <Eye>
                    <Pupils></Pupils>
                </Eye>
                <Eye>
                    <Pupils></Pupils>
                </Eye>
            </Eyes>
            <Nose></Nose>
        </Body>
    </Container>
        <Text fontSize='4xl'> Monster Cat's</Text>
        <Text fontSize='2xl'>Stat:</Text>
        <Text fontSize='xl'>Power = {power}</Text>
        <Text fontSize='xl'>Lifepoint = {lifepoint}</Text>
        <Text fontSize='xl'>Stamina = {stamina}</Text>
        <Text fontSize='xl'>Speed = {speed}</Text>
    </Box>
  )
}

InputGenerator

import React,{useState,useEffect} from 'react'
import { Container,Slider,SliderTrack,SliderFilledTrack,SliderThumb,Text,Button} from '@chakra-ui/react'
import GeneratorNFT from './GeneratorNFT'

export default function InputGenerator() {
    const [colorId1,setColorId1] = useState(30)
    const [colorId2,setColorId2] = useState(30)
    const [colorId3,setColorId3] = useState(30)

    const [power,setPower] = useState(0)
    const [lifepoint,setLifepoint] = useState(0)
    const [stamina,setStamina] = useState(0)
    const [speed,setSpeed] = useState(0)

  useEffect(() => {
      setStat();
  },[])

  function randomize(){
    setColorId1(Math.floor(Math.random() * (250 - 10))+10);
    setColorId2(Math.floor(Math.random() * (250 - 10))+10);
    setColorId3(Math.floor(Math.random() * (250 - 10))+10 );
  }
  function setStat(){
    setPower(Math.floor(Math.random() * (15 - 1))+1);
    setLifepoint(Math.floor(Math.random() * (15 - 1))+5);
    setStamina(Math.floor(Math.random() * (15 - 1))+1);
    setSpeed(Math.floor(Math.random() * (15 - 1))+1);

  }
    return (
    <Container marginleft={100} width={1000}  maxWidth={1000} display="flex-box" alignItems="center">
        <Text fontSize='4xl' marginEnd={15}> Create bad card's CAts</Text>
        <Container display="flex" alignItems="left" justifyContent="space-between" border={1}  maxWidth={1000}>
          <GeneratorNFT color1={colorId1} 
                        color2={colorId2}
                        color3={colorId3}
                        power = {power}
                        lifepoint = {lifepoint}
                        stamina = {stamina}
                        speed = {speed}

                        ></GeneratorNFT>
          <Container padding='4'   maxW='md'  alignItems="left" width={400} maxWidth={1000}>
            <Text fontSize='2xl' alignItems="left">Color id : {colorId1}</Text>
            <Slider aria-label='slider-ex-10' defaultValue={colorId1}
                min={10}
                max={250}
                colorScheme='teal'
                onChange={(v) => setColorId1(v)}>
              <SliderTrack>
                      <SliderFilledTrack />
                    </SliderTrack>
                    <SliderThumb />
                </Slider>
                <Text fontSize='2xl'>Color id : {colorId2}</Text>
            <Slider aria-label='slider-ex-10' defaultValue={colorId2}
                min={10}
                max={250}
                colorScheme='teal'
                onChange={(v) => setColorId2(v)}>
              <SliderTrack>
                      <SliderFilledTrack />
                    </SliderTrack>
                    <SliderThumb />
                </Slider>
                <Text fontSize='2xl'>Color id : {colorId3}</Text>
            <Slider aria-label='slider-ex-10' defaultValue={colorId3}
                min={10}
                max={250}
                colorScheme='teal'
                onChange={(v) => setColorId3(v)}>
              <SliderTrack>
                      <SliderFilledTrack />
                    </SliderTrack>
                    <SliderThumb />
                </Slider>
                <Button colorScheme='teal' variant='outline' onClick={()=>randomize()}> Random Color</Button>
         
               <Container marginTop={15}>
                    <Text fontSize='2xl'>Set Stat</Text>
                    <Button colorScheme='teal' variant='outline' onClick={()=>setStat()} marginTop={5}> Random stat</Button>      
               </Container>
         </Container>
           
        </Container>
        
    </Container>
  )
}

1 Like

man brilliant that your doing this in react. it shows you already have great knowledge. a few things tho. you should seperate your styled-components from your javascript code. its horrible to mix the two and becomes a disater to read. so eitehr put your styled components below your imports at the top of the file below all your javascript function components. or even better in each component folder create a styles.js file and put your styled-components here so for example
styles.js

import styled from "styled-components"

        export const Body = styled.div`
            background-color: rgb(${color1}, ${color2}, ${color3});
            height: 200px;
            width: 180px;
            border-radius: 50%
        `
        export const Eyes = styled.div`
                position: relative;
                top: 17px;
                display: flex;
                left: 14px;
        `
        export const Eye = styled.div`
            background-color: white;
            border-radius: 50%;
            height:40px;
            width: 40px;
            margin: 18px;
            
            
        `
        export const Pupils = styled.div`
                background-color: black;
                border-radius: 50%;
                height: 20px;
                width: 20px;
                top: 100px;
                left: 52px;
        `

        export const Ears = styled.div`
              position:relative;
        `
        exprort const Ears_left = styled.div`
                background-color: rgb(${color1}, ${color2}, ${color3});
                border-radius: 90% 0px 90% 0px;
                height: 100px;
                width: 100px;
                position: absolute;
                transform: scale(1.1) rotate(171deg) translate(-3px,15px) skew(7deg,10deg);


        `
        export const Ears_right = styled.div`
                 background-color: rgb(${color1}, ${color2}, ${color3});
                border-radius: 90% 0px 90% 0px;
                height: 100px;
                width: 100px;
                position: absolute;
                transform: scale(1.1) rotate(100deg) translate(-7px,87px) skew(9deg,10deg);
        `

        export const Nose = styled.div`
            position:relative;
            background-color: black;
            border-radius: 50%;
            height: 32px;
            width: 49px;
            margin-left: 65px;
     
        `

and in your functional component file whatever you have it called import all o fyour styled components like such

import { Container,Box,Text } from '@chakra-ui/react'
import React,{useState} from 'react'
import { Body, Eyes, Eye .....} from "./styles.js"
....
....

the next thing is do do with the optimisation of states. you have duplicate states for the same thing namely

    const [colorId1,setColorId1] = useState(30)
    const [colorId2,setColorId2] = useState(30)
    const [colorId3,setColorId3] = useState(30)

to reduce code duplication you should make one state here that is an object like

const [coloursId, setColoursId] = useState({colour1: 30, colour2: 30, colour3: 30})

then to update any colour just

setColours({colours1: newColour, colours2: newColour2, colour3: newColour3})

its much cleaner this way. however your killing it amaxing job so far

1 Like

thank you for this response.

yes i know, my code is messy , because i divide code in plus file, i lost function and use more time for finish my project.

i think that with some plus work on this , i can upgrade my skill.

with regard to “setColor” i I hadn’t thought a this solution.

1 Like

yeah doing states lik ethis when you have multiple states rhat are in the same category its handy. the same is through for thing slike login forums. instead of having setName, setEmail etc uou can bundle them in one object state. also great work excited to see the finished product

Hello All,

I could not use my original cat, instead I used Phillip’s cat and focused on learning. The dream is to become an awesome coder, when I do I will try with the original cat.

HTML File

<!-- Cat colors -->
<div id="catColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Mouth Belly and Tail</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes Color</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears and Paws</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                </div>
            </div>

            </div>

        </div>

        <br>



    </div>
    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

Cat Factory File


//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.cat__head, .cat__chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function mouthAndBelly(color,code) {
    $('.cat__mouth-contour, .cat__tail, .cat_chest_inner').css('background', '#' + color)  
    $('#muthcode').html('code: '+code) 
    $('#dnamouth').html(code) 
}
function eyeColor(color,code) {
    $('.cat__eye') .find('span').css('background', '#' + color)  
    $('#eyecode').html('code: '+code) 
    $('#dnaeyes').html(code) 
}
function earsAndPaw(color,code) {
    $('.cat__ear--left, .cat_ear--right, .cat_paw-left, .cat_paw-right, .cat_paw-left_inner, .cat_paw-right') .find('span').css('background', '#' + color)  
    $('#earscode').html('code: '+code) 
    $('#dnaears').html(code) 
}

CatSettings File

function renderCat(dna){
    headColor(colors[dna.headColor],dna.headColor)
    $('#bodycolor').val(dna.headColor)
    mouthAndBelly(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthcolor').val(dna.mouthColor)
    eyeColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyecolor').val(dna.eyesColor)
    earsAndPaw(colors[dna.earsColor],dna.earsColor)
    $('#earcolor').val(dna.earsColor)

}
// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
  
})

$('#mouthcolor').change(()=>{
  var colorVal = $('#mouthcolor').val()
  mouthAndBelly(colors[colorVal],colorVal)

})

$('#eyecolor').change(()=>{
  var colorVal = $('#eyecolor').val()
  eyeColor(colors[colorVal],colorVal)

})

$('#earcolor').change(()=>{
  var colorVal = $('#earcolor').val()
  earsAndPaw(colors[colorVal],colorVal)

})
1 Like