Styled select input (#431)

Styled select input

Co-authored-by: Liyas Thomas <liyasthomas@gmail.com>
This commit is contained in:
Liyas Thomas
2019-12-15 05:50:47 +05:30
committed by GitHub
4 changed files with 153 additions and 95 deletions

View File

@@ -550,11 +550,31 @@ code {
border-radius: 8px; border-radius: 8px;
} }
.select-wrapper {
position: relative;
&:after {
display: inline-block;
position: absolute;
pointer-events: none;
content: "\e313";
font-family: "Material Icons";
top: 14px;
right: 14px;
}
}
select { select {
height: 37px; height: 37px;
line-height: 37px;
background-color: var(--bg-dark-color); background-color: var(--bg-dark-color);
cursor: pointer; cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
&::-ms-expand {
display: none;
}
} }
option { option {

View File

@@ -26,35 +26,47 @@
:placeholder="request.name" :placeholder="request.name"
/> />
<label for="selectCollection">Collection</label> <label for="selectCollection">Collection</label>
<select <span class="select-wrapper">
type="text" <select
id="selectCollection" type="text"
v-model="requestUpdateData.collectionIndex" id="selectCollection"
> v-model="requestUpdateData.collectionIndex"
<option :key="undefined" :value="undefined" hidden disabled selected
>Current Collection</option
> >
<option <option
v-for="(collection, index) in $store.state.postwoman.collections" :key="undefined"
:key="index" :value="undefined"
:value="index" hidden
>{{ collection.name }}</option disabled
> selected
</select> >Current Collection</option
>
<option
v-for="(collection, index) in $store.state.postwoman
.collections"
:key="index"
:value="index"
>
{{ collection.name }}
</option>
</select>
</span>
<label for="selectFolder">Folder</label> <label for="selectFolder">Folder</label>
<select <span class="select-wrapper">
type="text" <select
id="selectFolder" type="text"
v-model="requestUpdateData.folderIndex" id="selectFolder"
> v-model="requestUpdateData.folderIndex"
<option :key="undefined" :value="undefined">/</option>
<option
v-for="(folder, index) in folders"
:key="index"
:value="index"
>{{ folder.name }}</option
> >
</select> <option :key="undefined" :value="undefined">/</option>
<option
v-for="(folder, index) in folders"
:key="index"
:value="index"
>
{{ folder.name }}
</option>
</select>
</span>
</li> </li>
</ul> </ul>
</div> </div>

View File

@@ -26,49 +26,64 @@
@keyup.enter="saveRequestAs" @keyup.enter="saveRequestAs"
/> />
<label for="selectCollection">Collection</label> <label for="selectCollection">Collection</label>
<select <span class="select-wrapper">
type="text" <select
id="selectCollection" type="text"
v-model="requestData.collectionIndex" id="selectCollection"
> v-model="requestData.collectionIndex"
<option :key="undefined" :value="undefined" hidden disabled selected
>Select a Collection</option
> >
<option <option
v-for="(collection, index) in $store.state.postwoman.collections" :key="undefined"
:key="index" :value="undefined"
:value="index" hidden
>{{ collection.name }}</option disabled
> selected
</select> >Select a Collection</option
>
<option
v-for="(collection, index) in $store.state.postwoman
.collections"
:key="index"
:value="index"
>
{{ collection.name }}
</option>
</select>
</span>
<label for="selectFolder">Folder</label> <label for="selectFolder">Folder</label>
<select <span class="select-wrapper">
type="text" <select
id="selectFolder" type="text"
v-model="requestData.folderIndex" id="selectFolder"
> v-model="requestData.folderIndex"
<option :key="undefined" :value="undefined">/</option>
<option
v-for="(folder, index) in folders"
:key="index"
:value="index"
>{{ folder.name }}</option
> >
</select> <option :key="undefined" :value="undefined">/</option>
<option
v-for="(folder, index) in folders"
:key="index"
:value="index"
>
{{ folder.name }}
</option>
</select>
</span>
<label for="selectRequest">Request</label> <label for="selectRequest">Request</label>
<select <span class="select-wrapper">
type="text" <select
id="selectRequest" type="text"
v-model="requestData.requestIndex" id="selectRequest"
> v-model="requestData.requestIndex"
<option :key="undefined" :value="undefined">/</option>
<option
v-for="(folder, index) in requests"
:key="index"
:value="index"
>{{ folder.name }}</option
> >
</select> <option :key="undefined" :value="undefined">/</option>
<option
v-for="(folder, index) in requests"
:key="index"
:value="index"
>
{{ folder.name }}
</option>
</select>
</span>
</li> </li>
</ul> </ul>
</div> </div>
@@ -121,11 +136,13 @@ export default {
const userSelectedAnyCollection = const userSelectedAnyCollection =
this.$data.requestData.collectionIndex !== undefined; this.$data.requestData.collectionIndex !== undefined;
if (!userSelectedAnyCollection) return []; if (!userSelectedAnyCollection) return [];
const noCollectionAvailable = const noCollectionAvailable =
this.$store.state.postwoman.collections[this.$data.requestData.collectionIndex] !== undefined; this.$store.state.postwoman.collections[
this.$data.requestData.collectionIndex
] !== undefined;
if (!noCollectionAvailable) return []; if (!noCollectionAvailable) return [];
return this.$store.state.postwoman.collections[ return this.$store.state.postwoman.collections[
this.$data.requestData.collectionIndex this.$data.requestData.collectionIndex
].folders; ].folders;
@@ -148,8 +165,10 @@ export default {
const collection = this.$store.state.postwoman.collections[ const collection = this.$store.state.postwoman.collections[
this.$data.requestData.collectionIndex this.$data.requestData.collectionIndex
]; ];
const noCollectionAvailable = const noCollectionAvailable =
this.$store.state.postwoman.collections[this.$data.requestData.collectionIndex] !== undefined; this.$store.state.postwoman.collections[
this.$data.requestData.collectionIndex
] !== undefined;
if (!noCollectionAvailable) return []; if (!noCollectionAvailable) return [];
const requests = collection.requests; const requests = collection.requests;

View File

@@ -44,17 +44,19 @@
<ul> <ul>
<li> <li>
<label for="method">{{ $t("method") }}</label> <label for="method">{{ $t("method") }}</label>
<select id="method" v-model="method" @change="methodChange"> <span class="select-wrapper">
<option value="GET">GET</option> <select id="method" v-model="method" @change="methodChange">
<option value="HEAD">HEAD</option> <option value="GET">GET</option>
<option value="POST">POST</option> <option value="HEAD">HEAD</option>
<option value="PUT">PUT</option> <option value="POST">POST</option>
<option value="DELETE">DELETE</option> <option value="PUT">PUT</option>
<option value="CONNECT">CONNECT</option> <option value="DELETE">DELETE</option>
<option value="OPTIONS">OPTIONS</option> <option value="CONNECT">CONNECT</option>
<option value="TRACE">TRACE</option> <option value="OPTIONS">OPTIONS</option>
<option value="PATCH">PATCH</option> <option value="TRACE">TRACE</option>
</select> <option value="PATCH">PATCH</option>
</select>
</span>
</li> </li>
<li> <li>
<label for="url">{{ $t("url") }}</label> <label for="url">{{ $t("url") }}</label>
@@ -330,11 +332,13 @@
</button> </button>
</div> </div>
</div> </div>
<select id="auth" v-model="auth"> <span class="select-wrapper">
<option>None</option> <select id="auth" v-model="auth">
<option>Basic</option> <option>None</option>
<option>Bearer Token</option> <option>Basic</option>
</select> <option>Bearer Token</option>
</select>
</span>
</li> </li>
</ul> </ul>
<ul v-if="auth === 'Basic'"> <ul v-if="auth === 'Basic'">
@@ -757,11 +761,13 @@
<ul> <ul>
<li> <li>
<label for="requestType">{{ $t("request_type") }}</label> <label for="requestType">{{ $t("request_type") }}</label>
<select id="requestType" v-model="requestType"> <span class="select-wrapper">
<option>JavaScript XHR</option> <select id="requestType" v-model="requestType">
<option>Fetch</option> <option>JavaScript XHR</option>
<option>cURL</option> <option>Fetch</option>
</select> <option>cURL</option>
</select>
</span>
</li> </li>
</ul> </ul>
<ul> <ul>
@@ -1488,8 +1494,9 @@ export default {
}, },
methods: { methods: {
checkCollections() { checkCollections() {
const checkCollectionAvailability = const checkCollectionAvailability =
this.$store.state.postwoman.collections && this.$store.state.postwoman.collections.length > 0 ; this.$store.state.postwoman.collections &&
this.$store.state.postwoman.collections.length > 0;
return checkCollectionAvailability; return checkCollectionAvailability;
}, },
scrollInto(view) { scrollInto(view) {
@@ -2100,7 +2107,7 @@ export default {
}); });
return; return;
} }
this.editRequest = { this.editRequest = {
url: this.url, url: this.url,
path: this.path, path: this.path,