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.

            
              <body>
    <div id="confirmcopy">
        <div>
            CODE COPIED ;)
        </div>
    </div>
    <div class="copycontainer innie">
        <span id="copydrawer">GET CODE</span>
        <div id="copyhtml" class="clippy" data-clipboard-target="#htmlcode">
            <i class="material-icons">
                code
            </i>
            copy html
        </div>
        <div id="copycss" class="clippy" data-clipboard-target="#csscode">
            <i class="material-icons">
                style
            </i>
            copy css
        </div>
    </div>
    <div id="container">
        <div id="colorpicker">

        </div>
        <div id="example">
            <div id="bgcolorvalue">
                <div id="bgtitle">Red 500</div>
                <div id="bghextitle">#FFGG78</div>
            </div>
            <div id="circle">
                <i id="icon" class="material-icons">
                    favorite
                </i>
            </div>
            <div id="shadcolorvalue">
                <div id="shadowtitle">Red 500</div>
                <div id="shadowhextitle">#FFGG78</div>
            </div>
        </div>
    </div>



    <textarea id="htmlcode" readonly>html</textarea>
    <textarea id="csscode" readonly>css</textarea>
</body>
            
          
!
            
              html,
body {
    padding: 0;
    margin: 0;
    background: rgb(31, 31, 31);
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.disablescroll {
    overflow: hidden;
}

#container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    min-width: 640px;
}

#confirmcopy {
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    color: #fff;
    position: absolute;
    z-index: 10;
    background-color: black;
    display: none;
}

#confirmcopy.show {
    display: flex;
}

textarea {
    opacity: 0;
    position: absolute;
    z-index: -1;
    top: 0;
}

.copycontainer {
    background-color: #ea524f;
    margin: 0 auto;
    padding: 10px 2px 38px 0px;
    color: #fff;
    text-align: center;
    position: fixed;
    right: 0;
    top: calc(50% - 104px);
    z-index: 2;
    transition: all 1s ease;
}

.outtie {
    transform: translateX(0%);
    transition: all 1s ease;
}

.innie {
    transform: translateX(100%);
    transition: all 1s ease;
}

.copycontainer::before {
    content: '';
    position: absolute;
    height: 100%;
    width: 20px;
    top: 0;
    left: -20px;
    background-color: #da4643;
    cursor: pointer;
}

.copycontainer span {
    position: absolute;
    width: 189px;
    transform: rotate(-90deg);
    left: -105px;
    font-size: 13px;
    color: #ff9e9c;
    top: 90px;
    cursor: pointer;
}

#copyhtml,
#copycss {
    cursor: pointer;
    margin-top: 20px;
}

.copycontainer i {
    font-size: 30px;
    font-size: 30px;
    width: 100%;
    text-align: center;
}

#colorpicker {
    height: 400px;
    width: 300px;
    background-color: rgb(53, 53, 53);
    border-radius: 5px;
    margin: 40px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#example {
    margin: 40px;
}

#colorpicker .colorp {
    width: 16.666%;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#shadcolorvalue {
    color: #717171;
    font-size: 18px;
    text-align: center;
    margin-top: 50px;
    position: relative;
}

#copytoclip {
    width: 100%;
    text-align: center;
    color: rgb(228, 228, 228);
}

#bgtitle,
#shadowtitle {
    font-size: 14px;
}

#bghextitle,
#shadowhextitle {
    font-size: 18px;
}

#bgcolorvalue {
    color: #717171;
    font-size: 18px;
    text-align: center;
    margin-bottom: 50px;
    position: relative;
}

#bgcolorvalue span {
    font-size: 25px;
}

#bgcolorvalue::after {
    content: '';
    position: absolute;
    z-index: 0;
    border: 2px solid #717171;
    height: 128px;
    width: 50px;
    border-right: none;
    top: 29px;
    left: -20px;
}

#shadcolorvalue::after {
    content: '';
    position: absolute;
    border: 2px solid #717171;
    height: 121px;
    width: 47px;
    border-left: none;
    top: -92px;
    right: -14px;
}

#colorpicker .colorp .lilcircle {
    height: 30px;
    width: 30px;
    transform: scale(.7);
    background-color: #008fee;
    border-radius: 50%;
    cursor: pointer;
    transition: all .5s ease;
}

#colorpicker .colorp .lilcircle:hover,
#colorpicker .colorp .lilcircle.active {
    transform: scale(1);
    transition: all .5s ease;
}

#colorpicker #example {
    height: 400px;
    width: 300px;
    background-color: rgb(53, 53, 53);
    border-radius: 5px;
    margin: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#circle {
    background-color: #6200EE;
    width: 180px;
    z-index: 1;
    position: relative;
    height: 180px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#circle i {
    font-size: 100px;
    color: white;
}

#icon {
    cursor: pointer;
}

@media only screen and (max-width: 740px) {
    .copycontainer {
        display: none;
    }
}
            
          
!
            
              // define html elements
const circle = document.getElementById('circle');
const icon = document.getElementById('icon');
const lilcircles = document.getElementsByClassName("lilcircle");
const colorpicker = document.getElementById('colorpicker');
const shadowhextitle = document.getElementById('shadowhextitle');
const bghextitle = document.getElementById('bghextitle');
const copydrawer = document.getElementById('copydrawer');
const htmlcode = document.getElementById('htmlcode');
const csscode = document.getElementById('csscode');
const confirmcopy = document.getElementById('confirmcopy');
let ricon = '';
new ClipboardJS('.clippy');


//function to fill out copyable html and css
let generateCode = function (backgroundColor = null, textshadow = null) {
    let htmlstr = `<div class="iconcircle"><i class="material-icons shadowicon">${ricon}</i></div>`
    if (backgroundColor || textshadow) {
        let cssstr = `.iconcircle{display:flex;align-items:center;justify-content:center;height:80px;width:80px;background-color:${backgroundColor};overflow:hidden;border-radius:50%}.iconcircle .shadowicon{color:#fff;font-size:45px;text-shadow:${textshadow}}`
        csscode.innerHTML = cssstr;
    }
    htmlcode.innerHTML = htmlstr;
}


//when code copied, show user it was copied
let celements = document.getElementsByClassName('clippy');
for (var i = 0; i < celements.length; i++) {
    celements[i].addEventListener('click', function () {
        confirmcopy.classList.add('show');
        setTimeout(function () {
            confirmcopy.classList.remove('show');
        }, 1000);

    });
}


//add event listener to open code copy drawer onclick
copydrawer.addEventListener('click', function () {
    let drawer = document.getElementsByClassName('copycontainer')[0];
    if (drawer.classList.contains('innie')) {
        drawer.classList.remove('innie');
        drawer.classList.add('outtie');
    } else {
        drawer.classList.remove('outtie');
        drawer.classList.add('innie');
    }
});


//Grab Material Colors and Parse JSON object
let googleColors = null;
var data = null;
var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
        googleColors = JSON.parse(this.responseText);

        //create preview swatches
        for (var color in googleColors) {
            for (var subcolor in googleColors[color]) {
                if (subcolor == '400' || subcolor == '500' || subcolor == '600') {
                    let shadowcolor = parseInt(subcolor) + 300;
                    let shadowhex = googleColors[color][shadowcolor]
                    let bgtitle = color + ' ' + subcolor;
                    let shadowtitle = color + ' ' + shadowcolor;
                    let el = document.createElement('div');
                    let htmlString = `<div class="lilcircle" style="background-color: ${googleColors[color][subcolor]};" data-shadow="${shadowhex}" data-bgtitle="${bgtitle}" data-shadowtitle="${shadowtitle}" data-color="${googleColors[color][subcolor]}"></div>`
                    el.innerHTML = htmlString.trim();
                    colorpicker.appendChild(el);
                    el.classList.add('colorp');
                }
            }
        }

        //set background of circle as color of selected cricle and shadow color
        for (var i = 0; i < lilcircles.length; i++) {
            lilcircles[i].addEventListener('click', function () {
                for (var i = 0; i < lilcircles.length; i++) {
                    lilcircles[i].classList.remove('active');
                }
                this.classList.add('active');
                circle.style['background-color'] = this.style['background-color'];

                //generate text-shadow string and add it onclick!
                let textshadowstring = '';
                for (i = 1; i < 120; i++) {
                    textshadowstring += i + 'px ' + i + 'px ' + this.getAttribute('data-shadow') + ',';
                }
                textshadowstring = textshadowstring.substring(0, textshadowstring.length - 1);
                icon.style['text-shadow'] = textshadowstring;

                //switch the titles
                shadowhextitle.innerHTML = this.getAttribute('data-shadow');
                bghextitle.innerHTML = this.getAttribute('data-color');
                shadowtitle.innerHTML = this.getAttribute('data-shadowtitle');
                bgtitle.innerHTML = this.getAttribute('data-bgtitle');

                //change the code to copy
                generateCode(this.style['background-color'], textshadowstring);

            });
        }

        //trigger click on an element
        document.getElementsByClassName('lilcircle')[Math.floor(Math.random() * 56) + 1].click();
    }
});

xhr.open("GET", "https://gist.githubusercontent.com/kawanet/a880c83f06d6baf742e45ac9ac52af96/raw/b4fbc9a730394eb977277e73cc37b60955463f21/material-colors.json");
xhr.send(data);


//grab random icon
let icons = [];
var icon_data = null;

var xhr_icon = new XMLHttpRequest();

let grabRandomIcon = function () {
    let randomicon = icons[Math.floor(Math.random() * icons.length)];
    ricon = randomicon.split(" ")[0];
    generateCode();
    return ricon;
}

xhr_icon.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
        icons = this.responseText.split("\n");
        icon.innerHTML = grabRandomIcon();
    }
});

xhr_icon.open("GET", "https://raw.githubusercontent.com/google/material-design-icons/master/iconfont/codepoints");
xhr_icon.send(icon_data);

//randomize icon again on user click
icon.addEventListener('click', function () {
    icon.innerHTML = grabRandomIcon();
});
            
          
!
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