<section class="Confirm">
<div class="Confirm-Header">
<a class="Confirm-Header-Button Confirm-Header-Button_Close" href="javascript: void(0)"></a>
<a class="Confirm-Header-Button Confirm-Header-Button_Minimize" href="javascript: void(0)"></a>
<a class="Confirm-Header-Button Confirm-Header-Button_Maximize" href="javascript: void(0)"></a>
<h1 class="Confirm-Header-Title">Confirm uninstall</h1>
</div>
<div class="Confirm-Body">
<h2 class="Confirm-Body-Title">Are you sure you want to remove Boi from your pc?</h2>
<figure class="Boi">
<div class="Boi-Blush Boi-Blush_L"></div>
<div class="Boi-Blush Boi-Blush_R"></div>
<div class="Boi-Eye Boi-Eye_L"></div>
<div class="Boi-Eye Boi-Eye_R"></div>
<div class="Boi-Mouth"></div>
</figure>
<a class="Confirm-Body-Button Confirm-Body-Button_Cancel" href="javascript: void(0)">Cancel</a>
<a class="Confirm-Body-Button Confirm-Body-Button_Delete" href="javascript: void(0)">Uninstall</a>
</div>
</section>
* {
box-sizing: border-box;
font: inherit;
}
html {
overflow: hidden;
color: #333;
font-size: 62.5%;
@media screen and (max-width: 480px){
font-size: 50%;
}
body {
font-size: 2rem;
padding: 0;
margin: 0;
width: 100vw;
height: 100vh;
background-image: linear-gradient(to left bottom, #444, #222);
overflow: hidden;
font-family: 'Rubik', sans-serif;
}
}
.Confirm {
$red: #a43;
$green: #6a4;
$yellow: #cb3;
position: absolute;
display: flex;
flex-direction: column;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 72rem;
max-width: 100%;
min-width: 34rem;
max-height: 100%;
height: 46rem;
background-color: #ccc;
border-radius: 1rem;
box-shadow: 0px 10px 5px -3px rgba(0, 0, 0, 0.2);
&-Header {
display: flex;
align-items: center;
position: relative;
flex: 0 0 4rem;
margin: 0 1rem;
border-bottom: solid 1px rgba(0, 0, 0, 0.1);
white-space: nowrap;
&-Button {
display: block;
width: 1.6rem;
height: 1.6rem;
border-radius: 1rem;
flex: 0 0 auto;
transition: background-color 0.3s;
&:not(:last-of-type) {
margin-right: 1rem;
}
&_Close {
background-color: $red;
&:hover {
background-color: lighten($red, 10%);
}
}
&_Maximize {
background-color: $yellow;
&:hover {
background-color: lighten($yellow, 10%);
}
}
&_Minimize {
background-color: $green;
&:hover {
background-color: lighten($green, 10%);
}
}
}
&-Title {
margin: 0;
padding: 0;
transform: translateX(50%);
margin-right: 50%;
margin-left: auto;
}
}
&-Body {
flex: 1;
display: flex;
align-items: flex-end;
justify-content: space-between;
position: relative;
margin: 2rem 4rem;
&-Title {
margin: 0;
padding: 0;
position: absolute;
transform: translateY(-50%);
top: 5%;
text-align: center;
width: 100%;
}
&-Button {
&, &:link, &:visited {
color: #fff;
border-radius: 1rem;
text-decoration: none;
padding: 1rem 2rem;
margin-bottom: 1rem;
min-width: 10rem;
text-align: center;
transition: background-color 0.3s;
}
&_Delete {
background-color: $red;
&:hover {
background-color: lighten($red, 10%);
}
}
&_Cancel {
background-color: $green;
&:hover {
background-color: lighten($green, 10%);
}
}
}
}
}
.Boi {
$face-color: #eb5;
$mouth-color: #a33;
$scare-color: #5a8;
--happiness: 0.9;
--derp: 1;
--px: 0.5;
--py: 0.5;
width: 22rem;
max-width: 100%;
height: 22rem;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-image: radial-gradient(lighten($face-color, 20%), $face-color);
border-radius: 100%;
overflow: hidden;
margin: 0;
align-self: center;
flex: 0 0 auto;
border: solid 2px darken($face-color, 5%);
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
&, * {
position: absolute;
}
&::before {
content: '';
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-image: linear-gradient(to bottom, $scare-color, rgba($scare-color, 0));
opacity: calc(1 - var(--happiness));
}
&-Blush {
width: 20%;
height: 10%;
background-color: rgba(255, 100, 100, 0.3);
border: 3px solid rgba(255, 100, 100, 0.3);
top: calc(45% + var(--py) * 10%);
border-radius: 100%;
opacity: calc(var(--happiness) * var(--happiness) * 0.9 + 0.1);
&_L {
left: calc(7% + var(--px) * 2%);
}
&_R {
right: calc(9% - var(--px) * 2%);
}
}
&-Eye {
width: calc(26% - var(--happiness) * 2%);
height: calc(26% - var(--happiness) * 2%);
background-color: #f6f6f6;
border-radius: 100%;
top: calc(25% + var(--py) * 10%);
overflow: hidden;
&_L {
left: calc(18% + var(--px) * 4%);
&::after {
transform: translate(calc((var(--px) + var(--derp) * 0.5) * 100%), calc((var(--py) + var(--derp) * 0.5) * 100%));
}
}
&_R {
right: calc(22% - var(--px) * 4%);
&::after {
transform: translate(calc((var(--px) + var(--derp) * -0.3) * 100%), calc((var(--py) + var(--derp) * -0.3) * 100%));
}
}
&::after {
content: '';
display: block;
background-color: #421;
width: calc(55% - var(--happiness) * 10%);
height: calc(55% - var(--happiness) * 10%);
border-radius: 100%;
}
}
&-Mouth {
width: calc(51% - var(--happiness) * 2%);
height: calc(26% - var(--happiness) * 2%);
background-color: $mouth-color;
border-radius: calc((1 - var(--happiness)) * 10em) calc((1 - var(--happiness)) * 10em) calc(var(--happiness) * 16em) calc(var(--happiness) * 16em);
top: calc(57.5% + var(--py) * 5%);
left: calc(47.5% + var(--px) * 5%);
transform: translateX(-50%);
overflow: hidden;
border: 3px solid darken($mouth-color, 5%);
/* fix safari overflow breach */
-webkit-mask-image: -webkit-radial-gradient(white, black);
&::before {
content: '';
display: block;
position: absolute;
width: 20%;
height: 20%;
top: 0;
left: 50%;
background-color: white;
border-radius: 0 0 0.5rem 0.5rem;
}
&::after {
content: '';
display: block;
position: absolute;
width: 60%;
height: 50%;
left: 10%;
bottom: 0;
background-color: rgba(0, 0, 0, 0.2);
border-radius: 20rem 20rem 0 0;
}
}
}
View Compiled
const confirm = document.querySelector('.Confirm');
const boi = document.querySelector('.Boi');
const btnDelete = document.querySelector('.Confirm-Body-Button_Delete');
const btnCancel = document.querySelector('.Confirm-Body-Button_Cancel');
const current = {
happiness: 0.9,
derp: 1,
px: 0.5,
py: 0.5
};
const target = { ...current };
confirm.addEventListener('mousemove', onMouseMove);
confirm.addEventListener('mouseleave', onMouseLeave);
function onMouseMove({ clientX: x, clientY: y }) {
let dx1 = x - btnDelete.getBoundingClientRect().x - btnDelete.getBoundingClientRect().width * 0.5;
let dy1 = y - btnDelete.getBoundingClientRect().y - btnDelete.getBoundingClientRect().height * 0.5;
let dx2 = x - btnCancel.getBoundingClientRect().x - btnCancel.getBoundingClientRect().width * 0.5;
let dy2 = y - btnCancel.getBoundingClientRect().y - btnCancel.getBoundingClientRect().height * 0.5;
let px = (x - confirm.getBoundingClientRect().x) / confirm.getBoundingClientRect().width;
let py = (y - confirm.getBoundingClientRect().y) / confirm.getBoundingClientRect().height;
let distDelete = Math.sqrt(dx1 * dx1 + dy1 * dy1);
let distCancel = Math.sqrt(dx2 * dx2 + dy2 * dy2);
let happiness = Math.pow(distDelete / (distCancel + distDelete), 0.75);
target.happiness = happiness;
target.derp = 0;
target.px = px;
target.py = py;
}
function onMouseLeave() {
target.happiness = 0.9;
target.derp = 1;
target.px = 0.5;
target.py = 0.5;
}
function update() {
for (let prop in target) {
if (target[prop] === current[prop]) {
continue;
} else if (Math.abs(target[prop] - current[prop]) < 0.01) {
current[prop] = target[prop];
} else {
current[prop] += (target[prop] - current[prop]) * 0.1;
}
boi.style.setProperty(`--${prop}`, current[prop]);
}
requestAnimationFrame(update);
}
update();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.