├── .env ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico └── index.html ├── src ├── App.vue ├── assets │ └── logo.png ├── components │ ├── DayForecastTab.vue │ ├── SearchBar.vue │ └── Weather.vue ├── main.js ├── router.js ├── service.js ├── store.js └── views │ └── Home.vue └── tests └── unit └── example.spec.js /.env: -------------------------------------------------------------------------------- 1 | VUE_APP_ROOT_API='https://api.apixu.com/v1/forecast.json?key=b26ac48768b64da2aae125932190705&q=' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # shak-vue-weatherapp 2 | https://shakweather.netlify.com/ 3 | 4 | ## Project setup 5 | ``` 6 | npm install 7 | ``` 8 | 9 | ### Compiles and hot-reloads for development 10 | ``` 11 | npm run serve 12 | ``` 13 | 14 | ### Compiles and minifies for production 15 | ``` 16 | npm run build 17 | ``` 18 | 19 | ### Run your tests 20 | ``` 21 | npm run test 22 | ``` 23 | 24 | ### Lints and fixes files 25 | ``` 26 | npm run lint 27 | ``` 28 | 29 | ### Run your unit tests 30 | ``` 31 | npm run test:unit 32 | ``` 33 | 34 | ### Customize configuration 35 | See [Configuration Reference](https://cli.vuejs.org/config/). 36 | "#simple vue weather app" 37 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shak-vue-weatherapp", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "test:unit": "vue-cli-service test:unit" 9 | }, 10 | "dependencies": { 11 | "bootstrap": "^4.3.1", 12 | "bootstrap-vue": "^2.0.0-rc.19", 13 | "core-js": "^2.6.5", 14 | "dotenv": "^8.0.0", 15 | "jquery": "^3.4.1", 16 | "popper.js": "^1.15.0", 17 | "vue": "^2.6.10", 18 | "vue-router": "^3.0.3", 19 | "vuetify": "^1.5.14", 20 | "vuex": "^3.0.1" 21 | }, 22 | "devDependencies": { 23 | "@vue/cli-plugin-babel": "^3.7.0", 24 | "@vue/cli-plugin-unit-jest": "^3.7.0", 25 | "@vue/cli-service": "^3.7.0", 26 | "@vue/test-utils": "1.0.0-beta.29", 27 | "babel-core": "7.0.0-bridge.0", 28 | "babel-jest": "^23.6.0", 29 | "material-design-icons-iconfont": "^5.0.1", 30 | "node-sass": "^4.9.0", 31 | "sass-loader": "^7.1.0", 32 | "vue-template-compiler": "^2.5.21" 33 | }, 34 | "postcss": { 35 | "plugins": { 36 | "autoprefixer": {} 37 | } 38 | }, 39 | "browserslist": [ 40 | "> 1%", 41 | "last 2 versions" 42 | ], 43 | "jest": { 44 | "moduleFileExtensions": [ 45 | "js", 46 | "jsx", 47 | "json", 48 | "vue" 49 | ], 50 | "transform": { 51 | "^.+\\.vue$": "vue-jest", 52 | ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub", 53 | "^.+\\.jsx?$": "babel-jest" 54 | }, 55 | "transformIgnorePatterns": [ 56 | "/node_modules/" 57 | ], 58 | "moduleNameMapper": { 59 | "^@/(.*)$": "/src/$1" 60 | }, 61 | "snapshotSerializers": [ 62 | "jest-serializer-vue" 63 | ], 64 | "testMatch": [ 65 | "**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)" 66 | ], 67 | "testURL": "http://localhost/", 68 | "watchPlugins": [ 69 | "jest-watch-typeahead/filename", 70 | "jest-watch-typeahead/testname" 71 | ] 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shxk/simple-vue-weather-app/54bfa108aa175af926b064802b19eed622360c77/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | shak vue weather app 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 26 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shxk/simple-vue-weather-app/54bfa108aa175af926b064802b19eed622360c77/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/DayForecastTab.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/components/SearchBar.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 38 | 39 | -------------------------------------------------------------------------------- /src/components/Weather.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 48 | 49 | 55 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import store from './store' 5 | import bootstrap from 'bootstrap-vue' 6 | import Vuetify from 'vuetify' 7 | import 'bootstrap/dist/css/bootstrap.css' 8 | import 'bootstrap-vue/dist/bootstrap-vue.css' 9 | import 'vuetify/dist/vuetify.min.css' 10 | import 'material-design-icons-iconfont/dist/material-design-icons.css' 11 | 12 | Vue.use(bootstrap) 13 | Vue.use(Vuetify, { 14 | iconfont: 'md' 15 | }) 16 | Vue.config.productionTip = false 17 | 18 | new Vue({ 19 | router, 20 | store, 21 | render: h => h(App) 22 | }).$mount('#app') 23 | -------------------------------------------------------------------------------- /src/router.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Home from './views/Home.vue' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'home', 12 | component: Home 13 | } 14 | ] 15 | }) 16 | -------------------------------------------------------------------------------- /src/service.js: -------------------------------------------------------------------------------- 1 | export default { 2 | getWeather(payload){ 3 | return fetch(process.env.VUE_APP_ROOT_API + payload) 4 | .then(res => res.json()); 5 | } 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/store.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import service from '@/service.js' 4 | 5 | 6 | Vue.use(Vuex) 7 | 8 | export default new Vuex.Store({ 9 | state: { 10 | isTabFlagCurrent: null, 11 | locationSearch: null, 12 | weatherCache: null, 13 | }, 14 | mutations: { 15 | setTabFlag: (state, payload) => state.isTabFlagCurrent = payload, 16 | setlocationSearch:(state,payload) => state.locationSearch = payload, 17 | setWeatherCache: (state, payload) => state.weatherCache = payload 18 | }, 19 | actions: { 20 | async searchLocation({ getters, commit, dispatch }, payload) { 21 | let wF = await service.getWeather(payload + '&days=7'); 22 | commit('setWeatherCache', wF) 23 | } 24 | }, 25 | getters:{ 26 | getTabFlag: (state) => state.isTabFlagCurrent, 27 | getlocationSearch: (state) => state.locationSearch, 28 | getWeatherCache: (state) => state.weatherCache, 29 | } 30 | }) 31 | -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 26 | 32 | 33 | -------------------------------------------------------------------------------- /tests/unit/example.spec.js: -------------------------------------------------------------------------------- 1 | import { shallowMount } from '@vue/test-utils' 2 | import Weather from "@/components/Weather.vue"; 3 | 4 | /* Example Test: 5 | 6 | describe('Weather.vue', () => { 7 | it('renders props.msg when passed', () => { 8 | const msg = 'new message' 9 | const wrapper = shallowMount(Weather, { 10 | propsData: { msg } 11 | }); 12 | expect(wrapper.text()).toMatch(msg) 13 | }) 14 | }) 15 | 16 | */ 17 | --------------------------------------------------------------------------------