This is a solution to the Expenses chart component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
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
- Solution URL: https://github.com/RolandoParadaPuig/expencesChartComponent
- Live Site URL: https://rolando-portfolio.web.app/expences-chart
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- Mobile-first workflow
- React - JS library
- ant Design - React UI library
I'm proud of this react component:
export const Bars = (props) => { const divisor = 7; const data = props.data; let maxValue = 0; for (let i = 0; i < data.length; i++) { if (maxValue < data[i].amount) maxValue = data[i].amount; }
const onEnter = (e) => {
const element = e.target.classList;
element.toggle("active");
const amountElem = document.getElementById(bar-${e.target.id});
amountElem.classList.toggle("active-amount");
};
const onLeave = (e) => {
const element = e.target.classList;
element.toggle("active");
const amountElem = document.getElementById(bar-${e.target.id});
amountElem.classList.toggle("active-amount");
};
return data.map((e) => {
const dayStr =
moment()._locale._weekdaysShort[moment().day() == 7 ? 0 : moment().day()];
const index = data.indexOf(e);
return (
i would like to continue develop my skills with React Hooks and react in general
- LinkedIn - https://www.linkedin.com/in/rolando-parada-puig
- Frontend Mentor - https://www.frontendmentor.io/profile/RolandoParadaPuig
- Twitter - https://twitter.com/RolandoParadap
