Relevant files are script.ts, WeatherData.ts, index.html.
I made a simple weather 5-day forecast application using mainly TypeScript. I was wondering how I can improve my code since I originally wanted to use a data structure that I created called a "WeatherData" to store my information about the weather for each day of the week.
WeatherData data structure
export class WeatherData {
date: string;
city: string;
country: string;
temperature: number;
minTemperature: number;
maxTemperature: number;
weather: any;
weatherIcon: any;
}
TypeScript file concerns
The main concerns I have about the TypeScript files (script.ts, WeatherData.ts) is the fact that halfway through making my project, I realized that I didn't actually need to use a WeatherData
data structure. This led to me passing in WeatherData
variables in functions as well as returning WeatherData
variables from functions that don't actually need to return it.
- Is there a more object-oriented way I should be approaching my script.ts class in order to use data structures?
- Will using a
WeatherData
data structure be better? - How can I format my code (maybe different classes?) such that all the functions aren't all clumped together?
HTML file concerns
First time ever making a front-end UI using HTML and I don't know what areas I should refactor. I noticed I have a lot of repeated element tags such as:
<h4 id="wordDay0">Day 0</h4>
<h4 id="monthDay0">month-day 0</h4>
<h4 id="forecast0">Forecast</h4>
<img src="" id="icon0" alt="" height="60" width="60">
<h1 id="currentTemp0">Current</h1>
<h4 id="maxTemp0">Max</h4>
<h4 id="minTemp0">Min</h4>
I have 5 of these (one for each day).
Screenshot of what the UI looks like:
- What type of suggestions are there to making my UI look better? I was thinking of making the jumbotron element a different color.