HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<body onload="collectPledges()">
<!-- Header includes hero, logo and main menu -->
<div class="header">
<div class="header--overlay"></div>
<div class="header__hero">
<picture>
<source media="(min-width: 768px)" srcset="https://supraweb.dev/demos/crowdfunding-product-page-main/images/image-hero-desktop.jpg">
<img class="hero__image" src="https://supraweb.dev/demos/crowdfunding-product-page-main/images/image-hero-mobile.jpg" alt="">
</picture>
</div>
<div class="header__navbar">
<div class="navbar__logo">
<img class="logo__image" src="https://supraweb.dev/demos/crowdfunding-product-page-main/images/logo.svg" alt="">
</div>
<div class="navbar__menu">
<ul class="main__menu">
<li class="menu__item"><a class="menu__link" href="">About</a></li>
<li class="menu__item"><a class="menu__link" href="">Discover</a></li>
<li class="menu__item"><a class="menu__link" href="">Get Started</a></li>
</ul>
<div class="menu__mobile-icons" onclick="menuToggle()">
<img class="mobile__hamburger" src="https://supraweb.dev/demos/crowdfunding-product-page-main/images/icon-hamburger.svg" alt="">
<img class="mobile__close mobile__close--hidden" src="https://supraweb.dev/demos/crowdfunding-product-page-main/images/icon-close-menu.svg" alt="">
</div>
</div>
</div>
</div>
<!-- Intro section -->
<div class="box">
<div class="box__inner">
<img class="box__image" src="https://supraweb.dev/demos/crowdfunding-product-page-main/images/logo-mastercraft.svg" alt="">
<h1 class="box__title">Mastercraft Bamboo Monitor Riser</h1>
<p class="box__paragraph">A beautiful & handcrafted monitor stand to reduce neck and eye strain.</p>
<div class="box__buttons">
<button class="button button--primary">Back this project</button>
<div class="button__bookmark" onclick="bookmark()">
<svg width="56" height="56" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd">
<circle class="button--circle-fill" cx="28" cy="28" r="28" />
<path class="button--bookmark-fill" d="M23 19v18l5-5.058L33 37V19z" />
</g>
</svg>
<p class="bookmark__paragraph">Bookmark</p>
</div>
</div>
</div>
</div>
<!-- Intro section | Counters -->
<div class="box box--nomargin">
<div class="box__inner box--flex">
<div class="box__numbers">
<p class="box__number box__total">$89,914</p>
<p class="box__paragraph box__paragraph--close">of $100,000 backed</p>
</div>
<div class="box__numbers">
<p class="box__number box__backers">5,007</p>
<p class="box__paragraph box__paragraph--close">total backers</p>
</div>
<div class="box__numbers">
<p class="box__number">56</p>
<p class="box__paragraph box__paragraph--close">days left</p>
</div>
<div class="box__slider">
<div class="slider__background">
<div class="slider__progress"></div>
</div>
</div>
</div>
</div>
<!-- Main section with pledges elements -->
<div class="box box--nomargin">
<div class="box__inner">
<h1 class="box__title box__title--aligned-left">About this project</h1>
<p class="box__paragraph box__paragraph--aligned-left">The Mastercraft Bamboo Monitor Riser is a sturdy and
stylish platform that elevates your screen to a more comfortable viewing height. Placing your monitor at eye
level has the potential to improve
your posture and make you more comfortable while at work, helping you stay focused on the task at hand.</p>
<p class="box__paragraph box__paragraph--aligned-left">Featuring artisan craftsmanship, the simplicity of design
creates extra desk space below your computer to allow notepads, pens, and USB sticks to be stored under the
stand.</p>
<div class="box__pledge">
<h3 class="pledge__title">Bamboo Stand</h3>
<p class="pledge__subtitle">Pledge $25 or more</p>
<p class="pledge__paragraph">You get an ergonomic stand made of natural bamboo. You've helped us launch our
promotional campaign, and you’ll be added to a special Backer member list.</p>
<div class="pledge__info">
<p class="pledge__paragraph"><span class="pledge__number">101</span>left</p>
<button class="button button--primary" onclick="openModal()" data-pledge-value="25">Select Reward</button>
</div>
</div>
<div class="box__pledge">
<h3 class="pledge__title">Black Edition Stand</h3>
<p class="pledge__subtitle">Pledge $75 or more</p>
<p class="pledge__paragraph">You get a Black Special Edition computer stand and a personal thank you. You’ll be
added to our Backer member list. Shipping is included.</p>
<div class="pledge__info">
<p class="pledge__paragraph"><span class="pledge__number">64</span>left</p>
<button class="button button--primary" onclick="openModal()" data-pledge-value="75">Select Reward</button>
</div>
</div>
<div class="box__pledge">
<h3 class="pledge__title">Mahogany Special Edition</h3>
<p class="pledge__subtitle">Pledge $200 or more</p>
<p class="pledge__paragraph">You get two Special Edition Mahogany stands, a Backer T-Shirt, and a personal thank
you. You’ll be added to our Backer member list. Shipping is included.</p>
<div class="pledge__info">
<p class="pledge__paragraph"><span class="pledge__number">0</span>left</p>
<button class="button button--secondary">Out of Stock</button>
</div>
</div>
</div>
</div>
<!-- Modal with selected items | Selected value moved to modal -->
<div class="modal">
<div class="box">
<div class="box__inner">
<img src="https://supraweb.dev/demos/crowdfunding-product-page-main/images/icon-close-modal.svg" class="modal__close" alt="" onclick="closeModal()">
<h1 class="box__title box__title--aligned-left">Back this project</h1>
<p class="box__paragraph box__paragraph--aligned-left">Want to support us in bringing Mastercraft Bamboo Monitor
Riser out in the world?</p>
<div class="box__pledge box__modal" data-box-value="1">
<div class="modal--flex">
<div class="box__radio">
<label class="radio__label" onclick="changePledge()">Pledge with no reward
<input type="radio" name="pledge-value" class="modal__radio" data-radio-value="1">
<span class="radio__checkmark"></span>
</label>
</div>
<p class="modal__subtitle"></p>
<p class="modal__left-p"><span class="modal__number"></span></p>
<p class="modal__paragraph">Choose to support us without a reward if you simply believe in our project. As
a backer, you will be signed up to receive product updates via email.</p>
</div>
<div class="modal__info">
<p class="info__paragraph">Enter your pledge</p>
<div>
<input type="number" class="modal__number-input" min="1" max="999999" index="1" value="1">
<input type="submit" class="button button--primary button--small" value="Continue" onclick="success()">
</div>
</div>
</div>
<div class="box__pledge box__modal" data-box-value="25">
<div class="modal--flex">
<div class="box__radio">
<label class="radio__label" onclick="changePledge()">Bamboo Stand
<input type="radio" name="pledge-value" class="modal__radio" data-radio-value="25">
<span class="radio__checkmark"></span>
</label>
</div>
<p class="modal__subtitle">Pledge $25 or more</p>
<p class="modal__left-p"><span class="modal__number">101</span>left</p>
<p class="modal__paragraph">You get an ergonomic stand made of natural bamboo. You've helped us launch our
promotional campaign, and you’ll be added to a special Backer member list.</p>
</div>
<div class="modal__info">
<p class="info__paragraph">Enter your pledge</p>
<div>
<input type="number" class="modal__number-input" min="25" max="999999" index="25" value="25">
<input type="submit" class="button button--primary button--small" value="Continue" onclick="success()">
</div>
</div>
</div>
<div class="box__pledge box__modal" data-box-value="75">
<div class="modal--flex">
<div class="box__radio">
<label class="radio__label" onclick="changePledge()">Black Edition Stand
<input type="radio" name="pledge-value" class="modal__radio" data-radio-value="75">
<span class="radio__checkmark"></span>
</label>
</div>
<p class="modal__subtitle">Pledge $75 or more</p>
<p class="modal__left-p"><span class="modal__number">64</span>left</p>
<p class="modal__paragraph">You get a Black Special Edition computer stand and a personal thank you.
You’ll be added to our Backer member list. Shipping is included.</p>
</div>
<div class="modal__info">
<p class="info__paragraph">Enter your pledge</p>
<div>
<input type="number" class="modal__number-input" min="75" max="999999" index="75" value="75">
<input type="submit" class="button button--primary button--small" value="Continue" onclick="success()">
</div>
</div>
</div>
<div class="box__pledge box__modal" data-box-value="200">
<div class="modal--flex">
<div class="box__radio">
<label class="radio__label" onclick="changePledge()">Mahogany Special Edition
<input type="radio" name="pledge-value" class="modal__radio" data-radio-value="200">
<span class="radio__checkmark"></span>
</label>
</div>
<p class="modal__subtitle">Pledge $200 or more</p>
<p class="modal__left-p"><span class="modal__number">0</span>left</p>
<p class="modal__paragraph">You get two Special Edition Mahogany stands, a Backer T-Shirt, and a personal
thank you. You’ll be added to our Backer member list. Shipping is included.</p>
</div>
<div class="modal__info">
<p class="info__paragraph">Enter your pledge</p>
<div>
<input type="number" class="modal__number-input" min="200" max="999999" index="200" value="200">
<input type="submit" class="button button--primary button--small" value="Continue" onclick="success()">
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Confirmation modal -->
<div class="success">
<div class="box">
<div class="box__inner box__success">
<img src="https://supraweb.dev/demos/crowdfunding-product-page-main/images/icon-check.svg" alt="">
<h1 class="box__title">Thanks for your support!</h1>
<p class="modal__paragraph modal__success">Your pledge brings us one step closer to sharing Mastercraft Bamboo
Monitor Riser
worldwide. You will get an email once our campaign is completed.</p>
<button class="button button--primary" onclick="successConfirm()">Got it!</button>
</div>
</div>
</div>
<script src="./js/script.js"></script>
<div class="attribution">
<p>Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.
</p>
<p>Coded by <a href="https://supraweb.dev/" target="_blank">Łukasz Gąsiecki</a>.</p>
</div>
</body>
@import url('https://fonts.googleapis.com/css2?family=Commissioner:wght@400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap');
:root {
/* Primary colors */
--Moderate-cyan: hsl(176, 50%, 47%);
--Dark-cyan: hsl(176, 72%, 28%);
/* Neutral colors */
--Black: hsl(0, 0%, 0%);
--Black-transparent: hsla(0, 0%, 0%, 0.5);
--Dark-gray: hsl(0, 0%, 48%);
--Border-gray: hsl(0, 0%, 89%);
--Background-gray: hsl(0, 0%, 97%);
--White: hsl(0, 0%, 100%);
/* Container max width */
--max-width-desktop: 1100px;
--max-width-mobile: 340px;
}
/* CSS Reset Start */
* {
padding: 0;
margin: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
list-style: none;
list-style-type: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
}
html,
body,
div,
span,
h1,
h2,
h3,
h4 {
font-size: 100%;
font: inherit;
}
/* CSS Reset End */
body {
font-family: 'Commissioner', sans-serif;
font-size: 16px;
font-weight: 400;
line-height: 1.6;
text-align: center;
color: var(--Black);
background-color: var(--Background-gray);
}
/* Top main header for page */
.header {
position: relative;
width: 100%;
height: 50vh;
}
/* Styling hero images inside the header */
.hero__image {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 50vh;
object-fit: cover;
}
/* Logo inside the header */
.navbar__logo {
width: 120px;
}
/* Logo image inside the header */
.logo__image {
width: 100%;
}
/* navbar inside header */
.header__navbar {
position: absolute;
left: 50%;
transform: translateX(-50%);
z-index: 99;
width: 100%;
max-width: var(--max-width-desktop);
padding: 5vh 3vh;
display: flex;
flex-direction: row;
justify-content: space-between;
}
/* Black transparent background for mobile menu */
.header--overlay {
display: none;
position: fixed;
top: 0;
left: 0;
z-index: 10;
width: 100%;
height: 100%;
background-color: var(--Black-transparent);
}
/* Black transparent background for mobile menu | When mobile menu is active */
.header--overlay.active {
display: block;
}
/* Main page navigation */
.main__menu {
display: none;
position: fixed;
left: 3vh;
top: 80px;
right: 3vh;
text-align: left;
background-color: var(--White);
border-radius: 10px;
-webkit-box-shadow: 0px 8px 18px -11px rgba(0, 0, 0, 1);
-moz-box-shadow: 0px 8px 18px -11px rgba(0, 0, 0, 1);
box-shadow: 0px 8px 18px -11px rgba(0, 0, 0, 1);
}
/* Menu display property on mobile */
.main__menu.active {
display: block;
}
/* Main menu links and items */
/* Main menu link */
.menu__link {
display: inline-block;
font-weight: 500;
color: var(--Black);
text-decoration: none;
padding: 4vh 3vh;
}
/* Main menu list item */
.menu__item {
display: block;
border-bottom: 1px solid var(--Border-gray);
}
/* Main menu list item | Removing border from last element */
.menu__item:last-of-type {
border-bottom: none;
}
/* Mobile menu | Buttons for hiding and showing menu*/
.mobile__hamburger,
.mobile__close {
display: block;
}
.mobile__hamburger--hidden {
display: none;
}
.mobile__close--hidden {
display: none;
}
/* Intro section | Box */
.box {
position: relative;
width: 100%;
margin-top: -50px;
}
/* Main conatiner inside box */
.box__inner {
position: relative;
width: 100%;
max-width: var(--max-width-mobile);
margin: auto;
padding: 5vh 3vh;
background-color: var(--White);
border: 1px solid var(--Border-gray);
border-radius: 16px;
}
/* Box in modal with selected pledge | Border 2px colored */
.box__modal.active {
border: 2px solid var(--Moderate-cyan);
}
/* Box with selected pledge | Properties of element with pledge value and Continue button */
.box__pledge.active>.modal__info {
display: flex;
flex-direction: column;
}
/* No margin with margin :) */
.box--nomargin {
margin-top: 30px;
}
/* Image inside box */
.box__image {
position: absolute;
top: -25px;
left: 50%;
transform: translateX(-50%);
}
/* Title inside box */
.box__title,
.pledge__title {
font-size: 24px;
font-weight: 700;
line-height: 1.1;
margin: 4vh 0 2vh;
}
.box__title--aligned-left,
.box__paragraph--aligned-left {
text-align: left;
}
/* Paragrapgh inside box */
.box__paragraph,
.pledge__paragraph {
color: var(--Dark-gray);
margin: 4vh 0;
}
/* Closing paragraph inside counters sections */
.box__paragraph--close {
position: relative;
padding-bottom: 3vh;
margin: 0.5vh 0 6vh;
}
/* Setting border after boxes with numbers inside counters section | All without last element */
.box__numbers:not(.box__numbers:nth-of-type(3))>.box__paragraph--close::after {
position: absolute;
top: 8vh;
left: 50%;
transform: translateX(-50%);
content: '';
width: 100px;
height: 1px;
background-color: var(--Border-gray);
}
/* Special text properties for counters in counter section and pledges left number */
.box__number,
.pledge__number {
font-size: 34px;
font-weight: 700;
color: var(--Black);
}
/* Special marign for last paragraph element inside counters section */
.box__numbers:nth-of-type(3)>.box__paragraph--close {
margin: 0.5vh 0 2vh;
}
/* Slider with progress of collected pledges */
.box__slider {
width: 100%;
}
/* Grayed background for slider */
.slider__background {
position: relative;
width: 100%;
height: 12px;
background-color: var(--Border-gray);
border-radius: 20px;
}
/* Cyan progress bar */
.slider__progress {
position: absolute;
top: 0;
left: 0;
width: 89%;
height: 12px;
background-color: var(--Moderate-cyan);
border-radius: 20px;
}
/* Main box with all pledge info */
.box__pledge {
text-align: left;
padding: 0 3vh 4vh;
margin-bottom: 30px;
border: 1px solid var(--Border-gray);
border-radius: 16px;
}
/* Cyan subtitle for pledge */
.pledge__subtitle {
font-weight: 500;
color: var(--Moderate-cyan);
}
/* Element with pledges left info and Select Reward button */
.pledge__info {
display: flex;
flex-direction: column;
width: 100%;
}
/* Postitioning pledges left inside paragraph */
.pledge__info>.pledge__paragraph {
display: flex;
align-items: center;
}
/* Setting margin for all elements with numbers*/
.pledge__info * .pledge__number {
margin-right: 10px;
}
/* Button | Might be reused */
.button {
font-size: 18px;
font-weight: 700;
color: var(--White);
display: inline-block;
width: 220px;
height: 56px;
border: none;
border-radius: 50px;
cursor: pointer;
transition: .3s ease-in-out;
}
/* Primary button */
.button--primary {
background-color: var(--Moderate-cyan);
}
/* Hover state for priamry button | changes to dark cyan */
.button--primary:hover {
background-color: var(--Dark-cyan);
}
/* Changing button size for mobile view */
.button--small {
width: 116px;
}
/* Grayed button as secondary */
.button--secondary {
background-color: var(--Dark-gray);
}
/* Putting buttons into one box */
.box__buttons {
width: 100%;
display: flex;
justify-content: space-between;
}
/* Mobile width for Bookmark button | Only icon is visible */
.button__bookmark {
width: 56px;
}
/* Bookmark button svg color */
.button--circle-fill {
fill: #2f2f2f;
}
/* Bookmark button svg color | Color when button active */
.button--circle-fill.colored {
fill: #3cb4ac;
}
/* Bookmark button svg color */
.button--bookmark-fill {
fill: #B1B1B1;
}
/* Bookmark button svg color | Color when button active */
.button--bookmark-fill.colored {
fill: #ffffff;
}
/* Paragraph inside Bookmark button | Disabled on mobile */
.bookmark__paragraph {
display: none;
}
/* Flex attribute for boxes */
.box--flex {
display: flex;
flex-direction: column;
}
/* Modal items */
/* Main modal element */
.modal {
display: none;
position: fixed;
overflow-y: scroll;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: var(--Black-transparent);
}
/* Modal closing icon */
.modal__close {
position: absolute;
top: 40px;
right: 40px;
cursor: pointer;
}
/* Active state for modal | Changing display property */
.modal.active {
display: block;
}
/* Special margin for box element inside modal */
.modal>.box,
.success>.box {
margin: 50px 0;
}
/* Radio input styling | Label is clickable | Input is hidden by opacity to 0 */
.modal__radio {
position: absolute;
opacity: 0;
cursor: pointer;
}
/* Label for radio */
.radio__label {
font-size: 18px;
font-weight: 700;
cursor: pointer;
}
/* Stylign circle instead of hidden radio */
.radio__checkmark {
position: absolute;
top: 16px;
left: 0;
width: 21px;
height: 21px;
background: var(--White);
border: 2px solid var(--Border-gray);
border-radius: 50%;
}
/* Styling selected state | Display set to none */
.radio__checkmark::after {
content: '';
position: absolute;
top: 3px;
left: 4px;
width: 10px;
height: 10px;
background-color: var(--Moderate-cyan);
border-radius: 50%;
display: none;
}
/* Setting display property to block when radio label is clicked */
.modal__radio:checked~.radio__checkmark::after {
display: block;
}
/* Box with all radio elements | Positioning by flex */
.box__radio {
position: relative;
padding-left: 40px;
flex-grow: 1;
order: 1;
}
/* Special styling for bix inside modal */
.box__modal {
padding-top: 20px;
padding: 0 0 4vh;
}
/* Subtitle in modal */
.modal__subtitle {
font-weight: 700;
color: var(--Moderate-cyan);
flex-grow: 1;
order: 2;
padding-left: 40px;
}
/* Pledges left info */
.modal__number {
font-size: 18px;
font-weight: 700;
color: var(--Black);
margin-right: 6px;
}
/* Pledges left info */
.modal__left-p {
color: var(--Dark-gray);
flex-grow: 8;
order: 4;
text-align: left;
margin-bottom: 3vh;
}
/* Flex display for modal elements */
.modal--flex {
display: flex;
flex-wrap: wrap;
flex-direction: column;
padding: 4vh 4vh 0;
}
/* Text paragraph for modal */
.modal__paragraph {
color: var(--Dark-gray);
margin: 2vh 0 4vh;
order: 3;
}
/* Element with "Enter your pledge", pledge value and continue button inside modal */
.modal__info {
display: none;
justify-content: space-between;
align-items: center;
width: 100%;
padding: 4vh 4vh 0;
border-top: 1px solid var(--Border-gray);
}
/* Changing to inline-block button element */
.modal__info>.button {
display: inline-block;
}
/* Enter your pledge text */
.info__paragraph {
display: inline-block;
margin-bottom: 20px;
}
/* Styling input with pledge value */
.modal__number-input {
font-size: 18px;
font-weight: 700;
text-align: right;
color: var(--Black);
display: inline-block;
width: 100px;
height: 56px;
padding-right: 20px;
margin-right: 20px;
border: 1px solid var(--Border-gray);
border-radius: 50px;
background-image: url(../images/icon-dollar.svg);
background-repeat: no-repeat;
background-position: left 10px top 17px;
}
/* Removing browser input default outline */
.modal__number-input:focus {
outline-offset: 0px !important;
outline: none !important;
}
/* Coloring input outline for hover, active, focus states */
.modal__number-input:hover,
.modal__number-input:active,
.modal__number-input:focus {
border: 1px solid var(--Moderate-cyan);
}
/* Modal success items */
/* Hidden by default confirmation box */
.success {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 300%;
background-color: var(--Black-transparent);
}
/* Active state for confirmation box */
.success.active {
display: block;
}
/* Padding reset for success modal */
.modal__success {
padding: 0;
}
/* Media query for desktop */
@media only screen and (min-width: 768px) {
/* Changing box width inside pledge */
.box__inner {
max-width: var(--max-width-desktop);
}
/* Changing width for success modal */
.box__success {
max-width: 700px;
}
/* Changing display flex into row on desktop */
.box--flex {
width: 100%;
text-align: left;
flex-direction: row;
flex-wrap: wrap;
align-items: flex-start;
column-gap: 160px;
}
/* Changing counter section border to right on desktop */
.box__numbers:not(.box__numbers:nth-of-type(3))>.box__paragraph--close::after {
top: -50px;
left: 200px;
content: '';
width: 1px;
height: 70px;
background-color: var(--Border-gray);
}
/* Changing padding for pledge */
.box__inner {
padding: 5vh 5vw;
}
/* Radio input padding overwite */
.box__radio {
padding-left: 60px;
}
/* Repositioning radio checkmark */
.radio__checkmark {
top: 4px;
}
/* Flex display to row on desktop */
.pledge__info {
flex-direction: row;
align-items: center;
justify-content: space-between;
}
/* Overwriting paragraph properties inside modal */
.modal__paragraph {
width: 100%;
order: 4;
padding: 0 60px;
}
/* Enter you plage text */
.modal__left-p {
order: 3;
text-align: right;
}
/* Modal flex display change to row on desktop */
.modal--flex {
flex-direction: row;
}
/* Removing padding for subttile in modal */
.modal__subtitle {
padding-left: 0;
}
/* Modal info flex change to row on active pledge box */
.box__pledge.active>.modal__info {
flex-direction: row;
}
/* Changing button small to normal width on desktop */
.button--small {
width: 220px;
}
/* Special Bookmark button styling */
.button__bookmark {
display: flex;
align-items: center;
width: auto;
height: 56px;
font-size: 18px;
font-weight: 500;
color: var(--Dark-gray);
text-decoration: none;
padding: 0 30px 0 0;
background-color: var(--Background-gray);
border-radius: 50px;
cursor: pointer;
}
/* Adding space between svg and text inside Bookmark button */
.button__bookmark>svg {
margin-right: 20px;
}
/* Paragraph display inside Bookmark button set to inline-block */
.bookmark__paragraph {
display: inline-block;
}
/* Changing color on Bookmark button when selected */
.bookmark__paragraph.active {
color: var(--Moderate-cyan);
}
/* Overwriting styles on desktop screen */
.main__menu {
display: block;
position: fixed;
left: none;
top: 5vh;
right: 3vh;
text-align: right;
background-color: transparent;
border-radius: 0;
box-shadow: none;
}
/* Main menu links and items */
/* Main menu link */
.menu__link {
display: inline-block;
font-weight: 500;
color: var(--White);
text-decoration: none;
padding: 0 3vh;
}
/* Main menu link hover */
.menu__link:hover {
text-decoration: underline;
}
/* Main menu list item */
.menu__item {
display: inline-block;
border-bottom: none;
}
/* Mobile menu | Buttons for hiding and showing menu*/
.mobile__hamburger {
display: none;
}
/* Removing margin for Enter your pledge text */
.info__paragraph {
margin-bottom: 0;
}
}
/* Attribution section */
.attribution {
font-family: 'Roboto', sans-serif;
font-size: 12px;
font-weight: 300;
color: #000;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 4vh 0;
}
.attribution>p>a {
color: #000;
}
.attribution>p {
padding-bottom: 0;
margin-bottom: 5px;
}
/* Variables on document load for zero state */
let boxModal = '';
let radioModal = '';
let modalSuccess = '';
let pledgeValue = '';
let inputValue = '';
let total = 89914;
let backers = 5007;
/* Function for bookmark button to change its visual state */
function bookmark() {
/* select bookmark text html element by class */
const bookmarkButton = document.querySelector('.bookmark__paragraph');
/* select svg circle to change color when active */
const circleSvg = document.querySelector('.button--circle-fill');
/* select bookmark icon inside circle */
const circleSvgBookmark = document.querySelector('.button--bookmark-fill');
/* change text inside bookmark button to -> Bookmarked */
bookmarkButton.innerHTML = 'Bookmarked';
/* change its color to -> Moderate Cyan */
bookmarkButton.classList.add('active');
/* change circle color to -> Moderate Cyan */
circleSvg.classList.add('colored');
/* change bookmark icon color inside bookmark button to -> White */
circleSvgBookmark.classList.add('colored');
}
/* Function for mobile menu */
function menuToggle() {
/* select main menu ul element by class */
const mainMenu = document.querySelector('.main__menu');
/* select overlay background for mobile menu */
const mainMenuOverlay = document.querySelector('.header--overlay');
/* variables for hamburger and menu close icons */
const mobileHamburger = document.querySelector('.mobile__hamburger');
const mobileClose = document.querySelector('.mobile__close');
/* condition for mobile menu | if ul main menu not contains active class */
/* adds active class (display: block) to ul element and overlay background */
if (!mainMenu.classList.contains('active')) {
mainMenu.classList.add('active');
mainMenuOverlay.classList.add('active');
/* changing display state of hamburger and close icons */
mobileHamburger.classList.add('mobile__hamburger--hidden');
mobileClose.classList.remove('mobile__close--hidden');
} else {
/* when functions invoked when active class is assigned changes states */
mainMenu.classList.remove('active');
mainMenuOverlay.classList.remove('active');
mobileHamburger.classList.remove('mobile__hamburger--hidden');
mobileClose.classList.add('mobile__close--hidden');
}
}
/* Function to open modal with pledges */
function openModal() {
/* select html element with modal class */
const modal = document.querySelector('.modal');
/* add active class display: block */
modal.classList.add('active');
}
/* Function to close modal */
function closeModal() {
/* removing active class boxModal variable changed after opening modal */
boxModal.classList.remove('active');
/* select html element with modal class */
const modal = document.querySelector('.modal');
/* hiding modal by removing active class */
modal.classList.remove('active');
}
/* Changing pledge inside opened modal */
function changePledge() {
/* Removing exisitng active state of selected element */
boxModal.classList.remove('active');
/* Assign value of radio input to variable radioModal */
radioModal = document.querySelector('input[name="pledge-value"]:checked').getAttribute('data-radio-value');
/* Assign boxModal value of selected input through data-box-value attribute */
boxModal = document.querySelector('[data-box-value="' + radioModal + '"]');
/* Select proper input after changing pledge by index */
inputValue = document.querySelector('[index="' + radioModal + '"]');
/* Activating selected by radio modal pledge box */
boxModal.classList.add('active');
}
/* Select all elements with class name button */
function collectPledges() {
/* Variable for button element*/
const dataPledgeValue = document.getElementsByClassName('button');
/* Loop for button elements */
for (let i = 0; i < dataPledgeValue.length; i++) {
/* Select elements with data-pledge-value only */
if (dataPledgeValue[i].hasAttribute('data-pledge-value')) {
/* Setting event listener for button elements containing value */
dataPledgeValue[i].addEventListener('click', pledgeClicked(i));
}
/* Function invoked by event listener after user click passing pledge value */
function pledgeClicked(i) {
return function () {
/* Passing pledge value into variable */
let attr = dataPledgeValue[i].getAttribute('data-pledge-value');
/* Adding attr variable with pledge value into boxModal, radioModal and number input */
/* data-box-value and value attributes */
boxModal = document.querySelector('[data-box-value="' + attr + '"]');
radioModal = document.querySelector('[data-radio-value="' + attr + '"]');
inputValue = document.querySelector('[index="' + attr + '"]');
/* Condition for display property of selected pledge */
if (!boxModal.classList.contains('active')) {
boxModal.classList.add('active');
radioModal.checked = true;
} else {
boxModal.classList.remove('active');
radioModal.checked = false;
}
}
}
}
}
/* Function invoked by Continue button | Confirmation of succefull pledge */
function success() {
/* Display property change by adding active class to element with .success class */
modalSuccess = document.querySelector('.success');
modalSuccess.classList.add('active');
/* Variables set to access HTML elements by class */
const totalText = document.querySelector('.box__total');
const totalBackers = document.querySelector('.box__backers');
const totalProgressBar = document.querySelector('.slider__progress');
/* Updating total variable about input value */
total = total + parseInt(inputValue.value);
/* Counting percent of total money backed */
let totalProgress = ((total * 100) / 100000);
/* Changing the width od progress bar */
/* Width cannot be more than 100% */
if (totalProgress >= 100) {
totalProgressBar.style.width = 100 + '%';
} else {
totalProgressBar.style.width = totalProgress + '%';
}
/* Displaying total collected money */
totalText.innerHTML = '$' + (total.toLocaleString("en-US"));
/* Updating total backers value | Increment by one */
backers = backers + 1;
/* Displaying updated backers */
totalBackers.innerHTML = backers.toLocaleString("en-US");
/* Invoking closeModal() function to clear states */
closeModal();
}
/* Invoked after Got it! button clicked */
function successConfirm() {
modalSuccess.classList.remove('active');
}
Also see: Tab Triggers