This project is a Svelte application that allows users to compare the cost of using fuel (gasoline or diesel) versus electricity for their vehicles. The application fetches real-time fuel and electricity prices from APIs and performs calculations based on user inputs such as fuel type, fuel consumption per kilometer, and energy consumption per kilometer.
- Fetches real-time fuel prices from the SSB API.
- Fetches real-time electricity prices from the "Hva Koster Strømmen" API.
- Allows users to select their fuel type (gasoline or diesel).
- Allows users to input their vehicle's fuel consumption per kilometer.
- Allows users to input their vehicle's energy consumption per kilometer.
- Calculates and displays the cost per kilometer for both fuel and electricity.
- Determines which energy source is currently cheaper for the user.
The project will be divided into several Svelte components for better maintainability and readability:
Switch.svelte
: A reusable switch component for selecting the fuel type.FuelCard.svelte
: Handles the fuel-related inputs and calculations.ElectricityCard.svelte
: Handles the electricity-related inputs and calculations.ComparisonCard.svelte
: Handles the comparison between fuel and electricity costs.
To run this project locally, follow these steps:
- Clone the repository:
git clone https://github.com/jvik/elbilkalulator.git
- Navigate into the project directory:
cd elbilkalulator
- Install the dependencies:
npm install
- Start the development server:
npm run dev
Contributions are welcome! Please read our contributing guidelines to get started.
This project is licensed under the MIT License. See the LICENSE file for details.