Skip to content

Commit 85a49c4

Browse files
committed
small tweaks and ui improvments
1 parent 7ecc535 commit 85a49c4

26 files changed

+364
-163
lines changed

src/App.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ export default defineComponent({
176176
@include flex-full-height;
177177
@include ios-flex;
178178
179-
// TODO: Find another alternative.
180-
// overflow: hidden; // To prevent horizontal scrollbars during panel sliding
179+
overflow: hidden; // To prevent horizontal scrollbars during panel sliding
181180
touch-action: pan-y;
182181
183182
/* Default: >= 1500px */

src/components/Tour.vue

Lines changed: 107 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@
8282
@click="goToPrevStep()"
8383
style="transform: rotate(180deg)"
8484
>
85-
<CaretRightIcon />
85+
<CaretRightSmallIcon />
8686
</button>
8787
<button
8888
class="next"
8989
:class="{ loading: isLoading }"
9090
:disabled="disableNextStep"
9191
@click="!isLoading && goToNextStep()"
9292
>
93-
<CaretRightIcon v-if="!isLoading" />
93+
<CaretRightSmallIcon v-if="!isLoading" />
9494
<CircleSpinner v-else class="circle-spinner" />
9595
</button>
9696
</div>
@@ -102,7 +102,7 @@
102102
import { useAccountStore } from '@/stores/Account';
103103
import { useNetworkStore } from '@/stores/Network';
104104
import { useTransactionsStore } from '@/stores/Transactions';
105-
import { CircleSpinner } from '@nimiq/vue-components';
105+
import { CircleSpinner, CaretRightSmallIcon } from '@nimiq/vue-components';
106106
import {
107107
computed,
108108
defineComponent,
@@ -121,7 +121,6 @@ import {
121121
MountedReturnFn, TourBroadcast, TourStep,
122122
TourStepIndex,
123123
} from '../lib/tour';
124-
import CaretRightIcon from './icons/CaretRightIcon.vue';
125124
import PartyConfettiIcon from './icons/PartyConfettiIcon.vue';
126125
import TourPreviousLeftArrowIcon from './icons/TourPreviousLeftArrowIcon.vue';
127126
@@ -137,8 +136,7 @@ export default defineComponent({
137136
const { state: $network } = useNetworkStore();
138137
const disconnected = computed(() => $network.consensus !== 'established');
139138
140-
const { state: tourStore, setTour, activeAccountInfo } = useAccountStore();
141-
activeAccountInfo.value!.fileExported = false;
139+
const { state: tourStore, setTour } = useAccountStore();
142140
143141
let tour: VueTour.Tour | null = null;
144142
const tourOptions: any = {
@@ -217,7 +215,10 @@ export default defineComponent({
217215
isLoading.value = false;
218216
219217
window.addEventListener('keyup', _onKeyDown);
220-
window.addEventListener('click', _userClicked());
218+
setTimeout(() => {
219+
window.addEventListener('click', _userClicked());
220+
}, 100); // avoid click event to be triggered by the setting button
221+
221222
// window.addEventListener('resize', _OnResize(_OnResizeEnd)); TODO
222223
223224
const app = document.querySelector('#app');
@@ -236,22 +237,26 @@ export default defineComponent({
236237
// Dont allow user to interact with the page while it is loading
237238
// But allow to end it
238239
watch([isLoading, disconnected], async () => {
239-
const app = document.querySelector('#app main') as HTMLDivElement;
240-
241-
if (isLoading.value || disconnected.value) {
242-
app.setAttribute('data-non-interactable', '');
243-
} else {
244-
app.removeAttribute('data-non-interactable');
245-
}
246-
247-
// FIXME we should wait until the button is rendered and the we could
240+
// TODO Avoid interaction with any of the elements when loading except tour elements (bar, manager and tooltip)
241+
// const elements = Object.values(WalletHTMLElements).filter((e) => e);
242+
// if (isLoading.value || disconnected.value) {
243+
// elements.forEach((element) => {
244+
// const el = document.querySelector(element);
245+
// if (!el) return;
246+
// el.setAttribute('data-non-interactable', 'loading');
247+
// });
248+
// } else {
249+
// elements.forEach((element) => {
250+
// const el = document.querySelector(element);
251+
// if (!el) return;
252+
// el.removeAttribute('data-non-interactable');
253+
// });
254+
// }
255+
256+
// FIXME we should wait until the buttons are rendered and the we could
248257
// execute _toggleDisabledButtons but it is kind of random the amount of time
249-
// it takes to render the button. I don't know how to fix it.
250-
251-
// Ensure that we disabled 'Receive Free NIM' button
252-
await sleep(500); // TODO
253-
// TODO Remove this code for the network, find other way
254-
// steps = Object.values(getTour(tourStore.tour?.name, context));
258+
// it takes to render the button. I don't know how to fix it. Waiting 500ms works.
259+
await sleep(500);
255260
_toggleDisabledButtons(steps[currentStep.value]?.ui.disabledButtons, true);
256261
});
257262
@@ -274,7 +279,6 @@ export default defineComponent({
274279
const { path: currentPath, ui: currentUI } = steps[currentStepIndex]!;
275280
const { path: futurePath, ui: futureUI, lifecycle: futureLifecycle } = steps[futureStepIndex]!;
276281
277-
isLoading.value = true;
278282
tour!.stop();
279283
280284
await sleep(500);
@@ -294,6 +298,7 @@ export default defineComponent({
294298
_toggleDisabledButtons(currentUI.disabledButtons, false);
295299
_toggleDisabledButtons(futureUI.disabledButtons, true);
296300
_addAttributes(futureUI, futureStepIndex);
301+
await context.root.$nextTick();
297302
298303
if (futurePath !== currentPath) {
299304
await sleep(500);
@@ -302,14 +307,14 @@ export default defineComponent({
302307
_removeAttributes(currentStepIndex);
303308
304309
tour!.start(futureStepIndex.toString());
310+
await context.root.$nextTick();
305311
306312
// FIXME Instead of doing tour!.end and tour!.start, we could also use .nextStep() or previsousStep()
307313
// The problem with this solution is that some animations glitch the UI so it needs further
308314
// investigation
309315
// goingForward ? tour!.nextStep() : tour!.previousStep();
310316
311317
// mounted
312-
isLoading.value = false;
313318
disableNextStep.value = futureStepIndex >= nSteps.value - 1 || !!futureUI.isNextStepDisabled;
314319
315320
unmounted = await futureLifecycle?.mounted?.({
@@ -338,6 +343,17 @@ export default defineComponent({
338343
context.root.$on('nimiq-tour-event', (data: TourBroadcast) => {
339344
if (data.type === 'end-tour') endTour();
340345
});
346+
context.root.$on('nimiq-tour-event', (data: TourBroadcast) => {
347+
if (data.type === 'clicked-outside-tour') {
348+
const tourManager = document.querySelector('.tour-control-bar');
349+
if (tourManager) {
350+
tourManager.classList.add('flash');
351+
setTimeout(() => {
352+
tourManager.classList.remove('flash');
353+
}, 400);
354+
}
355+
}
356+
});
341357
}
342358
343359
function _userClicked() {
@@ -382,12 +398,17 @@ export default defineComponent({
382398
}
383399
}
384400
401+
function _onScrollLockedElement(e: Event, el: Element) {
402+
e.preventDefault();
403+
el.scrollTop = 0;
404+
}
385405
function _addAttributes(
386406
uiConfig: TourStep['ui'],
387407
stepIndex: TourStepIndex,
388408
) {
389409
const fadedElements = uiConfig.fadedElements || [];
390410
const disabledElements = uiConfig.disabledElements || [];
411+
const scrollLockedElements = uiConfig.scrollLockedElements || [];
391412
392413
disabledElements.filter((e) => e).forEach((element) => {
393414
const el = document.querySelector(element);
@@ -401,20 +422,33 @@ export default defineComponent({
401422
el.setAttribute('data-opacified', stepIndex.toString());
402423
el.setAttribute('data-non-interactable', stepIndex.toString());
403424
});
425+
426+
scrollLockedElements.filter((e) => e).forEach((element) => {
427+
const el = document.querySelector(element);
428+
if (!el) return;
429+
el.setAttribute('data-scroll-locked', stepIndex.toString());
430+
// Avoid scrolling when tooltip is instantiated
431+
el.addEventListener('scroll', (e) => _onScrollLockedElement(e, el));
432+
el.scrollTop = 0;
433+
});
404434
}
405435
406436
function _removeAttributes(stepIndex: TourStepIndex) {
407-
document
408-
.querySelectorAll(`[data-non-interactable="${stepIndex}"]`)
437+
document.querySelectorAll(`[data-non-interactable="${stepIndex}"]`)
409438
.forEach((el) => {
410439
el.removeAttribute('data-non-interactable');
411440
});
412441
413-
document
414-
.querySelectorAll(`[data-opacified="${stepIndex}"]`)
442+
document.querySelectorAll(`[data-opacified="${stepIndex}"]`)
415443
.forEach((el) => {
416444
el.removeAttribute('data-opacified');
417445
});
446+
447+
document.querySelectorAll(`[data-scroll-locked="${stepIndex}"]`)
448+
.forEach((el) => {
449+
el.removeAttribute('data-scroll-locked');
450+
el.addEventListener('scroll', (e) => _onScrollLockedElement(e, el));
451+
});
418452
}
419453
420454
async function endTour(soft = false) {
@@ -495,7 +529,7 @@ export default defineComponent({
495529
// control bar
496530
currentStep,
497531
nSteps,
498-
isLoading: disconnected || isLoading,
532+
isLoading: computed(() => disconnected.value || isLoading.value),
499533
disableNextStep,
500534
501535
// actions
@@ -509,7 +543,7 @@ export default defineComponent({
509543
};
510544
},
511545
components: {
512-
CaretRightIcon,
546+
CaretRightSmallIcon,
513547
TourPreviousLeftArrowIcon,
514548
PartyConfettiIcon,
515549
CircleSpinner,
@@ -530,24 +564,43 @@ export default defineComponent({
530564
[data-tour-active] [data-non-interactable] * {
531565
user-select: none !important;
532566
pointer-events: none !important;
567+
cursor: not-allowed;
533568
}
534569
535-
[data-tour-active]#app > *:not(.tour):not(.tour-manager) {
536-
cursor: not-allowed;
570+
[data-tour-active] [data-scroll-locked],
571+
[data-tour-active] [data-scroll-locked] * {
572+
overflow: hidden;
537573
}
538574
539-
[data-tour-active] button.highlighted {
575+
[data-tour-active] button.green-highlight {
540576
background: linear-gradient(
541577
274.28deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 27.6%, rgba(255, 255, 255, 0) 53.12%,
542578
rgba(255, 255, 255, 0.2) 81.25%, rgba(255, 255, 255, 0) 100%
543-
),
544-
radial-gradient(100% 100% at 100% 100%, #41A38E 0%, #21BCA5 100%) !important;
579+
), var(--nimiq-green-bg) !important;
580+
background-blend-mode: hard-light, normal !important;
581+
}
582+
583+
[data-tour-active] button.gray-highlight {
584+
background: linear-gradient(
585+
274.28deg, rgba(31, 35, 72, 0) 0%, rgba(31, 35, 72, 0.07) 27.6%, rgba(31, 35, 72, 0) 53.12%,
586+
rgba(31, 35, 72, 0.07) 81.25%, rgba(31, 35, 72, 0) 100%) !important;
587+
background-blend-mode: hard-light, normal !important;
545588
}
546589
</style>
547590

548591
<style lang="scss" scoped>
549592
.tour {
550-
position: relative;
593+
font-family: Mulish, Muli, -apple-system, BlinkMacSystemFont, "Segoe UI",
594+
Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
595+
596+
position: absolute;
597+
width: 100vw;
598+
height: 100vh;
599+
pointer-events: none;
600+
601+
> * {
602+
pointer-events: initial;
603+
}
551604
552605
button {
553606
width: min-content;
@@ -571,6 +624,7 @@ export default defineComponent({
571624
border-radius: 1rem;
572625
width: clamp(200px, 255px, calc(100vw - 2rem));
573626
padding: 2rem;
627+
z-index: 10;
574628
575629
.content {
576630
display: flex;
@@ -714,9 +768,7 @@ export default defineComponent({
714768
grid-template-columns: 1fr 1fr 1fr;
715769
align-items: center;
716770
z-index: 6;
717-
718-
// TODO Cannot use CSS variables here
719-
background: radial-gradient(100% 100% at 100% 100%, #265dd7 0%, #0582ca 100%);
771+
background: var(--nimiq-light-blue-bg);
720772
721773
button {
722774
padding: 1.4rem 1.6rem 1rem 1.6rem;
@@ -749,14 +801,15 @@ export default defineComponent({
749801
}
750802
751803
&.next {
752-
padding-left: 0.75rem;
753-
754804
&.loading {
755-
padding-left: 0;
756805
cursor: inherit;
757806
758-
& ::v-deep svg path:nth-child(1) {
807+
& ::v-deep svg path {
759808
stroke: var(--nimiq-white);
809+
810+
&:nth-child(2) {
811+
opacity: 0.3;
812+
}
760813
}
761814
}
762815
}
@@ -772,6 +825,17 @@ export default defineComponent({
772825
letter-spacing: -0.4px;
773826
font-variant-numeric: tabular-nums;
774827
}
828+
829+
}
830+
831+
[data-tour-active] .flash {
832+
animation: flash 0.4s;
833+
}
834+
835+
@keyframes flash {
836+
from { background: var(--nimiq-light-blue-bg); }
837+
50% { background: radial-gradient(100% 100% at bottom right, hsl(221, 70%, 70%), hsl(202, 95%, 61%)); }
838+
to { background: var(--nimiq-light-blue-bg); }
775839
}
776840
777841
.remove_me {

0 commit comments

Comments
 (0)