microsoft/AI-For-Beginners
Publicmirrored fromhttps://github.com/microsoft/AI-For-BeginnersAvailable
etc/quiz-app/src/App.vue
145lines · modecode
| 1 | <template> |
| 2 | <div> |
| 3 | <nav> |
| 4 | <ul> |
| 5 | <li> |
| 6 | <router-link class="navlink" to="/">Home</router-link> |
| 7 | </li> |
| 8 | <li> |
| 9 | <label for="locale">locale</label> |
| 10 | </li> |
| 11 | <li> |
| 12 | <select v-model="locale"> |
| 13 | <option>en</option> |
| 14 | <option>es</option> |
| 15 | </select> |
| 16 | </li> |
| 17 | <li class="title">{{ questions[locale][0].title }}</li> |
| 18 | </ul> |
| 19 | </nav> |
| 20 | <div id="app"> |
| 21 | |
| 22 | <router-view> |
| 23 | <Quiz /> |
| 24 | </router-view> |
| 25 | </div> |
| 26 | </div> |
| 27 | </template> |
| 28 | |
| 29 | <script> |
| 30 | import Quiz from "@/components/Quiz.vue"; |
| 31 | import messages from "@/assets/translations"; |
| 32 | |
| 33 | export default { |
| 34 | name: "App", |
| 35 | computed: { |
| 36 | questions() { |
| 37 | return messages; |
| 38 | }, |
| 39 | |
| 40 | }, |
| 41 | i18n: { messages }, |
| 42 | components: { |
| 43 | Quiz, |
| 44 | }, |
| 45 | data() { |
| 46 | return { |
| 47 | locale: "", |
| 48 | }; |
| 49 | }, |
| 50 | watch: { |
| 51 | locale(val) { |
| 52 | this.$root.$i18n.locale = val; |
| 53 | }, |
| 54 | }, |
| 55 | created() { |
| 56 | this.route = this.$route.params.id; |
| 57 | if (this.$route.query.loc) { |
| 58 | this.locale = this.$route.query.loc; |
| 59 | } else { |
| 60 | this.locale = "en"; |
| 61 | } |
| 62 | }, |
| 63 | }; |
| 64 | </script> |
| 65 | |
| 66 | <style> |
| 67 | html { |
| 68 | font-family: Avenir, Helvetica, Arial, sans-serif; |
| 69 | -webkit-font-smoothing: antialiased; |
| 70 | -moz-osx-font-smoothing: grayscale; |
| 71 | color: #252d4a; |
| 72 | } |
| 73 | nav { |
| 74 | background-color: #252d4a; |
| 75 | padding: 1em; |
| 76 | margin-bottom: 20px; |
| 77 | } |
| 78 | |
| 79 | nav a { |
| 80 | color: white; |
| 81 | text-align: right; |
| 82 | } |
| 83 | |
| 84 | ul{ |
| 85 | list-style-type: none; |
| 86 | margin: 0; |
| 87 | padding: 0; |
| 88 | overflow: hidden; |
| 89 | } |
| 90 | |
| 91 | li { |
| 92 | float: left; |
| 93 | } |
| 94 | |
| 95 | .title { |
| 96 | color:white; |
| 97 | font-weight: bold; |
| 98 | font-size: x-large; |
| 99 | float: right; |
| 100 | } |
| 101 | |
| 102 | .link { |
| 103 | display: list-item; |
| 104 | } |
| 105 | |
| 106 | h1, |
| 107 | h2, |
| 108 | h3, |
| 109 | .message { |
| 110 | text-align: center; |
| 111 | } |
| 112 | .error { |
| 113 | color: red; |
| 114 | } |
| 115 | .complete { |
| 116 | color: green; |
| 117 | } |
| 118 | .card { |
| 119 | width: 60%; |
| 120 | border: #252d4a solid; |
| 121 | border-radius: 5px; |
| 122 | margin: auto; |
| 123 | padding: 1em; |
| 124 | } |
| 125 | .btn { |
| 126 | min-width: 50%; |
| 127 | font-size: 16px; |
| 128 | text-align: center; |
| 129 | cursor: pointer; |
| 130 | margin-bottom: 5px; |
| 131 | width: 50%; |
| 132 | font-size: 16px; |
| 133 | color: #ffffff; |
| 134 | background-color: #252d4a; |
| 135 | border-radius: 5px; |
| 136 | padding: 5px; |
| 137 | justify-content: flex-start; |
| 138 | align-items: center; |
| 139 | } |
| 140 | .ans-btn { |
| 141 | justify-content: center; |
| 142 | display: flex; |
| 143 | margin: 4px auto; |
| 144 | } |
| 145 | </style> |
| 146 | |