cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              svg(style='display:none')
  symbol#svg-scale(viewbox='0 0 512 512')
    g
      path(style='fill:#93603E;', d='M30.347,320.941c23.863,45.004,88.338,44.973,112.19,0H30.347z')
      path(style='fill:#93603E;', d='M481.668,320.941c-23.871,45.013-88.349,44.963-112.189,0H481.668z')
    g
      path(style='fill:#845135;', d='M57.678,320.941H30.347c13.22,24.93,41.504,38.504,69.76,32.3\
      C81.691,349.197,66.275,337.156,57.678,320.941z')
      path(style='fill:#845135;', d='M396.81,320.941h-27.331c13.219,24.93,41.505,38.505,69.761,32.3\
      C420.824,349.197,405.408,337.156,396.81,320.941z')
    path(style='fill:#93603E;', d='M255.347,27.407c-10.464,0-18.944,8.483-18.944,18.946c0,17.368,0,5.844,0,23.035v9.332v49.112v9.332\
    v168.68v9.332v70.103v9.332h37.89v-9.332v-70.103v-9.332c0-11.227,0-248.191,0-259.493C274.292,35.89,265.812,27.407,255.347,27.407\
    z')
    path(style='fill:#845135;', d='M256.969,315.178v-9.332c0-29.742,0-228.401,0-259.493c0-6.669,3.454-12.522,8.661-15.899\
    c-12.57-8.148-29.228,0.898-29.228,15.899c0,13.593,0-3.112,0,11.377v11.658v9.332v49.112v9.332v168.68v9.332v70.103v9.332h20.567\
    v-9.332V315.178z')
    g
      path(style='fill:#93603E;', d='M425.293,125.046C327.722,98.33,285.378,86.56,285.378,86.56c4.256,12.728,0.913,27.15-9.464,36.694\
      c11.666,3.195,1.167,0.293,60.784,16.821c16.26,4.452,60.881,16.67,78.588,21.518c10.092,2.764,20.514-3.18,23.278-13.27\
      C441.326,138.231,435.385,127.809,425.293,125.046z')
      path(style='fill:#93603E;', d='M223.516,97.61c0-3.863,0.638-7.577,1.8-11.05c0,0-45.83,12.726-139.916,38.485\
      c-10.09,2.764-16.034,13.184-13.27,23.277c2.763,10.091,13.184,16.034,23.275,13.27c94.591-25.9,66.365-18.129,130.357-35.87\
      l9.019-2.469C227.859,116.888,223.516,107.758,223.516,97.61z')
    g
      path(style='fill:#845135;', d='M415.286,141.812c-93.956-25.728-64.141-17.513-129.202-35.55\
      c-1.696,6.631-5.287,12.501-10.17,16.993c11.666,3.195,1.167,0.293,60.784,16.821c16.26,4.452,60.881,16.67,78.588,21.518\
      c16.557,4.534,30.061-13.59,21.146-28.155C432.14,140.442,423.606,144.09,415.286,141.812z')
      path(style='fill:#845135;', d='M224.61,106.262c-62.505,17.329-35.383,9.861-129.204,35.55c-8.32,2.278-16.854-1.371-21.144-8.374\
      c-8.927,14.588,4.608,32.685,21.144,28.156c94.591-25.9,66.365-18.129,130.357-35.87l9.019-2.469\
      C229.896,118.763,226.306,112.891,224.61,106.262z')
    g
      path(style='fill:#FFA92C;', d='M165.378,308.948c0,7.067-5.731,12.8-12.799,12.8H20.307c-7.068,0-12.799-5.732-12.799-12.8v-6.997\
      c0-7.069,5.732-12.8,12.799-12.8h132.272c7.068,0,12.799,5.73,12.799,12.8V308.948z')
      path(style='fill:#FFA92C;', d='M346.636,308.948c0,7.067,5.732,12.8,12.801,12.8h132.271c7.067,0,12.8-5.732,12.8-12.8v-6.997\
      c0-7.069-5.732-12.8-12.8-12.8H359.437c-7.068,0-12.801,5.73-12.801,12.8V308.948z')
    g
      path(style='fill:#EF8F11;', d='M152.579,305.449H20.307c-5.426,0-10.052-3.384-11.915-8.149c-1.086,2.782-0.884,4.04-0.884,11.648\
      c0,7.067,5.732,12.8,12.799,12.8h132.272c7.068,0,12.799-5.732,12.799-12.8c0-7.58,0.206-8.857-0.885-11.648\
      C162.631,302.066,158.005,305.449,152.579,305.449z')
      path(style='fill:#EF8F11;', d='M491.708,305.449H359.437c-5.426,0-10.053-3.384-11.916-8.149\
      c-1.093,2.797-0.885,4.091-0.885,11.648c0,7.067,5.732,12.8,12.801,12.8h132.271c7.067,0,12.8-5.732,12.8-12.8v-6.997\
      c0-1.642-0.321-3.208-0.885-4.651C501.761,302.066,497.134,305.449,491.708,305.449z')
    path(style='fill:#E8E8E8;', d='M284.186,385.281h-57.681c-6.355,0-11.505,5.152-11.505,11.505v9.587v19.126h80.692v-19.126v-9.587\
    C295.694,390.432,290.541,385.281,284.186,385.281z')
    path(style='fill:#D1D3D3;', d='M234.909,396.786c0-6.354,5.15-11.505,11.505-11.505h-19.909c-6.355,0-11.505,5.152-11.505,11.505\
    v9.587v19.126h19.909v-19.126V396.786z')
    circle(style='fill:#FFA92C;', cx='255.352', cy='98.612', r='34.83')
    path(style='fill:#EF8F11;', d='M239.462,98.61c0-15.952,10.727-29.39,25.358-33.518c-22.322-6.294-44.304,10.52-44.304,33.518\
    c0,23.003,21.985,39.812,44.304,33.519C250.188,128.001,239.462,114.564,239.462,98.61z')
    path(style='fill:#93603E;', d='M321.484,417.878h-132.27c-7.069,0-12.8,5.732-12.8,12.802v6.996v17.337h157.872v-17.337v-6.996\
    C334.284,423.61,328.553,417.878,321.484,417.878z')
    path(style='fill:#845135;', d='M196.322,430.679c0-7.069,5.73-12.802,12.8-12.802h-19.909c-7.069,0-12.8,5.732-12.8,12.802v6.996\
    v17.337h19.909v-17.337V430.679z')
    path(style='fill:#E8E8E8;', d='M341.393,452.012h-39.82h-92.451h-39.819c-7.069,0-12.8,5.732-12.8,12.802v6.997\
    c0,7.067,5.73,12.8,12.8,12.8h39.819h92.451h39.82c7.068,0,12.8-5.732,12.8-12.8v-6.997\
    C354.192,457.744,348.462,452.012,341.393,452.012z')
    path(style='fill:#D1D3D3;', d='M341.393,468.312h-39.82h-92.451h-39.819c-5.427,0-10.053-3.383-11.915-8.149\
    c-0.564,1.443-0.885,3.01-0.885,4.652v6.997c0,7.067,5.73,12.8,12.8,12.8h39.819h92.451h39.82c7.068,0,12.8-5.732,12.8-12.8v-6.997\
    c0-1.642-0.321-3.209-0.885-4.652C351.446,464.929,346.819,468.312,341.393,468.312z')
    path(d='M491.7,281.642h-0.724L440.629,160.17c12.327-14.841,5.024-37.332-13.364-42.367L293.96,81.306\
    c-2.771-6.162-6.967-11.544-12.176-15.724V46.343c0-14.582-11.863-26.445-26.445-26.445c-14.581,0-26.443,11.863-26.443,26.445\
    v19.239c-5.209,4.18-9.407,9.562-12.178,15.725L83.411,117.804c-19.041,5.214-25.901,28.806-12.466,43.391L21.021,281.642\
    C8.127,281.642,0,291.474,0,301.942v6.997c0,11.193,9.106,20.299,20.3,20.299h4.986c27.449,46.624,94.89,46.544,122.297,0h4.989\
    c11.193,0,20.3-9.105,20.3-20.299v-6.997c0-10.435-8.089-20.3-21.023-20.3L104.3,166.921l124.595-34.113v244.963h-2.397\
    c-10.478,0-19.005,8.525-19.005,19.005c0,10.34-0.119,11.033,0.434,13.593h-18.723c-11.193,0-20.3,9.106-20.3,20.302v13.852\
    c-11.013,0.21-19.911,9.218-19.911,20.282v6.997c0,11.193,9.105,20.3,20.3,20.3h68.546c4.143,0,7.499-3.357,7.499-7.499\
    c0-4.143-3.357-7.499-7.499-7.499h-68.546c-2.923,0-5.301-2.378-5.301-5.301v-6.997c0-2.924,2.378-5.303,5.301-5.303h7.11\
    c6.287,0,154.837,0,164.98,0c2.923,0,5.301,2.379,5.301,5.303v6.997c0,2.923-2.378,5.301-5.301,5.301h-68.548\
    c-4.142,0-7.499,3.357-7.499,7.499c0,4.143,3.358,7.499,7.499,7.499h68.548c11.193,0,20.3-9.105,20.3-20.3v-6.997\
    c0-11.062-8.896-20.071-19.909-20.282v-13.852c0-11.194-9.106-20.302-20.301-20.302h-18.724c0.546-2.527,0.433-3.122,0.433-13.593\
    c0-10.478-8.526-19.005-19.007-19.005h-2.395V274.046c0-4.143-3.357-7.499-7.499-7.499c-4.143,0-7.499,3.357-7.499,7.499v103.727\
    h-22.891V139.361c7.221,2.062,15.528,2.091,22.891-0.001v99.688c0,4.143,3.357,7.499,7.499,7.499c4.143,0,7.499-3.357,7.499-7.499\
    v-106.24l125.779,34.439L360.15,281.641c-12.897,0-21.021,9.834-21.021,20.3v6.997c0,11.193,9.107,20.299,20.301,20.299h4.988\
    c27.443,46.614,94.883,46.556,122.297,0h4.987c11.193,0,20.3-9.105,20.3-20.299v-6.997C512,290.749,502.895,281.642,491.7,281.642z\
    M78.935,181.09v100.553H37.258L78.935,181.09z M44.604,330.432h83.661C106.032,355.479,66.814,355.458,44.604,330.432z\
    M152.571,296.641c2.923,0,5.301,2.378,5.301,5.301v6.997c0,2.923-2.378,5.301-5.301,5.301H20.3c-2.923,0-5.301-2.378-5.301-5.301\
    v-6.997c0-2.923,2.378-5.301,5.301-5.301c3.524,0,123.477,0,126.538,0C146.837,296.641,152.537,296.641,152.571,296.641z\
    M135.61,281.642H93.934V181.089L135.61,281.642z M91.432,154.691c-2.798,0.266-5.145-0.459-7.465-1.923\
    c-8.13-5.542-5.916-17.946,3.406-20.5L213.015,97.87c-0.121,7.536,1.775,15.25,5.823,22.141\
    C87.419,155.994,93.085,154.536,91.432,154.691z M243.894,46.343c0-6.313,5.135-11.446,11.444-11.446\
    c6.313,0,11.446,5.135,11.446,11.446v11.5c-7.39-2.079-15.554-2.078-22.891-0.001V46.343H243.894z M321.476,425.368\
    c2.924,0,5.302,2.379,5.302,5.303v13.833H183.905V430.67c0-2.924,2.378-5.303,5.301-5.303\
    C195.742,425.368,316.433,425.368,321.476,425.368z M284.178,392.771c2.21,0,4.008,1.797,4.008,4.006v9.587\
    c0,2.209-1.798,4.006-4.008,4.006h-57.68c-2.209,0-4.006-1.797-4.006-4.006v-9.587c0-2.209,1.797-4.006,4.006-4.006\
    C233.38,392.771,277.434,392.771,284.178,392.771z M257.11,125.871c-10.596,0.686-20.442-4.798-25.563-13.844\
    c-13.631-24.172,14.082-51.829,38.369-36.53C292.357,89.711,283.288,124.237,257.11,125.871z M433.065,181.09l41.676,100.553\
    h-41.676V181.09z M291.842,120.013c4.042-6.957,5.945-14.524,5.822-22.141l125.64,34.398c6.088,1.667,9.685,7.976,8.02,14.063\
    c-1.552,5.663-7.235,9.123-11.939,8.186c-0.658-0.133-1.317-0.175-1.962-0.134C416.64,154.188,293.157,120.372,291.842,120.013z\
    M418.066,181.084v100.559h-41.678L418.066,181.084z M383.735,330.432h83.661C445.164,355.48,405.946,355.458,383.735,330.432z\
    M497.001,308.939c0,2.923-2.378,5.301-5.301,5.301H359.429c-2.924,0-5.302-2.378-5.302-5.301v-6.997\
    c0-2.923,2.378-5.301,5.302-5.301c3.524,0,123.477,0,126.538,0c0.007-0.001,0.015-0.001,0.02,0h5.715\
    c2.923,0,5.301,2.378,5.301,5.301L497.001,308.939L497.001,308.939z')


  symbol#svg-pencil(viewbox='0 0 53.255 53.255')
    path(style='fill:#D75A4A;', d='M39.598,2.343c3.124-3.124,8.19-3.124,11.314,0s3.124,8.19,0,11.314L39.598,2.343z')
    polygon(style='fill:#ED8A19;', points='42.426,17.899 16.512,43.814 15.982,48.587 44.548,20.02 44.548,20.02 ')
    polygon(style='fill:#ED8A19;', points='10.325,42.93 15.098,42.4 41.012,16.485 36.77,12.243 10.855,38.157 ')
    polygon(style='fill:#ED8A19;', points='35.356,10.829 33.234,8.707 33.234,8.707 4.668,37.273 9.441,36.743 ')
    polygon(style='fill:#C7CAC7;', points='48.79,15.778 48.79,15.778 50.912,13.657 39.598,2.343 37.476,4.465 37.477,4.465 ')
    polygon(style='fill:#C7CAC7;', points='36.062,5.879 36.062,5.879 34.648,7.293 34.648,7.293 45.962,18.606 45.962,18.606 \
    47.376,17.192 47.376,17.192 ')
    path(style='fill:#FBCE9D;', d='M14.424,44.488l-5.122,0.569c-0.036,0.004-0.073,0.006-0.109,0.006c0,0-0.001,0-0.001,0H9.192H9.192\
    c-0.001,0-0.001,0-0.001,0c-0.036,0-0.073-0.002-0.109-0.006c-0.039-0.004-0.071-0.026-0.108-0.035\
    c-0.072-0.017-0.141-0.035-0.207-0.067c-0.05-0.024-0.093-0.053-0.138-0.084c-0.057-0.04-0.109-0.083-0.157-0.134\
    c-0.038-0.04-0.069-0.081-0.1-0.127c-0.038-0.057-0.069-0.116-0.095-0.181c-0.022-0.054-0.038-0.107-0.05-0.165\
    c-0.007-0.032-0.024-0.059-0.028-0.092c-0.004-0.038,0.01-0.073,0.01-0.11c0-0.038-0.014-0.072-0.01-0.11l0.569-5.122l-5.122,0.569\
    c-0.037,0.004-0.075,0.006-0.111,0.006c-0.079,0-0.152-0.024-0.227-0.042L0.442,51.399l2.106-2.106c0.391-0.391,1.023-0.391,1.414,0\
    s0.391,1.023,0,1.414l-2.106,2.106l12.03-2.864c-0.026-0.109-0.043-0.222-0.03-0.339L14.424,44.488z')
    path(style='fill:#38454F;', d='M3.962,49.293c-0.391-0.391-1.023-0.391-1.414,0l-2.106,2.106L0,53.255l1.856-0.442l2.106-2.106\
    C4.352,50.316,4.352,49.684,3.962,49.293z')
    polygon(style='fill:#F2ECBF;', points='48.79,15.778 37.477,4.465 37.476,4.465 36.062,5.879 36.062,5.879 47.376,17.192 \
    47.376,17.192 48.79,15.778 ')
    path(style='fill:#EBBA16;', d='M41.012,16.485L15.098,42.4l-4.773,0.53l0.53-4.773L36.77,12.243l-1.414-1.414L9.441,36.743\
    l-4.773,0.53l-1.133,1.133l-0.228,0.957c0.075,0.018,0.147,0.042,0.227,0.042c0.036,0,0.074-0.002,0.111-0.006l5.122-0.569\
    l-0.569,5.122c-0.004,0.038,0.01,0.073,0.01,0.11c0,0.038-0.014,0.072-0.01,0.11c0.004,0.033,0.021,0.06,0.028,0.092\
    c0.012,0.057,0.029,0.112,0.05,0.165c0.026,0.064,0.057,0.124,0.095,0.181c0.03,0.045,0.063,0.088,0.1,0.127\
    c0.047,0.05,0.1,0.094,0.157,0.134c0.044,0.031,0.089,0.061,0.138,0.084c0.065,0.031,0.135,0.05,0.207,0.067\
    c0.038,0.009,0.069,0.03,0.108,0.035c0.036,0.004,0.072,0.006,0.109,0.006h0.001h0h0.001h0.001c0,0,0.001,0,0.001,0h0\
    c0.035,0,0.072-0.002,0.109-0.006l5.122-0.569l-0.569,5.122c-0.013,0.118,0.004,0.23,0.03,0.339l0.963-0.229l1.133-1.132l0.53-4.773\
    l25.914-25.915L41.012,16.485z')
    polygon(style='fill:#F2ECBF;', points='45.962,18.606 34.648,7.293 34.648,7.293 33.234,8.707 33.234,8.707 35.356,10.829 \
    36.77,12.243 41.012,16.485 42.426,17.899 44.548,20.02 44.548,20.02 45.962,18.606 ')


h1 The Color Averager
svg.icon.svg-scale(aria-hidden='true')
  use(xlink:href='#svg-scale')

.container
  .color
    button.button1.pencil
      svg.icon(aria-hidden='true')
        use(xlink:href='#svg-pencil')
    .swing
      input(type='text', class='manual manual1', placeholder='#', maxlength='6')       
    label.label1
      .text Color 1
      input(type='color' id='color_1', value='#ffffff')
  
  .result
    .text
  
  .color
    button.button2.pencil
      svg.icon(aria-hidden='true')
        use(xlink:href='#svg-pencil') 
    .swing
      input(type='text', class='manual manual2', placeholder='#', maxlength='6')       
    label.label2 
      .text Color 2
      input(type='color' id='color_2', value='#000000')
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Fontdiner+Swanky');

* { box-sizing: border-box; }

@keyframes bouncedown {
  0% {
    transform: translateY(-50em);
  }
  
  50% {
    transform: translateY(.5em);
  }
  
  100% {
    transform: translateY(0);
  }
}

h1,
label,
.result .text {
  font-family: 'Fontdiner Swanky', cursive;  
}

h1 {
  animation: 1s bouncedown forwards;
  color: white;
  text-shadow: #190e0e 1px 0 10px;
  font-size: 80px;  
  margin-bottom: 0;
}

.svg-scale {
  margin-bottom: 1em;
}

body {
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  display: flex;
  justify-content: center;
  transition: 0.5s background-color;  
}

.container {  
  display: flex;
  width: 800px;
  max-width: calc(100% - 2em);
  align-items: center;
  padding: 0 2em 4em;
}

[type=color] {
  width: 100%;
	appearance: none;
	border: none;
  margin-top: .4em;
  cursor: pointer;
}

label {
  letter-spacing: 1px;
  cursor: pointer;
}

.label1 { 
  text-align: right;
}

.label2 {
  text-align-last: left;
}

[type="color"]::-webkit-color-swatch-wrapper {
	padding: 0;
}

[type="color"]::-webkit-color-swatch {
	border: none;
}

.container > * {
  flex: 1;
}

.result {
  display: flex;
  align-items: center;
  padding: 0 1em;
  align-self: flex-end;
}

.result .text {
  flex: 1;
  background-color: #000c;
  color: white;
  padding: .5em .75em;
  letter-spacing: 2px;
  text-align: center;
}

.result .color {
  display: inline-block;
  width: 30px;
  height: 30px;
}

.color {
  position: relative;
}

.color button {
  background: transparent;
  border: none;
  -webkit-appearance: none;
  position: absolute;
  width: 32px;
  height: 32px;
  bottom: 0;
  cursor: pointer;
/*   display: none; */
}

.color button > * {
  pointer-events: none; 
}

.button1 {
  left: -35px;
}

.button2 {
  right: -35px;
  transform: rotate(-90deg);
}

button svg {
  width: 100%;
  height: 100%;
}

.swing {
  perspective: 800;
  position: absolute;  
  bottom: -25px;
  width: 100%;
  transform-style: preserve-3d;
  overflow: hidden;
  backface-visibility: hidden;
}

input.manual {
  transform-origin: top;
  width: 100%;
  transform: translateY(-100%);  
  padding: 0 .2em;
}

button.active+.swing>.manual {
  animation: balance 0.55s ease-in-out forwards;
}

button.inactive+.swing>.manual {
  animation: remove-balance 0.55s ease-in-out forwards;
}

@keyframes balance {
  0% {
    transform: translateY(-100%) rotateX(180deg);
  }

  100% {
    transform: translateY(0) rotateX(0deg);
  }
}

@keyframes remove-balance {  
  0% {
    transform: translateY(0) rotateX(0deg);
  }
  
  100% {
    transform: translateY(-100%) rotateX(180deg);
  }
}

@media screen and (max-width: 900px) {
  h1 {
    font-size: 50px;
  }
}

@media screen and (max-width: 550px) {
  h1 {
    font-size: 40px;
  }
}

@media screen and (max-width: 450px) {
  h1 {
    font-size: 30px;
  }
}
            
          
!
            
              function display(hex) {
  function setLabelText(label) {
    var val = isEditModeManual()
      ? '#' + document.querySelector('.manual' + label).value
      : document.getElementById('color_' + label).value
    document
      .querySelector('.label' + label + ' .text')
      .innerText = 'Color: ' + val    
  }
  result_text.innerHTML = '#' + hex;
  document.body.style.backgroundColor='#' + hex;
  setLabelText('1');
  setLabelText('2');
}

function isEditModeManual() {
  return document.body.classList.contains('manual');
}

function generateAverageColor() {
  var color_1 = document.getElementById('color_1');
  var color_2 = document.getElementById('color_2');
  
  var input_1 = isEditModeManual()
    ? document.querySelector('.manual1').value
    : color_1.value.replace('#', '');

  var input_2 = isEditModeManual()
    ? document.querySelector('.manual2').value
    : color_2.value.replace('#', '');  
  
  // Utility
  function intToHex(num) {
    var hex = Math.round(num).toString(16);

    if (hex.length == 1) {
      hex = '0' + hex;
    }
    return hex;
  }

  // Convert inputs to RGB
  var color_1 = [
  	parseInt(input_1[0] + input_1[1], 16),
    parseInt(input_1[2] + input_1[3], 16),
    parseInt(input_1[4] + input_1[5], 16)
  ];

  var color_2 = [
  	parseInt(input_2[0] + input_2[1], 16),
    parseInt(input_2[2] + input_2[3], 16),
    parseInt(input_2[4] + input_2[5], 16)
  ];

  // Average RGB
  var color_3 = [
    color_1[0] * .5 + color_2[0] * .5,
    color_1[1] * .5 + color_2[1] * .5,
    color_1[2] * .5 + color_2[2] * .5,
  ];

  // Convert back to hex and display
  display(intToHex(color_3[0]) + intToHex(color_3[1]) + intToHex(color_3[2]));
}

var color_inputs = document.querySelectorAll('[type=color]');
var hidden_inputs = document.querySelectorAll('input.manual');
var pencil_icons = document.querySelectorAll('.pencil');
var result_text = document.querySelector('.result > .text');
var result_color = document.querySelector('.result > .color');

[].forEach.call(color_inputs, handleChange);
[].forEach.call(pencil_icons, handlePencilClick);
[].forEach.call(hidden_inputs, handleHiddenInput);

function handleHiddenInput(input) { 
  input.addEventListener(
    'keyup',
    function() {
      var full_fields = 0;
      [].forEach.call(hidden_inputs, function(hidden_input) {
        
        if (hidden_input.value.length === 6) {
          full_fields++;
          if (full_fields === 2) {
            setEditMode('manual');
            generateAverageColor();
          }
        } else {
          setEditMode('');
        }
      });
    }
  );
}

function setEditMode(state) {
  if (state === '') {
    document.body.classList.remove('manual')
  } else {
    document.body.classList.add(state)
  }
 }

function handlePencilClick(pencil) {
  pencil.addEventListener(
    'click', 
    function(e) {
      if (this.classList.contains('active')) {
        this.classList.add('inactive');
        this.classList.remove('active');
      } else {
        this.classList.add('active');
        this.classList.remove('inactive');
      }      
    }
  );  
}

function handleChange(e) {  
  this.addEventListener( 
    'input',
    function() {
      setEditMode('');
      generateAverageColor();
    }
  )
}

window.onload = generateAverageColor;
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console