index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div>
  3. <metadata title="Settings" />
  4. <main-header />
  5. <div class="container">
  6. <h1 id="page-title">Settings</h1>
  7. <div id="sidebar-with-content">
  8. <div class="nav-links">
  9. <router-link
  10. :class="{ active: activeTab === 'profile' }"
  11. to="#profile"
  12. >
  13. Profile
  14. </router-link>
  15. <router-link
  16. :class="{ active: activeTab === 'account' }"
  17. to="#account"
  18. >
  19. Account
  20. </router-link>
  21. <router-link
  22. :class="{ active: activeTab === 'security' }"
  23. to="#security"
  24. >
  25. Security
  26. </router-link>
  27. <router-link
  28. :class="{ active: activeTab === 'preferences' }"
  29. to="#preferences"
  30. >
  31. Preferences
  32. </router-link>
  33. </div>
  34. <profile-settings
  35. v-if="activeTab === 'profile'"
  36. ></profile-settings>
  37. <account-settings
  38. v-if="activeTab === 'account'"
  39. ></account-settings>
  40. <security-settings
  41. v-if="activeTab === 'security'"
  42. ></security-settings>
  43. <preferences-settings
  44. v-if="activeTab === 'preferences'"
  45. ></preferences-settings>
  46. </div>
  47. </div>
  48. <main-footer />
  49. </div>
  50. </template>
  51. <script>
  52. import { mapActions } from "vuex";
  53. import Toast from "toasters";
  54. import MainHeader from "../../components/layout/MainHeader.vue";
  55. import MainFooter from "../../components/layout/MainFooter.vue";
  56. import SecuritySettings from "./tabs/Security.vue";
  57. import AccountSettings from "./tabs/Account.vue";
  58. import ProfileSettings from "./tabs/Profile.vue";
  59. import PreferencesSettings from "./tabs/Preferences.vue";
  60. import io from "../../io";
  61. export default {
  62. components: {
  63. MainHeader,
  64. MainFooter,
  65. SecuritySettings,
  66. AccountSettings,
  67. ProfileSettings,
  68. PreferencesSettings
  69. },
  70. data() {
  71. return {
  72. activeTab: ""
  73. };
  74. },
  75. mounted() {
  76. if (this.$route.hash === "") {
  77. this.$router.push("#profile");
  78. } else {
  79. this.activeTab = this.$route.hash.replace("#", "");
  80. this.localNightmode = this.nightmode;
  81. io.getSocket(socket => {
  82. this.socket = socket;
  83. this.socket.emit("users.findBySession", res => {
  84. if (res.status === "success") {
  85. this.setUser(res.data);
  86. } else {
  87. new Toast({
  88. content: "You're not currently signed in.",
  89. timeout: 3000
  90. });
  91. }
  92. });
  93. this.socket.on("event:user.linkPassword", () =>
  94. this.updateOriginalUser({
  95. property: "password",
  96. value: true
  97. })
  98. );
  99. this.socket.on("event:user.unlinkPassword", () =>
  100. this.updateOriginalUser({
  101. property: "password",
  102. value: false
  103. })
  104. );
  105. this.socket.on("event:user.linkGithub", () =>
  106. this.updateOriginalUser({
  107. property: "github",
  108. value: true
  109. })
  110. );
  111. this.socket.on("event:user.unlinkGithub", () =>
  112. this.updateOriginalUser({
  113. property: "github",
  114. value: false
  115. })
  116. );
  117. });
  118. }
  119. },
  120. methods: mapActions("settings", ["updateOriginalUser", "setUser"])
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. @import "../../styles/global.scss";
  125. .night-mode {
  126. .content {
  127. background-color: #222 !important;
  128. }
  129. }
  130. /deep/ .character-counter {
  131. display: flex;
  132. justify-content: flex-end;
  133. height: 0;
  134. }
  135. .container {
  136. margin-top: 32px;
  137. padding: 24px;
  138. .content {
  139. background-color: #fff;
  140. padding: 30px 50px;
  141. border-radius: 3px;
  142. }
  143. #page-title {
  144. margin-top: 0;
  145. font-size: 35px;
  146. }
  147. #sidebar-with-content {
  148. display: flex;
  149. flex-direction: column;
  150. }
  151. @media only screen and (min-width: 900px) {
  152. #page-title {
  153. margin: 0;
  154. font-size: 40px;
  155. }
  156. #sidebar-with-content {
  157. width: 962px;
  158. margin: 0 auto;
  159. margin-top: 30px;
  160. flex-direction: row;
  161. .content {
  162. width: 600px;
  163. margin-top: 0px !important;
  164. }
  165. }
  166. }
  167. .nav-links {
  168. width: 250px;
  169. margin-right: 64px;
  170. a {
  171. outline: none;
  172. border: none;
  173. box-shadow: none;
  174. color: $musare-blue;
  175. font-size: 22px;
  176. line-height: 26px;
  177. padding: 7px 0 7px 12px;
  178. width: 100%;
  179. text-align: left;
  180. cursor: pointer;
  181. border-radius: 5px;
  182. background-color: transparent;
  183. display: inline-block;
  184. &.active {
  185. color: $white;
  186. background-color: $musare-blue;
  187. }
  188. }
  189. }
  190. /deep/ .content {
  191. margin: 24px 0;
  192. height: fit-content;
  193. .save-changes {
  194. margin-top: 30px;
  195. &:disabled {
  196. background-color: $light-grey !important;
  197. color: #000;
  198. }
  199. }
  200. .control:not(:first-of-type) {
  201. margin: 10px 0;
  202. }
  203. label {
  204. font-size: 14px;
  205. color: $dark-grey-2;
  206. }
  207. textarea {
  208. height: 96px;
  209. }
  210. button {
  211. width: 100%;
  212. }
  213. }
  214. }
  215. /deep/ .saving-changes-transition-enter-active {
  216. transition: all 0.1s ease;
  217. }
  218. /deep/ .saving-changes-transition-enter {
  219. transform: translateX(20px);
  220. opacity: 0;
  221. }
  222. </style>