cholis04 / interactive-pricing-component-main

This is my solution to the Interactive Pricing Component challenge on Frontend Mentor.

Home Page:https://interactive-pricing-fem.web.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Frontend Mentor - Interactive pricing component solution

This is a solution to the Interactive pricing component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the app depending on their device's screen size
  • See hover states for all interactive elements on the page
  • Use the slider and toggle to see prices for different page view numbers

Screenshot

Web Capture

Links

My process

Built with

  • Semantic HTML5 markup
  • Desktop-first workflow
  • CSS custom properties
  • Flexbox & Grid - Layouting
  • Input type 'Range' & 'Checkbox'
  • Typescript - For Development JavaScript Compile

This is my first project using typescript.

What I learned

List Style Image

Web Capture

main .card-price > .action > ul {
  list-style-image: url('../images/icon-check.svg');
}

Selection Input type Range / Slider for Styling

Web Capture

<input
  type="range"
  min="0"
  max="4"
  step="1"
  name="pageviews"
  id="pageviews"
  value="2"
/>
input[type='range'] {
  /* Styles */
}
input[type='range']::-webkit-slider-thumb {
  /* Styles */
}
input[type='range']::-webkit-slider-thumb:hover {
  /* Styles */
}
input[type='range']::-webkit-slider-thumb:active {
  /* Styles */
}
input[type='range']::-webkit-slider-runnable-track {
  /* Styles */
}
input[type='range']::-moz-range-progress {
  /* Styles */
}
input[type='range']::-ms-fill-lower {
  /* Styles */
}

Create Toggle from Checkbox

Web Capture

<label for="period">
  <input type="checkbox" name="period" id="period" />
  <span class="box-check">
    <span></span>
  </span>
</label>
label > input[type='checkbox'] {
  display: none;
}
label {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
label > span.box-check {
  position: relative;
  width: 46px;
  height: 24px;
  border-radius: 25px;
  display: flex;
  align-items: center;
  padding: 2px 4px;
  background-color: var(--toggle-background);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@media (hover: hover) {
  label:hover > span.box-check {
    background-color: var(--soft-cyan);
  }
}

label > span.box-check > span {
  position: absolute;
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50px;
  background-color: var(--white);
  transition: all 0.2s ease-in-out;
}

label > input[type='checkbox']:checked + span.box-check > span {
  transform: translateX(22px);
}

label > input[type='checkbox']:checked + span.box-check {
  background-color: var(--strong-cyan);
}

Continued development

Input type range is still not supported in some older browsers. Mainly for applying styles that require a prefix to run well. A combination of JavaScript and CSS is indispensable

Useful resources

Author

Acknowledgments

Many thanks to anyone who provided feedback.

About

This is my solution to the Interactive Pricing Component challenge on Frontend Mentor.

https://interactive-pricing-fem.web.app/


Languages

Language:CSS 66.6%Language:HTML 13.4%Language:TypeScript 10.1%Language:JavaScript 10.0%