An open API service indexing awesome lists of open source software.

https://github.com/medsagou/expenses-chart-component


https://github.com/medsagou/expenses-chart-component

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

# Frontend Mentor - Expenses chart component solution

This is a solution to the [Expenses chart component challenge ](https://www.frontendmentor.io/challenges/expenses-chart-component-e7yJBUdjwt).

## Table of contents

- [Overview](#overview)
- [The challenge](#the-challenge)
- [Screenshot](#screenshot)
- [Links](#links)
- [My process](#my-process)
- [Built with](#built-with)
- [What I learned](#what-i-learned)
- [Continued development](#continued-development)
- [Useful resources](#useful-resources)
- [Author](#author)
- [Acknowledgments](#acknowledgments)

## Overview

### The challenge

Users should be able to:

- View the bar chart and hover over the individual bars to see the correct amounts for each day
- See the current day’s bar highlighted in a different colour to the other bars
- View the optimal layout for the content depending on their device’s screen size
- See hover states for all interactive elements on the page
- **Bonus**: Use the JSON data file provided to dynamically size the bars on the chart

### Screenshot

![](./screenshot.jpg)

### Links

- Solution URL: [https://github.com/medsagou/expenses-chart-component.git](https://github.com/medsagou/expenses-chart-component.git)
- Live Site URL: [https://medsagou.github.io/expenses-chart-component/](https://medsagou.github.io/expenses-chart-component/)

## My process
no process just keep going when you get stack.
### Built with

- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Mobile-first workflow
- [React](https://reactjs.org/) - JS library
- [Next.js](https://nextjs.org/) - React framework
- [Styled Components](https://styled-components.com/) - For styles
- [Modern css reset](https://piccalil.li/blog/a-modern-css-reset/) - piccalil

### What I learned

```html












  • mon

  • tue

  • wed

  • thu

  • fri

  • sat

  • sun




```
```css
@media (hover: hover){
.col-1::after,
.col-2::after,
.col-3::after,
.col-4::after,
.col-5::after,
.col-6::after,
.col-7::after{
content: attr(title);
position: absolute;
display: none;
background-color: var(--neutral-700);
color: rgb(255, 255, 255);
width: max-content;
font-family: var(--ff-primary);
font-weight: 700;
border-radius: .2rem;
font-size: .7rem;
padding: .4em .5em;
top: -1rem;
left: 50%;
transform: translate(-50%,-50%);
}
.col-1:hover::after,
.col-2:hover::after,
.col-3:hover::after,
.col-4:hover::after,
.col-5:hover::after,
.col-6:hover::after,
.col-7:hover::after {
display: block;
z-index: 1;
}

}
```
```js

// just the last 7 days
function lastSevenDays(arr){
objAppend={'day':'***', 'amount':0};
if (arr.length > 7) {
const M=arr.length-7;
for(let i=0 ; i < M ; i++) {
arr.shift();
}
}else if (arr.length < 7) {
const M=7-arr.length;
for(let i=0 ; i < M ; i++) {
arr.push(objAppend)
}
}
return arr;
}

// claculate the height of each column
function heightCalc(amount, maxAmount,colHeight){
return (amount*colHeight)/maxAmount
}

//get amounts
function getAmounts(data){
const amounts=[];
for(let i=0; i