Skip to content

Commit

Permalink
Replace title attribute with instant tooltips (#704)
Browse files Browse the repository at this point in the history
Closes #648.
  • Loading branch information
matthew-white authored Jan 22, 2023
1 parent 375f6e1 commit 242dddf
Show file tree
Hide file tree
Showing 73 changed files with 1,135 additions and 477 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ module.exports = {
asyncArrow: 'always'
}],
'spaced-comment': 'off',
'vue/attributes-order': ['error', {
order: [
'DEFINITION',
'LIST_RENDERING',
'CONDITIONALS',
'RENDER_MODIFIERS',
'GLOBAL',
['UNIQUE', 'SLOT'],
'TWO_WAY_BINDING',
['OTHER_DIRECTIVES', 'OTHER_ATTR'],
'EVENTS',
'CONTENT'
],
alphabetical: false
}],
'vue/first-attribute-linebreak': 'off',
'vue/html-closing-bracket-newline': ['error', {
singleline: 'never',
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"pre-commit": "node bin/transifex/restructure.js && git diff --exit-code -- transifex/strings_en.json"
},
"dependencies": {
"@floating-ui/dom": "^1.1.0",
"axios": "^0.22.0",
"bootstrap": "~3",
"dompurify": "~2",
Expand Down
21 changes: 19 additions & 2 deletions src/assets/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ em:lang(ja) {
font-weight: bold;
}

.tooltip {
/* v-tooltip.aria-describedby tooltips are rendered before they are shown
on-screen. `display` is not set to `none` for those tooltips. Instead, they
are transparent. However, we do need to position them: otherwise, they would
result in extra space at the bottom of the page. I tried using the sr-only
class, but that resulted in Floating UI miscalculating the position of the
tooltip. Instead, tooltips will be positioned at the top of the page. */
top: 0;
// Move the tooltip to the left so that it doesn't obstruct the navbar.
left: -1000px;
}
.tooltip-inner {
overflow-wrap: break-word;
// Allow the text to have line breaks.
white-space: pre-line;
}



////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -198,8 +215,8 @@ a, .btn-link {

a {
&.disabled, fieldset[disabled] & {
// Not specifying pointer-events so that the cursor and any title attribute
// is shown.
// Not specifying pointer-events so that the cursor and any tooltip is
// shown.

&.btn { color: #fff; }
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/actor-link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
-->
<template>
<link-if-can v-if="actor.type === 'user' && actor.deletedAt == null" :to="to" class="actor-link" :title="actor.displayName">{{ actor.displayName }}</link-if-can>
<span v-else class="actor-link" :title="actor.displayName">{{ actor.displayName }}</span>
<link-if-can v-if="actor.type === 'user' && actor.deletedAt == null" :to="to" class="actor-link" v-tooltip.text>{{ actor.displayName }}</link-if-can>
<span v-else class="actor-link" v-tooltip.text>{{ actor.displayName }}</span>
</template>

<script>
Expand Down
1 change: 1 addition & 0 deletions src/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ except according to the terms contained in the LICENSE file.
<div class="container-fluid" @click.capture="hideAlertAfterClick">
<router-view/>
</div>
<div id="tooltips"></div>
</div>
</template>

Expand Down
21 changes: 11 additions & 10 deletions src/components/audit/row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@ except according to the terms contained in the LICENSE file.
</td>
<td class="initiator">
<template v-if="audit.actor != null">
<span v-if="audit.actor.deletedAt != null" class="icon-trash" :title="$t('deletedMessage')"></span>
<span v-if="audit.actor.deletedAt != null" class="icon-trash" v-tooltip.sr-only></span>
<actor-link :actor="audit.actor"/>
<span v-if="audit.actor.deletedAt != null" class="sr-only">
&nbsp;{{ $t('deletedMessage') }}
</span>
</template>
</td>
<td class="target">
<template v-if="target != null">
<router-link v-if="target.path != null" :to="target.path"
:title="target.title">
v-tooltip.text>
{{ target.title }}
</router-link>
<template v-else>
<span v-if="target.deleted" class="icon-trash" :title="$t('deletedMessage')"></span>
<span v-else-if="target.purged" class="icon-trash" :title="$t('purgedMessage')"></span>
<span :title="target.title">{{ target.title }}</span>
<span v-if="target.deleted || target.purged" class="icon-trash" v-tooltip.sr-only></span>
<span v-tooltip.text>{{ target.title }}</span>
<span v-if="target.deleted || target.purged" class="sr-only">
&nbsp;{{ target.deleted ? $t('deletedMessage') : $t('purgedMessage') }}
</span>
</template>
</template>
</td>
Expand Down Expand Up @@ -156,11 +161,7 @@ export default {
}
.initiator, .target { @include text-overflow-ellipsis; }
.icon-trash {
cursor: help;
margin-right: $margin-right-icon;
}
.icon-trash { margin-right: $margin-right-icon; }
}
</style>

Expand Down
2 changes: 1 addition & 1 deletion src/components/dataset/overview/connection-to-forms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ except according to the terms contained in the LICENSE file.
<expandable-row v-for="(form) in propertiesByForm" :key="form.xmlFormId">
<template #title>
<div class="form-name">
<router-link :to="publishedFormPath(projectId, form.xmlFormId)" :title="form.name">{{ form.name }}</router-link>
<router-link :to="publishedFormPath(projectId, form.xmlFormId)" v-tooltip.text>{{ form.name }}</router-link>
</div>
</template>
<template #caption>
Expand Down
4 changes: 2 additions & 2 deletions src/components/dataset/overview/dataset-properties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ except according to the terms contained in the LICENSE file.
{{ property.name }}
</td>
<td>
<router-link v-if="property.forms.length > 0" :to="publishedFormPath(projectId, property.forms[0].xmlFormId)" :title="property.forms[0].name">
<router-link v-if="property.forms.length > 0" :to="publishedFormPath(projectId, property.forms[0].xmlFormId)" v-tooltip.text>
{{ property.forms[0].name }}
</router-link>
</td>
</tr>
<template v-for="(form, index) in property.forms" :key="form.xmlFormId">
<tr v-if="index > 0">
<td>
<router-link :to="publishedFormPath(projectId, form.xmlFormId)" :title="form.name">{{ form.name }}</router-link>
<router-link :to="publishedFormPath(projectId, form.xmlFormId)" v-tooltip.text>{{ form.name }}</router-link>
</td>
</tr>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/dataset/overview/linked-forms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ except according to the terms contained in the LICENSE file.
<tbody>
<tr v-for="(form) in linkedForms" :key="form.xmlFormId">
<td>
<router-link :to="publishedFormPath(projectId, form.xmlFormId)" :title="form.name">{{ form.name }}</router-link>
<router-link :to="publishedFormPath(projectId, form.xmlFormId)" v-tooltip.text>{{ form.name }}</router-link>
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion src/components/dataset/row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ except according to the terms contained in the LICENSE file.
<template>
<tr class="dataset-row">
<td class="name">
<router-link :title="dataset.name" :to="datasetOverviewPage">{{ dataset.name }}</router-link>
<router-link :to="datasetOverviewPage" v-tooltip.text>{{ dataset.name }}</router-link>
</td>
<td class="entities">
<span>{{ $n(dataset.entities, 'default') }}</span>
Expand Down
5 changes: 3 additions & 2 deletions src/components/dataset/summary/row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ except according to the terms contained in the LICENSE file.
<!-- eslint-disable-next-line vuejs-accessibility/click-events-have-key-events, vuejs-accessibility/interactive-supports-focus -->
<div class="row" role="button" @click.prevent="toggleExpanded">
<div class="col-xs-6 dataset-name-wrap">
<div class="dataset-name text-overflow-ellipsis" :title="dataset.name">{{ dataset.name }}</div>
<div class="dataset-name text-overflow-ellipsis" v-tooltip.text>{{ dataset.name }}</div>
<div v-if="dataset.isNew" class="dataset-new">
<span class="icon-plus-circle"></span>
{{ $t('new') }}
Expand All @@ -32,7 +32,8 @@ except according to the terms contained in the LICENSE file.
<div v-show="expanded" class="property-list">
<span v-for="(property, index) in inFormProperties" :key="property.name">
<span>{{ property.name }}</span>
<span v-if="property.isNew" class="icon-plus-circle property-new" :title="$t('addedByThisDraft')"></span>
<span v-if="property.isNew" class="icon-plus-circle property-new" v-tooltip.sr-only></span>
<span class="sr-only">&nbsp;{{ $t('addedByThisDraft') }}</span>
<template v-if="index < inFormProperties.length - 1">{{ $t('common.punctuations.comma') }}<sentence-separator/></template>
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/date-time.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
-->
<template>
<time v-if="iso != null" :datetime="iso" :title="title">{{ format(true) }}</time>
<time v-if="iso != null" :datetime="iso" v-tooltip.no-aria="tooltipText">{{ format(true) }}</time>
<span v-else>{{ blank }}</span>
</template>

Expand Down Expand Up @@ -40,7 +40,7 @@ export default {
dateTime() {
return DateTime.fromISO(this.iso, { locale: this.$i18n.locale });
},
title() {
tooltipText() {
return this.tooltip ? this.format(false) : null;
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/enketo/fill.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
-->
<template>
<a v-if="disabledTitle == null" class="enketo-fill btn btn-primary"
<a v-if="disabledDescription == null" class="enketo-fill btn btn-primary"
:href="href" target="_blank">
<slot></slot>
</a>
<button v-else type="button" class="enketo-fill btn btn-primary" aria-disabled="true"
:title="disabledTitle">
v-tooltip.aria-describedby="disabledDescription">
<slot></slot>
</button>
</template>
Expand All @@ -32,7 +32,7 @@ export default {
}
},
computed: {
disabledTitle() {
disabledDescription() {
if (this.formVersion.publishedAt != null &&
this.formVersion.state !== 'open')
return this.$t('disabled.notOpen');
Expand Down
6 changes: 3 additions & 3 deletions src/components/enketo/preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
-->
<template>
<a v-if="disabledTitle == null" class="enketo-preview btn btn-default"
<a v-if="disabledDescription == null" class="enketo-preview btn btn-default"
:href="href" target="_blank">
<span class="icon-eye"></span>{{ $t('action.showPreview') }}
</a>
<button v-else type="button" class="enketo-preview btn btn-default" aria-disabled="true"
:title="disabledTitle">
v-tooltip.aria-describedby="disabledDescription">
<span class="icon-eye"></span>{{ $t('action.showPreview') }}
</button>
</template>
Expand All @@ -32,7 +32,7 @@ export default {
}
},
computed: {
disabledTitle() {
disabledDescription() {
if (this.formVersion.publishedAt != null &&
this.formVersion.state !== 'open')
return this.$t('disabled.notOpen');
Expand Down
2 changes: 1 addition & 1 deletion src/components/field-key/row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ except according to the terms contained in the LICENSE file.
<template>
<tr class="field-key-row" :class="{ success: fieldKey.id === highlighted }">
<td class="display-name">
<span :title="fieldKey.displayName">{{ fieldKey.displayName }}</span>
<span v-tooltip.text>{{ fieldKey.displayName }}</span>
</td>
<td>
<time-and-user :iso="fieldKey.createdAt" :user="fieldKey.createdBy"/>
Expand Down
20 changes: 8 additions & 12 deletions src/components/form-attachment/row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ except according to the terms contained in the LICENSE file.
<template>
<tr :class="htmlClass">
<td class="form-attachment-list-type">{{ type }}</td>
<td :title="attachment.name" class="form-attachment-list-name">
<a v-if="attachment.blobExists" :href="href" target="_blank">
<td class="form-attachment-list-name">
<a v-if="attachment.blobExists" :href="href" target="_blank"
v-tooltip.text>
{{ attachment.name }}
</a>
<template v-else>
{{ attachment.name }}
</template>
<span v-else v-tooltip.text>{{ attachment.name }}</span>
</td>
<td class="form-attachment-list-uploaded">
<template v-if="attachment.datasetExists">
Expand All @@ -39,10 +38,11 @@ except according to the terms contained in the LICENSE file.
</span>
</template>
<template v-else>
<span class="icon-exclamation-triangle"></span>
<span :title="$t('notUploaded.title')">
{{ $t('notUploaded.text') }}
<span v-tooltip.sr-only>
<span class="icon-exclamation-triangle"></span>
<span>{{ $t('notUploaded.text') }}</span>
</span>
<span class="sr-only">&nbsp;{{ $t('notUploaded.title') }}</span>
</template>
</td>
<td class="form-attachment-list-action">
Expand Down Expand Up @@ -172,10 +172,6 @@ export default {
.icon-exclamation-triangle {
color: #e1bf50;
margin-right: $margin-right-icon;
+ span {
cursor: help;
}
}
.form-attachment-list-uploaded{
Expand Down
13 changes: 2 additions & 11 deletions src/components/form-version/string.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
-->
<template>
<span :class="htmlClass" :title="versionOrBlank">{{ versionOrBlank }}</span>
<span v-if="version !== ''" class="form-version-string" v-tooltip.text>{{ version }}</span>
<span v-else class="form-version-string blank-version">{{ $t('blank') }}</span>
</template>

<script>
Expand All @@ -21,16 +22,6 @@ export default {
type: String,
required: true
}
},
computed: {
htmlClass() {
return this.version !== ''
? 'form-version-string'
: 'form-version-string blank-version';
},
versionOrBlank() {
return this.version !== '' ? this.version : this.$t('blank');
}
}
};
</script>
Expand Down
Loading

0 comments on commit 242dddf

Please sign in to comment.