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

refactor: Custom icons #864

Merged
merged 13 commits into from
Feb 7, 2024
3 changes: 0 additions & 3 deletions src/assets/discord.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/github.svg

This file was deleted.

4 changes: 4 additions & 0 deletions src/assets/icons/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/icons/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/icons/x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/assets/x.svg

This file was deleted.

36 changes: 27 additions & 9 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
<script setup lang="ts">
import { version, repository } from '@/../package.json';
import ICX from '~icons/c/x';
import ICDiscord from '~icons/c/discord';
import ICGithub from '~icons/c/github';

const COMMIT_SHA = import.meta.env.VITE_COMMIT_SHA || '';

const SOCIALS = [
{
href: 'https://twitter.com/SnapshotLabs',
icon: ICX
},
{
href: 'https://discord.gg/snapshot',
icon: ICDiscord
},
{
href: 'https://github.com/snapshot-labs',
icon: ICGithub
}
];
</script>

<template>
Expand Down Expand Up @@ -54,15 +72,15 @@ const COMMIT_SHA = import.meta.env.VITE_COMMIT_SHA || '';
</div>
<div class="space-y-2">
<div class="eyebrow">Join the community</div>
<div class="space-x-2">
<a href="https://twitter.com/SnapshotLabs" target="_blank">
<img src="~@/assets/x.svg" class="w-[32px] h-[32px] inline-block" />
</a>
<a href="https://discord.gg/snapshot" target="_blank">
<img src="~@/assets/discord.svg" class="w-[32px] h-[32px] inline-block" />
</a>
<a href="https://github.com/snapshot-labs" target="_blank">
<img src="~@/assets/github.svg" class="w-[32px] h-[32px] inline-block" />
<div class="flex space-x-2">
<a
v-for="social in SOCIALS"
:key="social.href"
:href="social.href"
target="_blank"
class="text-[#606060] hover:text-skin-link"
>
<component :is="social.icon" class="w-[32px] h-[32px]" />
</a>
</div>
</div>
Expand Down
35 changes: 22 additions & 13 deletions src/views/Space/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import { _n, compareAddresses, sanitizeUrl } from '@/helpers/utils';
import { getNetwork, offchainNetworks } from '@/networks';
import { Space } from '@/types';
import ICX from '~icons/c/x';
import ICDiscord from '~icons/c/discord';
import ICGithub from '~icons/c/github';
import IHGlobeAlt from '~icons/heroicons-outline/globe-alt';

const PROPOSALS_LIMIT = 4;

Expand Down Expand Up @@ -35,6 +39,13 @@ const githubUrl = computed(() =>
props.space.github ? sanitizeUrl(`https://github.com/${props.space.github}`) : null
);

const socials = computed(() => [
{ href: externalUrl.value, icon: IHGlobeAlt },
{ href: twitterUrl.value, icon: ICX },
{ href: discordUrl.value, icon: ICDiscord },
{ href: githubUrl.value, icon: ICGithub }
]);

const proposalsRecord = computed(() => proposalsStore.proposals[spaceIdComposite]);

watchEffect(() => setTitle(props.space.name));
Expand Down Expand Up @@ -92,19 +103,17 @@ watchEffect(() => setTitle(props.space.name));
{{ space.about }}
</span>
</div>
<div class="space-x-2">
<a v-if="externalUrl" :href="externalUrl" target="_blank">
<IH-globe-alt class="w-[26px] h-[26px] inline-block text-[#606060]" />
</a>
<a v-if="twitterUrl" :href="twitterUrl" target="_blank">
<img src="~@/assets/x.svg" class="w-[26px] h-[26px] inline-block" />
</a>
<a v-if="discordUrl" :href="discordUrl" target="_blank">
<img src="~@/assets/discord.svg" class="w-[26px] h-[26px] inline-block" />
</a>
<a v-if="githubUrl" :href="githubUrl" target="_blank">
<img src="~@/assets/github.svg" class="w-[26px] h-[26px] inline-block" />
</a>
<div class="space-x-2 flex">
<span v-for="(social, i) in socials" :key="i">
<a
v-if="social.href"
:href="social.href"
target="_blank"
class="text-[#606060] hover:text-skin-link"
>
<component :is="social.icon" class="w-[26px] h-[26px]" />
</a>
</span>
</div>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
import visualizer from 'rollup-plugin-visualizer';
import inject from '@rollup/plugin-inject';

Expand All @@ -30,6 +31,7 @@ export default defineConfig({
directoryAsNamespace: true,
resolvers: [
IconsResolver({
customCollections: ['c'],
alias: {
h: 'heroicons-outline',
s: 'heroicons-solid'
Expand All @@ -47,6 +49,11 @@ export default defineConfig({
iconCustomizer(collection, icon, props) {
props.width = '20px';
props.height = '20px';
},
customCollections: {
c: FileSystemIconLoader('./src/assets/icons', svg =>
svg.replace(/^<svg /, '<svg fill="currentColor" ')
)
}
})
],
Expand Down
Loading