From aeaaad4039793ae2b67d8a44933e109bcb2db43a Mon Sep 17 00:00:00 2001 From: Anssi Juvonen Date: Fri, 20 Dec 2024 15:25:32 +0200 Subject: [PATCH] Add tooltips to badges and unify appearance with chartjs --- package-lock.json | 32 ++++++ package.json | 1 + src/assets/main.scss | 23 ++++ src/components/AchievementBadge.vue | 12 ++- .../AchievementBadge.spec.ts.snap | 4 +- .../AchievementList.spec.ts.snap | 102 +++++++++--------- src/i18n/en.json | 4 +- src/i18n/fi.json | 4 +- src/main.ts | 7 ++ src/utils/constants.ts | 1 + src/utils/helpers.ts | 4 +- vitest.setup.ts | 4 + 12 files changed, 135 insertions(+), 63 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1cc2b0a..6bae69a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "vue-chartjs": "^5.3.2", "vue-i18n": "^10.0.5", "vue-router": "^4.5.0", + "vue-tippy": "^6.5.0", "xstate": "^5.19.0" }, "devDependencies": { @@ -2641,6 +2642,16 @@ "node": ">=18" } }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@rollup/plugin-node-resolve": { "version": "15.3.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.0.tgz", @@ -9355,6 +9366,15 @@ "node": ">=14.0.0" } }, + "node_modules/tippy.js": { + "version": "6.3.7", + "resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-6.3.7.tgz", + "integrity": "sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==", + "license": "MIT", + "dependencies": { + "@popperjs/core": "^2.9.0" + } + }, "node_modules/tldts": { "version": "6.1.53", "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.53.tgz", @@ -11124,6 +11144,18 @@ "vue": "^3.2.0" } }, + "node_modules/vue-tippy": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/vue-tippy/-/vue-tippy-6.5.0.tgz", + "integrity": "sha512-U44UDETTLuZWZGosagslEwgimWQdt1JVSxfWStVPnVdeqo2jo9X5zW3SB04k7JaTFosdgrDhFsUDrd6n42Nh7Q==", + "license": "MIT", + "dependencies": { + "tippy.js": "^6.3.7" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, "node_modules/vue-tsc": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-2.1.10.tgz", diff --git a/package.json b/package.json index 0660119..fd1c9e0 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "vue-chartjs": "^5.3.2", "vue-i18n": "^10.0.5", "vue-router": "^4.5.0", + "vue-tippy": "^6.5.0", "xstate": "^5.19.0" }, "devDependencies": { diff --git a/src/assets/main.scss b/src/assets/main.scss index 42e786e..943d6a3 100644 --- a/src/assets/main.scss +++ b/src/assets/main.scss @@ -74,3 +74,26 @@ body { .outline-override > :focus { @apply outline-sky-500; } + +.tippy-box { + @apply mx-2; + @apply bg-sky-950; +} + +.tippy-content { + @apply p-2 text-sm; + @apply text-slate-50; +} + +.tippy-box[data-placement^='top'] > .tippy-arrow::before { + border-top-color: #082f49; +} +.tippy-box[data-placement^='bottom'] > .tippy-arrow::before { + border-bottom-color: #082f49; +} +.tippy-box[data-placement^='left'] > .tippy-arrow::before { + border-left-color: #082f49; +} +.tippy-box[data-placement^='right'] > .tippy-arrow::before { + border-right-color: #082f49; +} diff --git a/src/components/AchievementBadge.vue b/src/components/AchievementBadge.vue index 43fa509..9daff7e 100644 --- a/src/components/AchievementBadge.vue +++ b/src/components/AchievementBadge.vue @@ -143,9 +143,13 @@ const achievementProps: AchievementProps = {