Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltip for longer card names #3278

Merged
merged 3 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions kolibri/plugins/learn/assets/src/views/content-card/index.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<template>

<router-link :to="link" class="card" :class="{ 'mobile-card': isMobile }">

<card-thumbnail
class="thumbnail"
:thumbnail="thumbnail"
:kind="kind"
:progress="progress"
:isMobile="isMobile"
/>

<h3 class="text" dir="auto">{{ title }}</h3>

</router-link>
<span ref="complete-title">
indirectlylit marked this conversation as resolved.
Show resolved Hide resolved

<router-link :to="link" class="card" :class="{ 'mobile-card': isMobile }">
<card-thumbnail
class="thumbnail"
:thumbnail="thumbnail"
:kind="kind"
:progress="progress"
:isMobile="isMobile"
/>
<h3 class="text" dir="auto" v-shave>{{ title }}</h3>
indirectlylit marked this conversation as resolved.
Show resolved Hide resolved
</router-link>

<ui-tooltip v-if="hasTooltip" trigger="complete-title">
{{ title }}
</ui-tooltip>

</span>

</template>

Expand All @@ -23,10 +28,20 @@
import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants';
import { validateLinkObject } from 'kolibri.utils.validators';
import cardThumbnail from './card-thumbnail';
import Vue from 'kolibri.lib.vue';
import VueShave from 'vue-shave';
import uiTooltip from 'keen-ui/src/UiTooltip';

Vue.use(VueShave, {
throttle: 300,
height: 35,
spaces: true,
});

export default {
components: {
cardThumbnail,
uiTooltip,
},
props: {
title: {
Expand Down Expand Up @@ -62,6 +77,16 @@
default: false,
},
},
data() {
return {
hasTooltip: false,
};
},
updated() {
indirectlylit marked this conversation as resolved.
Show resolved Hide resolved
this.$nextTick(() => {
this.hasTooltip = this.$el.querySelector('h3 .js-shave') !== null;
indirectlylit marked this conversation as resolved.
Show resolved Hide resolved
});
},
};

</script>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"vue-intl": "2.1.1",
"vue-markdown": "^2.1.3",
"vue-router": "^2.1.1",
"vue-shave": "^1.0.3",
"vuex": "^1.0.0"
},
"devDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5289,6 +5289,10 @@ shallow-clone@^0.1.2:
lazy-cache "^0.2.3"
mixin-object "^2.0.1"

shave@^2.0.2:
version "2.1.3"
resolved "https://registry.yarnpkg.com/shave/-/shave-2.1.3.tgz#89c7df997d35a95bc31703c9150161bc98d3fa3b"

shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
Expand Down Expand Up @@ -6171,6 +6175,12 @@ vue-router@^2.1.1:
version "2.7.0"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-2.7.0.tgz#16d424493aa51c3c8cce8b7c7210ea4c3a89aff1"

vue-shave@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/vue-shave/-/vue-shave-1.0.3.tgz#8168b65d13b14021e128f0931c5b54e810122746"
dependencies:
shave "^2.0.2"

vue-style-loader@^3.0.0, vue-style-loader@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-3.0.3.tgz#623658f81506aef9d121cdc113a4f5c9cac32df7"
Expand Down