Skip to content

Commit

Permalink
feat: Create a contextual help to support the user in the different d…
Browse files Browse the repository at this point in the history
…ataset views (#1913)

* add dataset options components

* remove unused components

* set sidebar items by task

* remove old component

* refactor sidebar

* styles and modal refactor

* add help info for explain

* update pagination copy

* lint and update test

* remove icon and title

* update test

* refactor and clean code after review

* update docs link

* update snapshot
  • Loading branch information
leiyre committed Nov 21, 2022
1 parent 8aec980 commit 8e3851e
Show file tree
Hide file tree
Showing 27 changed files with 362 additions and 344 deletions.
3 changes: 3 additions & 0 deletions frontend/assets/scss/abstract/variables/_variables.scss
Expand Up @@ -157,6 +157,9 @@ $swift-linear-duration: 0.15s !default;
$swift-linear-timing-function: linear !default;
$swift-linear: all $swift-linear-duration $swift-linear-timing-function !default;

// topbar
$topbarHeight: 56px;

// sidebar
$sidebarPanelWidth: 280px;
$sidebarMenuWidth: 70px;
Expand Down
25 changes: 12 additions & 13 deletions frontend/components/base/BaseButton.vue
Expand Up @@ -92,12 +92,12 @@ export default {
// buttons
%button {
position: relative;
min-width: auto;
display: flex;
position: relative;
align-items: center;
gap: $base-space;
min-width: auto;
overflow: hidden;
user-select: none;
cursor: pointer;
outline: 0;
background: none;
border: 0;
Expand All @@ -108,13 +108,12 @@ export default {
font-weight: 500;
text-align: center;
text-decoration: none;
vertical-align: middle;
white-space: nowrap;
align-items: center;
@include font-size(14px);
line-height: 14px;
padding: 12px 24px;
transition: all 0.4s $cb-normal;
cursor: pointer;
&:focus {
outline: 0;
}
Expand All @@ -129,19 +128,11 @@ export default {
}
.button {
@extend %button;
:deep(.svg-icon) {
margin-right: $base-space * 2;
margin-left: -$base-space * 2;
}
}
.small {
@include font-size(13px);
line-height: 13px;
padding: 9px 18px;
:deep(.svg-icon) {
margin-right: $base-space;
margin-left: -$base-space;
}
}
.primary {
background-color: $primary-color;
Expand Down Expand Up @@ -177,6 +168,14 @@ export default {
background: $black-4;
}
}
&.link {
background: none;
color: $primary-color;
&:hover {
text-decoration: underline;
background: none;
}
}
}
.secondary {
Expand Down
102 changes: 37 additions & 65 deletions frontend/components/base/BaseModal.vue
Expand Up @@ -16,23 +16,25 @@
-->

<template>
<div v-if="modalVisible" v-click-outside="onClickOutside" class="modal-mask">
<transition name="fade" appear>
<transition name="fade" v-if="modalVisible" appear>
<div v-click-outside="onClickOutside" class="modal-mask">
<div class="modal-wrapper" :class="modalPosition">
<div :class="['modal-container', modalClass]">
<p v-if="!modalCustom" class="modal__title">
<span
class="state"
:class="modalClass === 'modal-info' ? 'succeeded' : 'failed'"
/>
<p v-if="modalTitle" class="modal__title">
<svgicon
v-if="modalIcon"
width="24"
height="24"
:name="modalIcon"
color="#000000"
></svgicon>
{{ modalTitle }}
</p>
<div v-if="!modalCustom" />
<slot />
</div>
</div>
</transition>
</div>
</div>
</transition>
</template>

<script>
Expand All @@ -51,14 +53,13 @@ export default {
type: Boolean,
default: true,
},
modalCustom: {
type: Boolean,
default: false,
},
modalClass: {
type: String,
default: "modal-info",
},
modalIcon: {
type: String,
},
modalTitle: {
type: String,
default: undefined,
Expand All @@ -73,7 +74,7 @@ export default {
},
modalPosition: {
type: String,
default: "modal-bottom",
default: "modal-center",
},
},
data: () => ({}),
Expand Down Expand Up @@ -117,38 +118,44 @@ export default {
}
.modal-wrapper {
display: table-cell;
vertical-align: middle;
&.modal-bottom {
vertical-align: bottom;
padding-bottom: 3em;
padding-left: 30%;
display: flex;
height: 100vh;
&.modal-bottom-right {
align-items: flex-end;
padding-bottom: 3.5em;
.modal-container {
margin-right: 1.5em;
}
}
&.modal-top-right {
align-items: flex-start;
padding-top: 10em;
.modal-container {
margin-right: 6em;
}
}
&.modal-center {
vertical-align: middle;
align-items: center;
}
}
.modal-container {
position: relative;
max-width: 460px;
margin: 0px auto;
padding: $base-space * 4;
background-color: palette(white);
color: $black-87;
border-radius: $border-radius;
box-shadow: $shadow;
transition: $swift-ease-in-out;
position: relative;
text-align: left;
pointer-events: all;
}
.modal-primary {
box-shadow: $shadow;
border-radius: $border-radius;
max-width: 520px;
:deep(.modal__title) {
font-weight: normal;
@include font-size(16px);
}
:deep(.modal__text) {
margin-bottom: 2em;
}
Expand All @@ -173,36 +180,12 @@ export default {
}
}
:deep(.modal__title) {
display: flex;
align-items: center;
gap: $base-space;
@include font-size(16px);
color: $black-54;
font-weight: 600;
margin-top: 0;
margin-right: 2em;
}
.modal__message {
margin-bottom: 1em;
display: block;
&:last-of-type {
margin-bottom: 0;
}
.modal-text {
margin-top: 0;
margin-bottom: 0.3em;
font-weight: 600;
&--info {
margin-top: 0;
margin-bottom: 0.3em;
display: block;
font-weight: lighter;
}
}
.failed {
color: $error;
font-weight: lighter;
margin-bottom: 0;
margin-top: 0;
}
}
.modal-enter {
Expand All @@ -213,17 +196,6 @@ export default {
opacity: 0;
}
// .modal-close {
// border: 0;
// background: palette(white);
// color: $black-54;
// position: absolute;
// top: 0.5em;
// right: 0.5em;
// outline: none;
// cursor: pointer;
// }
.modal-enter .modal-container,
.modal-leave-active .modal-container {
transform: scale(0.9);
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/base/BasePagination.vue
Expand Up @@ -95,7 +95,7 @@
: paginationSize * currentPage
}}
</strong>
of {{ paginableTotalItems | formatNumber }}
of {{ paginableTotalItems | formatNumber }} records
</div>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/base/BaseTopbarBrand.vue
Expand Up @@ -33,7 +33,7 @@ export default {
width: 100%;
display: flex;
align-items: center;
min-height: 56px;
min-height: $topbarHeight;
position: relative;
background: palette(grey, 100);
color: palette(white);
Expand Down
3 changes: 1 addition & 2 deletions frontend/components/base/table/BaseTableInfo.vue
Expand Up @@ -161,12 +161,11 @@
:modal-custom="true"
:prevent-body-scroll="true"
modal-class="modal-secondary"
:modal-title="deleteModalContent.title"
:modal-visible="visibleModalId === item.id"
modal-position="modal-center"
@close-modal="$emit('close-modal')"
>
<div>
<p class="modal__title">{{ deleteModalContent.title }}</p>
<p v-html="deleteModalContent.text"></p>
<div class="modal-buttons">
<base-button
Expand Down
@@ -0,0 +1,62 @@
<template>
<div>
<base-button
title="Info"
class="dataset-option__button"
:class="buttonClass"
@click="showHelpInfo()"
>
<svgicon name="support" width="18" height="18" />Help</base-button
>
<component
:visible="visible"
@on-close="close()"
:is="currentTaskHelpInfo"
/>
</div>
</template>

<script>
export default {
props: {
task: {
type: String,
required: true,
},
},
data() {
return {
visible: false,
};
},
computed: {
currentTaskHelpInfo() {
return `${this.task}HelpInfo`;
},
buttonClass() {
return this.visible ? "--active" : null;
},
},
methods: {
showHelpInfo() {
this.visible = !this.visible;
},
close() {
this.visible = false;
},
},
};
</script>

<style lang="scss" scoped>
.dataset-option {
&__button {
padding: 0;
color: $primary-color;
&:hover,
&.--active {
color: darken($primary-color, 10%);
}
}
}
</style>
@@ -0,0 +1,41 @@
<template>
<div class="dataset-options">
<dataset-option-help-info
class="dataset-options__item"
v-if="availableHelpInfo"
:task="task"
/>
</div>
</template>

<script>
export default {
props: {
dataset: {
type: Object,
required: true,
},
},
computed: {
availableHelpInfo() {
return this.dataset.results.records.some((record) => record.explanation);
},
task() {
return this.dataset.task;
},
},
};
</script>

<style lang="scss" scoped>
.dataset-options {
display: flex;
align-items: center;
gap: $base-space;
margin-left: auto;
&__item {
display: flex;
align-items: center;
}
}
</style>
2 changes: 1 addition & 1 deletion frontend/components/commons/header/filters/FiltersList.vue
Expand Up @@ -264,7 +264,7 @@ export default {
},
selectGroup(group) {
if (this.initialVisibleGroup === group) {
this.initialVisibleGroup = null;
this.initialVisibleGroup = null;
} else {
this.initialVisibleGroup = group;
}
Expand Down

0 comments on commit 8e3851e

Please sign in to comment.