Skip to content

Commit cb20b39

Browse files
committed
feat(icon): Adding the AttributeIcon component
1 parent 12f5959 commit cb20b39

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

components/AttributeIcon.vue

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<template>
2+
<div class="icon" :class="classObject">
3+
<SpriteSymbol :name="name" />
4+
</div>
5+
</template>
6+
7+
<script setup lang="ts">
8+
export interface Props {
9+
name: string;
10+
fill?: boolean;
11+
modifier?: string;
12+
}
13+
14+
const props = withDefaults(defineProps<Props>(), {
15+
fill: false,
16+
});
17+
18+
const classObject = reactive({
19+
[`icon--${props.name}`]: true,
20+
"icon--fill": props.fill,
21+
});
22+
23+
if (props.modifier) {
24+
classObject[`icon--${props.modifier}`] = true;
25+
}
26+
</script>
27+
28+
<style lang="scss">
29+
@use "~/assets/sass/tools";
30+
31+
.icon {
32+
width: var(--icon-size--s);
33+
height: var(--icon-size--s);
34+
display: inline-flex;
35+
align-items: center;
36+
37+
svg {
38+
display: block;
39+
width: 100%;
40+
height: 100%;
41+
margin-bottom: 0;
42+
}
43+
44+
&--logo {
45+
svg {
46+
width: var(--icon-size--logo);
47+
height: auto;
48+
}
49+
}
50+
51+
&--fill {
52+
svg {
53+
display: block;
54+
width: 100%;
55+
height: 100%;
56+
}
57+
}
58+
}
59+
</style>

nuxt.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// https://nuxt.com/docs/api/configuration/nuxt-config
22
export default defineNuxtConfig({
33
devtools: { enabled: true },
4-
})
4+
modules: ["nuxt-svg-icon-sprite"],
5+
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@nuxt/eslint": "latest",
1616
"eslint": "^9.34.0",
1717
"nuxt": "^4.0.3",
18+
"nuxt-svg-icon-sprite": "2.0.2",
1819
"typescript": "^5.9.2",
1920
"vue": "latest"
2021
}

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)