Skip to content

Commit

Permalink
fix: network list action buttons opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
peronczyk committed Jul 31, 2024
1 parent 2c4997b commit 4b89dd7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 20 deletions.
26 changes: 18 additions & 8 deletions src/popup/components/NetworkRow.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<RadioButton
v-slot="{ checked }"
:value="isActive"
class="network-row"
type="radio"
Expand All @@ -9,6 +10,7 @@
<div class="name-and-actions">
<p
class="name"
:class="{ 'label-part-unchecked': !checked }"
data-cy="network-name"
v-text="network.name"
/>
Expand All @@ -26,15 +28,17 @@
<BtnIcon
size="sm"
data-cy="network-delete"
icon-variant="danger"
dimmed
:icon="TrashIcon"
@click="$emit('deleteNetwork', network.name);"
/>
</div>
</div>

<table class="network-details">
<table
class="network-details"
:class="{ 'label-part-unchecked': !checked }"
>
<tbody>
<tr
v-for="(protocolSettings, protocol) in networkSettingsToDisplay"
Expand All @@ -51,7 +55,7 @@
<script lang="ts">
import { PropType, computed, defineComponent } from 'vue';
import type { INetwork, Protocol } from '@/types';
import type { INetwork, NetworkProtocolsSettings, Protocol } from '@/types';
import { NETWORK_TYPE_CUSTOM } from '@/constants';
import { ROUTE_NETWORK_EDIT } from '@/popup/router/routeNames';
import { ProtocolAdapterFactory } from '@/lib/ProtocolAdapterFactory';
Expand Down Expand Up @@ -79,11 +83,13 @@ export default defineComponent({
setup(props) {
// Filter out the network protocol settings that has no `nodeUrl` default property
const networkSettingsToDisplay = computed(
() => Object.fromEntries((Object.keys(props.network.protocols) as Protocol[])
.map((protocol) => {
const settings = props.network.protocols[protocol];
return settings.nodeUrl ? [protocol, settings] : [];
})),
(): NetworkProtocolsSettings => Object.fromEntries(
(Object.keys(props.network.protocols) as (keyof typeof props.network.protocols)[])
.map((protocol) => {
const settings = props.network.protocols[protocol];
return settings.nodeUrl ? [protocol, settings] : [];
}),
),
);
function getProtocolName(protocol: Protocol) {
Expand All @@ -109,6 +115,10 @@ export default defineComponent({
.network-row {
margin-bottom: 12px;
.label-part-unchecked {
opacity: 0.5;
}
.name-and-actions {
display: flex;
justify-content: space-between;
Expand Down
11 changes: 9 additions & 2 deletions src/popup/components/RadioButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:class="{
disabled,
checked: value,
'has-label-effect': hasLabelEffect,
}"
>
<span class="radio-dot">
Expand All @@ -17,7 +18,7 @@
</span>

<span class="radio-holder">
<slot />
<slot :checked="value">{{ label }}</slot>
</span>
</label>
</template>
Expand All @@ -30,6 +31,9 @@ export default defineComponent({
value: { type: [String, Number, Boolean], default: '' },
type: { type: String as PropType<'checkbox' | 'radio'>, default: 'checkbox' },
name: { type: String, default: '' },
label: { type: String, default: '' },
/** Makes the unchecked input's label semi transparent */
hasLabelEffect: Boolean,
disabled: Boolean,
},
});
Expand All @@ -48,9 +52,12 @@ export default defineComponent({
display: flex;
cursor: pointer;
user-select: none;
opacity: 0.5;
transition: opacity 0.15s;
&.has-label-effect {
opacity: 0.5;
}
&.checked {
--radio-dot-scale: 1;
Expand Down
6 changes: 3 additions & 3 deletions src/popup/components/TransactionSpeedPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
v-for="(feeItem, index) in feeList"
:key="index"
:value="modelValue === index"
:label="feeItem.label"
has-label-effect
@input="handleInput(index)"
>
<p v-text="feeItem.label" />
</RadioButton>
/>
</div>
<p
v-if="UNFINISHED_FEATURES"
Expand Down
1 change: 1 addition & 0 deletions src/popup/pages/CurrencySettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
:value="currentCurrencyCode === code"
:class="{ active: currentCurrencyCode === code }"
class="currency"
has-label-effect
@input="setCurrentCurrency(code)"
>
<div class="row">
Expand Down
19 changes: 12 additions & 7 deletions src/popup/pages/LanguageSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
v-for="{ code, name } in languageList"
:key="code"
:value="activeLanguage === code"
class="language"
:class="{ active: activeLanguage === code }"
class="language"
has-label-effect
@input="switchLanguage(code)"
>
{{ name }}
Expand All @@ -27,20 +28,24 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { IonPage, IonContent } from '@ionic/vue';
import { languages } from '@/popup/plugins/i18n';
import { languages, SupportedLanguage } from '@/popup/plugins/i18n';
import { useLanguages } from '@/composables';
import RadioButton from '../components/RadioButton.vue';
const languageList = Object.entries(languages)
.map(([code, { name }]) => ({ code, name }))
.sort();
export default defineComponent({
components: { RadioButton, IonPage, IonContent },
components: {
RadioButton,
IonPage,
IonContent,
},
setup() {
const { activeLanguage, switchLanguage } = useLanguages();
const languageList = Object.entries(languages)
.map(([code, { name }]) => ({ code, name } as { code: SupportedLanguage; name: string }))
.sort();
return {
languageList,
activeLanguage,
Expand Down
1 change: 1 addition & 0 deletions src/popup/pages/SecureLoginSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
:disabled="!isSecureLoginEnabled"
:class="{ active: secureLoginTimeout === ms }"
class="timeout"
has-label-effect
@input="setSecureLoginTimeout(ms)"
>
<div class="row">
Expand Down

0 comments on commit 4b89dd7

Please sign in to comment.