This is my solution to the Expenses Chart Component challenge on Frontend Mentor. The challenge was a great opportunity to practice dynamic rendering of charts, responsive design, and working with LESS for CSS preprocessing.
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 color than 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.
Desktop Design
Mobile Design
- Solution URL: Add solution URL here
- Live Site URL: Live Site
- Semantic HTML5
- LESS (CSS preprocessor)
- Flexbox for layout
- Vanilla JavaScript for dynamic functionality
- Mobile-first workflow
While building this project, I gained deeper insight into the following:
-
LESS Preprocessor:
- Using variables for colors to maintain consistency across styles.
- Nesting CSS for better readability.
-
Dynamic Data Rendering:
- Using
fetch()
to retrieve and render JSON data. - Dynamically calculating bar heights and tooltips based on the provided data.
- Using
-
Responsive Design:
- Adapting the chart layout for various screen sizes using media queries.
Here's a small snippet showcasing my use of LESS variables:
@soft-red: hsl(10, 79%, 65%);
@cyan: hsl(186, 34%, 60%);
.bar {
background-color: @soft-red;
&:hover {
opacity: 0.7;
}
}
In future projects, I plan to:
- Explore other preprocessors like SCSS for comparison.
- Dive deeper into JavaScript frameworks like React to handle dynamic components more efficiently.
- Refine accessibility by using ARIA attributes for charts.
- LESS Documentation - A great resource to understand the features and syntax of LESS.
- MDN Web Docs - Fetch API - Helped me understand how to fetch and process JSON data.
- CSS Tricks - Responsive Design - A comprehensive guide to mastering Flexbox for responsive layouts.
Follow these steps to install and run the project:
- Install Node.js (if not already installed). Download it from Node.js.
- Install LESS globally via npm:
npm install -g less
-
Clone the project repository:
git clone https://github.com/yourusername/expenses-chart-component.git
-
Navigate to the project directory:
cd expenses-chart-component
-
Compile the LESS file to CSS:
lessc style.less style.css
-
Open the
index.html
file in your browser to view the project.
To watch and automatically recompile LESS during development, run:
lessc style.less style.css --watch
- LinkedIn - Yashi Singh
- Frontend Mentor - Yashi-Singh-9
Special thanks to Frontend Mentor for providing this challenge and helping me improve my skills.