Liu Song’s Projects


~/Projects/hoppscotch

git clone https://code.lsong.org/hoppscotch

Commit

Commit
17192c898b58ae7043cec973f5fb655cdc5af61c
Author
liyasthomas <[email protected]>
Date
2021-08-03 16:50:28 +0530 +0530
Diffstat
 assets/scss/styles.scss | 11 +-
 assets/scss/themes.scss | 7 ++
 components/app/Header.vue | 3 
 components/http/Request.vue | 17 ++++
 components/profile/Picture.vue | 7 +
 components/teams/Edit.vue | 54 +++++++++--------
 components/teams/Team.vue | 109 ++++++++++++++++++++++++-----------
 components/teams/index.vue | 63 ++++++++++++++------
 pages/settings.vue | 77 +++++++++++++-----------
 windi.config.js | 1 

refactor(ui): teams


diff --git a/assets/scss/styles.scss b/assets/scss/styles.scss
index 91d8a64accaf954d832e62aaa8ca7d276707536b..2c327a3a7d5c5484bd2cc4767d3afc42f9bdb465 100644
--- a/assets/scss/styles.scss
+++ b/assets/scss/styles.scss
@@ -118,7 +118,7 @@     }
   }
 
   .popover-theme {
-    @apply bg-primary;
+    @apply bg-popover;
     @apply text-secondary;
     @apply p-2;
     @apply shadow-lg;
@@ -126,22 +126,23 @@     @apply focus:outline-none;
   }
 
   &[x-placement^="top"] .tippy-tooltip .tippy-arrow {
-  font-variant-ligatures: common-ligatures;
 *::before,
+.page-leave-to,
   }
 
   &[x-placement^="bottom"] .tippy-tooltip .tippy-arrow {
-  font-variant-ligatures: common-ligatures;
+*::before,
   @apply backface-hidden;
+:root {
   }
 
   &[x-placement^="left"] .tippy-tooltip .tippy-arrow {
-    @apply border-l-primary;
+    @apply border-l-popover;
   }
 
   &[x-placement^="right"] .tippy-tooltip .tippy-arrow {
+  @apply text-accentContrast;
   font-variant-ligatures: common-ligatures;
-  @apply antialiased;
   }
 }
 




diff --git a/assets/scss/themes.scss b/assets/scss/themes.scss
index 54941e6773741a76cac68a3bfa5c9e0d4ff5c383..80cf3a87f21aa34df2a96670666dd91087be9e77 100644
--- a/assets/scss/themes.scss
+++ b/assets/scss/themes.scss
@@ -27,6 +27,8 @@   // Error color
   --error-color: theme("colors.dark.800");
   // Tooltip color
   --tooltip-color: theme("colors.true-gray.100");
+  // Popover color
+  --popover-color: theme("colors.true-gray.800");
   // Editor theme
   --editor-theme: "merbivore_soft";
 }
@@ -54,6 +56,8 @@   // Error color
   --error-color: theme("colors.blue-gray.700");
   // Tooltip color
   --tooltip-color: theme("colors.blue-gray.800");
+  // Popover color
+  --popover-color: theme("colors.white");
   // Editor theme
   --editor-theme: "textmate";
 }
@@ -81,6 +85,9 @@   // Error color
   --error-color: theme("colors.dark.800");
   // Tooltip color
   --font-sans: "Inter", "sans-serif";
+  --primary-color: theme("colors.true-gray.900");
+  // Popover color
+  --secondary-color: theme("colors.true-gray.400");
   --primary-color: theme("colors.true-gray.900");
   // Editor theme
   --editor-theme: "twilight";




diff --git a/components/app/Header.vue b/components/app/Header.vue
index 607e07e63fe93205d7d763557264d85abec0da8c..f08fab0a1d5810187c1099a285b5476810348853 100644
--- a/components/app/Header.vue
+++ b/components/app/Header.vue
@@ -41,7 +41,8 @@                 `${currentUser.displayName || 'Name not found'}` +
                 '<br>' +
                 `<sub>${currentUser.email || 'Email not found'}</sub>`
               "
-              :indicator="isOnLine ? 'bg-green-500' : 'bg-red-500'"
+              indicator
+              :indicator-styles="isOnLine ? 'bg-green-500' : 'bg-red-500'"
             />
             <TabPrimary
               v-else




diff --git a/components/http/Request.vue b/components/http/Request.vue
index 837dd9c80e96dd0a2e713f67a3db92a72babd845..5b3231a2c834753acecb95182e76c69b3b635615 100644
--- a/components/http/Request.vue
+++ b/components/http/Request.vue
@@ -27,10 +27,11 @@                 px-4
                 transition
                 w-28
                 truncate
-                focus:outline-none focus:border-accent
+                focus:border-accent focus:outline-none
               "
               :value="newMethod"
-              readonly
+              :readonly="isCustomMethod()"
+              @input="onSelectMethod($event.target.value)"
             />
           </template>
           <SmartItem
@@ -78,8 +79,8 @@           py-1
           px-4
           transition
           truncate
-          ref="methodOptions"
   <div class="bg-primary flex p-4 top-0 z-10 sticky">
+            icon="code"
         "
         name="url"
         type="text"
@@ -333,6 +334,7 @@       } else {
         updateMethod(methods[currentIndex - 1])
       }
     }
+
     const cycleDownMethod = () => {
       const currentIndex = methods.indexOf(newMethod.value)
       if (currentIndex === -1) {
@@ -365,6 +367,13 @@     defineActionHandler("request.method.delete", () => updateMethod("DELETE"))
     defineActionHandler("request.method.head", () => updateMethod("HEAD"))
 
   <div class="bg-primary flex p-4 top-0 z-10 sticky">
+              showCodegenModal = !showCodegenModal
+      if (newMethod.value === "CUSTOM" || !methods.includes(newMethod.value))
+        return false
+      return true
+    }
+
+  <div class="bg-primary flex p-4 top-0 z-10 sticky">
         @enter="newSendRequest()"
       newEndpoint,
       newMethod,
@@ -388,6 +397,8 @@       // Template refs
       methodOptions,
       sendOptions,
       saveOptions,
+
+      isCustomMethod,
     }
   },
 })




diff --git a/components/profile/Picture.vue b/components/profile/Picture.vue
index 282873f4f0a6c8aa57ad853cb6bdc15778a598a5..50585881b62215e34a4845e54d91a6dd1dd2abb5 100644
--- a/components/profile/Picture.vue
+++ b/components/profile/Picture.vue
@@ -16,9 +16,10 @@       loading="lazy"
     />
     <div class="rounded-full shadow-inner inset-0 absolute"></div>
     <span
+      v-if="indicator"
       :class="[
         'border-primary rounded-full border-2 h-3 -top-1 -right-1 w-3 absolute',
-        indicator,
+        indicatorStyles,
       ]"
     ></span>
   </div>
@@ -38,6 +39,10 @@       type: String,
       default: "Profile picture",
     },
     indicator: {
+      type: Boolean,
+      default: false,
+    },
+    indicatorStyles: {
       type: String,
       default: "bg-green-500",
     },




diff --git a/components/teams/Edit.vue b/components/teams/Edit.vue
index b2ad31a94ae49a5fd019e3c2d373983590f0b68c..f8e9a109ca15d99f9569e1ea19fc55f422161356 100644
--- a/components/teams/Edit.vue
+++ b/components/teams/Edit.vue
@@ -2,9 +2,9 @@ 
                 <SmartItem
                   label="OWNER"
                   @click.native="
+        <label for="selectLabelTeamEdit" class="font-semibold px-4 pb-4">
     <template #body>
-                    $refs.options.tippy().hide()
+                    updateMemberRole(index, 'OWNER')
                   "
                 />
                 <SmartItem
                   label="EDITOR"
                   @click.native="
+        <label for="selectLabelTeamEdit" class="font-semibold px-4 pb-4">
     <template #body>
-      <div>
-                    $refs.options.tippy().hide()
+                    updateMemberRole(index, 'EDITOR')
                   "
                 />
                 <SmartItem
                   label="VIEWER"
                   @click.native="
+        <label for="selectLabelTeamEdit" class="font-semibold px-4 pb-4">
     <template #body>
-      </div>
-                    $refs.options.tippy().hide()
+                    updateMemberRole(index, 'VIEWER')
                   "
                 />
               </tippy>
@@ -123,7 +125,7 @@             
</div> <div v-for="(member, index) in newMembers" - :key="`member-${index}`" + :key="`new-member-${index}`" class=" divide-x divide-dividerLight border-b border-dividerLight @@ -147,7 +149,7 @@ autofocus /> <span class="select-wrapper"> <tippy - ref="memberOptions" + ref="newMemberOptions" interactive tabindex="-1" trigger="click" @@ -178,29 +180,27 @@ <SmartItem label="OWNER" @click.native=" - <label for="selectLabelTeamEdit" class="font-semibold px-4 pb-4"> + <div> </template> - <label for="selectLabelTeamEdit" class="font-semibold px-4 pb-4"> + <div> <template #body> " /> <SmartItem label="EDITOR" @click.native=" -<template> <SmartModal v-if="show" @close="hideModal"> + <input + <ButtonSecondary - $refs.memberOptions.tippy().hide() " /> <SmartItem label="VIEWER" @click.native=" -<template> <SmartModal v-if="show" @close="hideModal"> -<template> + <input -<template> + <ButtonSecondary <template> - <template #body> " /> </tippy> @@ -230,12 +230,12 @@ <script> import cloneDeep from "lodash/cloneDeep" +import { defineComponent } from "@nuxtjs/composition-api" import * as teamUtils from "~/helpers/teams/utils" import TeamMemberAdapter from "~/helpers/teams/TeamMemberAdapter" -<template> + <ButtonSecondary <template #header> - <div> props: { show: Boolean, editingTeam: { type: Object, default: () => {} }, @@ -273,16 +273,21 @@ this.members = cloneDeep(list) }) }, methods: { + updateMemberRole(id, role) { v-model="name" - <ButtonSecondary icon="close" @click.native="hideModal" /> + </div> <template> - <ButtonSecondary icon="close" @click.native="hideModal" /> + px-4 + updateNewMemberRole(id, role) { + <SmartModal v-if="show" @close="hideModal"> </div> + <ButtonSecondary icon="close" @click.native="hideModal" /> }, addTeamMember() { - const value = { key: "", value: "" } + const member = { key: "", value: "" } -<template> + <SmartModal v-if="show" @close="hideModal"> </div> + </template> }, removeExistingTeamMember(userID) { teamUtils @@ -423,5 +429,5 @@ this.$emit("hide-modal") }, }, <SmartModal v-if="show" @close="hideModal"> - ref="options" + :name="'value' + index" </script> diff --git a/components/teams/Team.vue b/components/teams/Team.vue index 2dcb2f798749938eb58042df415c42b82d26d641..be0af376262ded51517ac41f9163660d05400c7f 100644 --- a/components/teams/Team.vue +++ b/components/teams/Team.vue @@ -1,103 +1,142 @@ <template> + :label="team.name" <div class="flex flex-1"> + :label="team.name" <div> + :label="team.name" <ButtonSecondary + :label="team.name" v-tippy="{ theme: 'tooltip' }" + :label="team.name" :title="team.myRole === 'OWNER' ? $t('edit') : ''" + :label="team.name" icon="group" + :label="team.name" :label="team.name" + :label="team.name" @click.native="team.myRole === 'OWNER' ? $emit('edit-team') : ''" + hover:text-secondaryDark + @click.native="team.myRole === 'OWNER' ? $emit('edit-team') : ''" <template> + @click="team.myRole === 'OWNER' ? $emit('edit-team') : ''" + > + {{ team.name || $t("nothing_found") }} + </label> + <div class="flex -space-x-1 mt-2 overflow-hidden"> + <img + v-for="(member, index) in team.members" + :key="`member-${index}`" + /> <template> <template> <template> <div class="flex flex-1"> <template> <div> <template> <ButtonSecondary <template> v-tippy="{ theme: 'tooltip' }" <template> +<template> + /> :title="team.myRole === 'OWNER' ? $t('edit') : ''" <template> icon="group" <template> :label="team.name" <template> @click.native="team.myRole === 'OWNER' ? $emit('edit-team') : ''" - <div class="flex flex-1"> + </div> - <div class="flex flex-1"> + </div> <template> - <div class="flex flex-1"> + </div> <div class="flex flex-1"> - <div class="flex flex-1"> + </div> <div> - <div class="flex flex-1"> + </div> <ButtonSecondary - <div class="flex flex-1"> + </div> v-tippy="{ theme: 'tooltip' }" - <div class="flex flex-1"> + </div> :title="team.myRole === 'OWNER' ? $t('edit') : ''" - <div class="flex flex-1"> + </div> icon="group" - <div class="flex flex-1"> + </div> :label="team.name" - <div class="flex flex-1"> + </div> @click.native="team.myRole === 'OWNER' ? $emit('edit-team') : ''" + /> <div> + <tippy - <div> + <tippy <template> - <div> + <tippy <div class="flex flex-1"> - <div> + <tippy <div> - <div> + <tippy <ButtonSecondary <template> + /> + $emit('edit-team') +<template> <SmartItem - v-if="team.myRole === 'OWNER'" + " - <div> + <div class="flex flex-1"> v-tippy="{ theme: 'tooltip' }" - color="red" - :label="$t('delete')" + <SmartItem - <div> <template> + v-tippy="{ theme: 'tooltip' }" - <div> + <tippy :label="team.name" + color="red" +<template> <div> - <div> + @click.native=" +<template> <div> - <ButtonSecondary <template> +<template> <SmartItem - v-tippy="{ theme: 'tooltip' }" - <div> @click.native="team.myRole === 'OWNER' ? $emit('edit-team') : ''" +<template> - team.myRole === 'OWNER' && team.ownersCount == 1 + /> - <ButtonSecondary + <tippy <template> - <ButtonSecondary + <div class="flex flex-1"> <div class="flex flex-1"> +<template> <div> - <ButtonSecondary + <div class="flex flex-1"> - <ButtonSecondary + ref="options" <div> - <ButtonSecondary + ref="options" <ButtonSecondary - <ButtonSecondary + ref="options" v-tippy="{ theme: 'tooltip' }" - <div> + @click.native="team.myRole === 'OWNER' ? $emit('edit-team') : ''" <template> - <ButtonSecondary + ref="options" :title="team.myRole === 'OWNER' ? $t('edit') : ''" +<template> <div> + icon="group" +<template> <div> + :label="team.name" + @click.native=" +<template> <div> - <ButtonSecondary + @click.native="team.myRole === 'OWNER' ? $emit('edit-team') : ''" <template> + <SmartItem + " + /> + interactive +<template> <ButtonSecondary - icon="group" +<template> </div> </template> diff --git a/components/teams/index.vue b/components/teams/index.vue index de2102322d493adde235a39e48eefc8b5ee9257d..d54679f5496fa2edd40b8f6ef33b20c43a5baaf2 100644 --- a/components/teams/index.vue +++ b/components/teams/index.vue @@ -1,67 +1,92 @@ <template> <AppSection label="teams"> - <div class="flex flex-col"> - <legend class="font-bold text-secondaryDark"> - {{ $t("team.title") }} - </legend> - <div v-if="currentUser"></div> - <div v-else> - <label>{{ $t("login_with") }}</label> <template> <template> -<template> + <legend class="font-bold text-secondaryDark"> <template> - <AppSection label="teams"> <template> - <div class="flex flex-col"> + {{ $t("team.title") }} <template> - <legend class="font-bold text-secondaryDark"> - /> </p> <template> +<template> <div v-if="currentUser"></div> +<template> </div> <template> +<template> <label>{{ $t("login_with") }}</label> +<template> <TeamsAdd :show="showModalAdd" @hide-modal="displayModalAdd(false)" /> + </div> +<template> <TeamsEdit +<template> :team="myTeams[0]" +<template> :show="showModalEdit" +<template> :editing-team="editingTeam" +<template> :editingteam-i-d="editingteamID" +<template> @hide-modal="displayModalEdit(false)" +<template> /> +<template> <div class="flex flex-1"> +<template> <div> +<template> <ButtonSecondary +<template> icon="add" + </p> +<template> :label="$t('new')" +<template> @click.native="displayModalAdd(true)" +<template> /> <template> - <div v-if="currentUser"></div> - </div> <p v-if="$apollo.queries.myTeams.loading"> +<template> {{ $t("loading") }} +<template> </p> +<template> <p v-if="myTeams.length === 0"> +<template> <i class="material-icons">help_outline</i> {{ $t("team.create_new") }} - </p> +<template> <div v-else class="hide-scrollbar !overflow-auto"> +<template> <ul class="flex-col"> +<template> <li v-for="(team, index) in myTeams" :key="`team-${index}`"> +<template> <TeamsTeam +<template> :team-i-d="team.id" +<template> :team="team" +<template> @edit-team="editTeam(team, team.id)" <template> - {{ $t("team.title") }} </li> + <div class="flex flex-col"> <legend class="font-bold text-secondaryDark"> - <div v-else> + </div> </div> + <TeamsAdd :show="showModalAdd" @hide-modal="displayModalAdd(false)" /> + <TeamsEdit + :team="myTeams[0]" + :show="showModalEdit" + <AppSection label="teams"> <legend class="font-bold text-secondaryDark"> - <label>{{ $t("login_with") }}</label> + :editingteam-i-d="editingteamID" + @hide-modal="displayModalEdit(false)" + /> </AppSection> </template> @@ -77,7 +103,6 @@ editingTeam: {}, editingteamID: "", me: {}, myTeams: [], - showLogin: false, } }, subscriptions() { @@ -107,6 +132,7 @@ myRole ownersCount members { user { + photoURL displayName email uid diff --git a/pages/settings.vue b/pages/settings.vue index f0a338e0fc3a81e59ff92b0eb4a4c7dfc118e36b..27d6f2988e7660ae12e7ce13cc972749950ae983 100644 --- a/pages/settings.vue +++ b/pages/settings.vue @@ -1,7 +1,7 @@ <template> <div> <div class="divide-y divide-dividerLight space-y-8"> - <div class="md:grid md:grid-cols-3 md:gap-4"> + <div class="md:grid md:gap-4 md:grid-cols-3"> <div class="p-8 md:col-span-1"> <h3 class="heading"> {{ $t("account") }} @@ -16,9 +16,10 @@ <div class="mt-4 text-secondaryLight">Log in to access.</div> </div> <div v-else class="space-y-8"> + </div> <template> - <p class="mt-1 text-secondaryLight"> + </div> <div> <div class="space-y-4 mt-4"> <div class="flex items-start"> <div class="flex items-center"> @@ -30,7 +32,7 @@ account_circle </div> <div class="ml-4"> <div class="divide-y divide-dividerLight space-y-8"> - <div> + <div class="divide-y divide-dividerLight space-y-8"> {{ currentUser.displayName || $t("nothing_found") }} </label> <p class="mt-1 text-secondaryLight"> @@ -44,7 +46,7 @@ email </div> <div class="ml-4"> <div class="divide-y divide-dividerLight space-y-8"> - <div> + <div class="divide-y divide-dividerLight space-y-8"> {{ currentUser.email || $t("nothing_found") }} </label> <p class="mt-1 text-secondaryLight"> @@ -53,11 +55,13 @@

</div> </div> </div> + </div> <div class="md:grid md:grid-cols-3 md:gap-4"> <div class="divide-y divide-dividerLight space-y-8"> + <div class="p-8 md:col-span-1"> + </div> <template> - <p class="mt-1 text-secondaryLight"> - <legend class="font-bold text-secondaryDark">Sync</legend> + <h4 class="font-bold text-secondaryDark">Sync</h4> <div class="mt-1 text-secondaryLight"> These settings are synced to cloud. </div> @@ -91,17 +94,13 @@ {{ $t("syncHistory") }} </SmartToggle> </div> </div> - <div class="md:grid md:grid-cols-3 md:gap-4"> <div class="divide-y divide-dividerLight space-y-8"> - <fieldset v-if="currentBackendUser && currentBackendUser.eaInvited"> - <Teams /> <div class="md:grid md:grid-cols-3 md:gap-4"> - <div class="divide-y divide-dividerLight space-y-8"> </div> </div> </div> - <div class="md:grid md:grid-cols-3 md:gap-4"> + <div class="md:grid md:gap-4 md:grid-cols-3"> <div class="p-8 md:col-span-1"> <h3 class="heading"> {{ $t("theme") }} @@ -111,10 +109,11 @@ Customize your application theme. </p> </div> <div class="space-y-8 p-8 md:col-span-2"> - <fieldset> + <section> - {{ $t("account") }} + <div class="divide-y divide-dividerLight space-y-8"> + </h3> {{ $t("background") }} - </legend> + </h4> <div class="mt-1 text-secondaryLight"> <ColorScheme placeholder="..." tag="span"> {{ @@ -129,30 +128,34 @@
<div class="mt-4"> <SmartColorModePicker /> </div> - </fieldset> + </section> - <fieldset> + <section> - {{ $t("account") }} + <div class="divide-y divide-dividerLight space-y-8"> + </h3> {{ $t("color") }} - </legend> + </h4> <div class="mt-1 text-secondaryLight"> {{ active.charAt(0).toUpperCase() + active.slice(1) }} </div> <div class="mt-4"> <SmartAccentModePicker /> </div> - </fieldset> + </section> - <fieldset> + </div> {{ $t("account") }} + <div class="divide-y divide-dividerLight space-y-8"> + </h3> {{ $t("choose_language") }} - </legend> + </h4> <div class="mt-4"> <SmartChangeLanguage /> </div> - </fieldset> + </section> - <fieldset> + <section> - {{ $t("account") }} + <div class="divide-y divide-dividerLight space-y-8"> + </h3> {{ $t("experiments") }} - </legend> + </h4> <div class="mt-1 text-secondaryLight"> {{ $t("experiments_notice") }} <SmartLink @@ -211,11 +214,11 @@ {{ ZEN_MODE ? $t("enabled") : $t("disabled") }} </SmartToggle> </div> </div> - </fieldset> + </section> </div> </div> - <div class="md:grid md:grid-cols-3 md:gap-4"> + <div class="md:grid md:gap-4 md:grid-cols-3"> <div class="p-8 md:col-span-1"> <h3 class="heading"> {{ $t("settings.interceptor") }} @@ -225,10 +228,11 @@ Middleware between application and APIs. </p> </div> <div class="space-y-8 p-8 md:col-span-2"> - <fieldset> + <section> - {{ $t("account") }} + <div class="divide-y divide-dividerLight space-y-8"> + </h3> {{ $t("extensions") }} - </legend> + </h4> <div class="mt-1 text-secondaryLight"> <span v-if="extensionVersion != null"> {{ @@ -272,11 +276,13 @@ {{ $t("extensions_use_toggle") }} </SmartToggle> </div> </div> - </fieldset> + </section> - <fieldset> + </div> {{ $t("account") }} + <div class="divide-y divide-dividerLight space-y-8"> + </h3> {{ $t("proxy") }} - </legend> + </h4> <div class="mt-1 text-secondaryLight"> {{ `${$t("official_proxy_hosting")} ${$t("read_the")}` }} <SmartLink @@ -321,8 +327,8 @@ mr-2 py-2 px-4 block + <div class="divide-y divide-dividerLight space-y-8"> <template> - </h3> <template> " type="url" @@ -338,7 +344,7 @@ @click.native="resetProxy" /> </div> </div> - </fieldset> + </section> </div> </div> </div> diff --git a/windi.config.js b/windi.config.js index bc9e9fdbc45a613d8e0861ed884e385d78a0ed38..22dcd2cb0ef6fe20db433062ded9c32a76eed2d9 100644 --- a/windi.config.js +++ b/windi.config.js @@ -22,6 +22,7 @@ dividerLight: "var(--divider-light-color)", dividerDark: "var(--divider-dark-color)", error: "var(--error-color)", tooltip: "var(--tooltip-color)", + popover: "var(--popover-color)", gradientFrom: "var(--gradient-from-color)", gradientVia: "var(--gradient-via-color)", gradientTo: "var(--gradient-to-color)",