Skip to content

Commit 8df3d47

Browse files
committed
feat!: advanced customization of the service icon
1 parent 70b76b0 commit 8df3d47

File tree

5 files changed

+59
-9
lines changed

5 files changed

+59
-9
lines changed

components/service/Base.vue

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<template>
22
<div class="p-4 flex gap-4">
33
<div class="flex-shrink-0 flex">
4-
<a :href="link" :title="title" class="self-center w-16 h-16 overflow-hidden rounded-2xl border border-black/5">
4+
<a :href="link" class="self-center w-16 h-16 overflow-hidden rounded-2xl border border-fg/10 dark:border-fg/15">
55
<slot name="icon">
6-
<img v-if="icon" :src="icon" :alt="title" class="block bg-contain h-full w-full">
7-
<div v-else class="bg-fg-dimmed h-full w-full" />
6+
<div :class="iconWrapClasses" :style="iconWrapStyles">
7+
<Icon v-if="icon?.name" :name="icon.name" :class="iconClasses" />
8+
<img v-else-if="icon?.url" :src="icon.url" alt="" :class="iconClasses">
9+
</div>
810
</slot>
911
</a>
1012
</div>
11-
1213
<div>
1314
<h3 class="text-lg mt-1 font-semibold line-clamp-1">
14-
<a :href="link" :title="title">{{ title }}</a>
15+
<a :href="link">{{ title }}</a>
1516
</h3>
1617
<p class="text-sm text-fg-dimmed line-clamp-1">
1718
<slot name="description" :description="description">
@@ -25,5 +26,17 @@
2526
<script setup lang="ts">
2627
import type { BaseService } from '~/types'
2728
28-
defineProps<BaseService>()
29+
const props = defineProps<BaseService>()
30+
31+
const iconsExist = computed(() => props.icon && (props.icon?.name || props.icon?.url))
32+
const iconClasses = 'block h-full w-full'
33+
const iconWrapClasses = computed(() => ({
34+
'bg-fg/5 dark:bg-fg/10': !iconsExist.value || (props.icon?.wrap && !props.icon?.background),
35+
'p-2': props.icon?.wrap,
36+
'h-full w-full': true,
37+
}))
38+
const iconWrapStyles = computed(() => ({
39+
background: props.icon?.background,
40+
color: props.icon?.color,
41+
}))
2942
</script>

nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default defineNuxtConfig({
6363
'@nuxtjs/i18n',
6464
'@vueuse/nuxt',
6565
'@vite-pwa/nuxt',
66+
'nuxt-icon',
6667
],
6768
i18n: {
6869
locales: [

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"husky": "^8.0.3",
3636
"lint-staged": "^15.2.0",
3737
"nuxt": "^3.9.0",
38+
"nuxt-icon": "^0.6.8",
3839
"typescript": "^5.3.3",
3940
"vue-tsc": "^1.8.27"
4041
},
@@ -44,4 +45,4 @@
4445
"lint-staged": {
4546
"*.ts": "yarn run lint"
4647
}
47-
}
48+
}

types/services.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ export interface BaseService {
44
title: string
55
description?: string
66
link: string
7-
icon?: string
7+
icon?: {
8+
url?: string
9+
name?: string
10+
wrap?: boolean
11+
background?: string
12+
color?: string
13+
}
814
options?: Record<string, string | number | boolean>
915
secrets?: Record<string, string | number | boolean>
1016
}

yarn.lock

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,25 @@
14471447
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz#e5211452df060fa8522b55c7b3c0c4d1981cb044"
14481448
integrity sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==
14491449

1450+
"@iconify/collections@^1.0.374":
1451+
version "1.0.375"
1452+
resolved "https://registry.yarnpkg.com/@iconify/collections/-/collections-1.0.375.tgz#e75d4f84ba7c94c7300cf946de2d4372a0b7734c"
1453+
integrity sha512-BCHzOQKuKaQRqTzZ0dAXXhGoPhho1B3bdRMyX2Jz/1t62+3WoK9s7frqOekyEU/Z354TI/Z/5b5y+OaIGunk8w==
1454+
dependencies:
1455+
"@iconify/types" "*"
1456+
1457+
"@iconify/types@*", "@iconify/types@^2.0.0":
1458+
version "2.0.0"
1459+
resolved "https://registry.yarnpkg.com/@iconify/types/-/types-2.0.0.tgz#ab0e9ea681d6c8a1214f30cd741fe3a20cc57f57"
1460+
integrity sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==
1461+
1462+
"@iconify/vue@^4.1.1":
1463+
version "4.1.1"
1464+
resolved "https://registry.yarnpkg.com/@iconify/vue/-/vue-4.1.1.tgz#c143c2973a4990ba2b47b766f80a9bca97937305"
1465+
integrity sha512-RL85Bm/DAe8y6rT6pux7D2FJSiUEM/TPfyK7GrbAOfTSwrhvwJW+S5yijdGcmtXouA8MtuH9C7l4hiSE4mLMjg==
1466+
dependencies:
1467+
"@iconify/types" "^2.0.0"
1468+
14501469
"@intlify/bundle-utils@^7.4.0":
14511470
version "7.5.0"
14521471
resolved "https://registry.yarnpkg.com/@intlify/bundle-utils/-/bundle-utils-7.5.0.tgz#fb50947c4e9997228a8abd5775e57a1202f71b09"
@@ -1748,7 +1767,7 @@
17481767
resolved "https://registry.yarnpkg.com/@nuxt/devalue/-/devalue-2.0.2.tgz#5749f04df13bda4c863338d8dabaf370f45ef7c7"
17491768
integrity sha512-GBzP8zOc7CGWyFQS6dv1lQz8VVpz5C2yRszbXufwG/9zhStTIH50EtD87NmWbTMwXDvZLNg8GIpb1UFdH93JCA==
17501769

1751-
"@nuxt/devtools-kit@1.0.6":
1770+
"@nuxt/devtools-kit@1.0.6", "@nuxt/devtools-kit@^1.0.6":
17521771
version "1.0.6"
17531772
resolved "https://registry.yarnpkg.com/@nuxt/devtools-kit/-/devtools-kit-1.0.6.tgz#e4a96fc20a9bb88fe58a3d775fcc1e317e3438cb"
17541773
integrity sha512-CUSE++NRTIwvBWbLsPzLZIDMpXr6oyllaWm8tOR3Wgr/04jW31uyWbXjU/fxRuDotQwZfcTe19uunRoCoBnk1Q==
@@ -6866,6 +6885,16 @@ nuxi@^3.10.0:
68666885
optionalDependencies:
68676886
fsevents "~2.3.3"
68686887

6888+
nuxt-icon@^0.6.8:
6889+
version "0.6.8"
6890+
resolved "https://registry.yarnpkg.com/nuxt-icon/-/nuxt-icon-0.6.8.tgz#15c36e92e4baa03adf322938dba86bb872b6251f"
6891+
integrity sha512-6eWlNOb6Uvp63uXFdhcmsB1JlubDv76Pot/VwmIu0yJxDYhwytbnv3WAjw2khl2l7W/65V4eMGIEeX9C5Ahxng==
6892+
dependencies:
6893+
"@iconify/collections" "^1.0.374"
6894+
"@iconify/vue" "^4.1.1"
6895+
"@nuxt/devtools-kit" "^1.0.6"
6896+
"@nuxt/kit" "^3.9.0"
6897+
68696898
nuxt@^3.9.0:
68706899
version "3.9.0"
68716900
resolved "https://registry.yarnpkg.com/nuxt/-/nuxt-3.9.0.tgz#a63e9a0a8d70d2233edd0f8ad87d13ed16ad84b7"

0 commit comments

Comments
 (0)