-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
vite.config.ts
Outdated
@@ -45,8 +47,12 @@ export default defineConfig({ | |||
Icons({ | |||
compiler: 'vue3', | |||
iconCustomizer(collection, icon, props) { | |||
props.width = '20px'; | |||
props.height = '20px'; | |||
props.class = 'text-sm'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched the props to text-sm
instead of using a 20-pixel width and height. This change simplifies setting the icon size. However, you need to prefix !
for overrides, like !text-lg
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer we not make icons some type of global size. I'd rather overwrite width/height to be 1em
and then it will just inherit text-size from its parent (basically the same as we do with currentColor
).
Then when we actually use it we can use regular font-size to control it (no need to use !important
). It also makes it use size you actually request (because right now to achieve 32px you need to use text-[27px]
and you actually end up with 27*1.2 so 32.4). Also it feels a bit more cleaner to set text size/color properties on a
instead of this component itself to me (see the diff), but it's just nitpick.
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 6ba834d..0b1d1d4 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -73,8 +73,14 @@ const socials = [
<div class="space-y-2">
<div class="eyebrow">Join the community</div>
<div class="flex space-x-2">
- <a v-for="social in socials" :key="social.href" :href="social.href" target="_blank">
- <component :is="social.icon" class="!text-[27px] text-[#606060] hover:text-skin-link" />
+ <a
+ v-for="social in socials"
+ :key="social.href"
+ :href="social.href"
+ target="_blank"
+ class="text-[32px] text-[#606060] hover:text-skin-link"
+ >
+ <component :is="social.icon" />
</a>
</div>
</div>
diff --git a/src/views/Space/Overview.vue b/src/views/Space/Overview.vue
index 528a786..ce8a165 100644
--- a/src/views/Space/Overview.vue
+++ b/src/views/Space/Overview.vue
@@ -107,11 +107,13 @@ watchEffect(() => setTitle(props.space.name));
</div>
<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">
- <component
- :is="social.icon"
- class="!text-[22px] text-[#606060] hover:text-skin-text"
- />
+ <a
+ v-if="social.href"
+ :href="social.href"
+ target="_blank"
+ class="text-[26px] text-[#606060] hover:text-skin-text"
+ >
+ <component :is="social.icon" />
</a>
</span>
</div>
diff --git a/vite.config.ts b/vite.config.ts
index 86a6891..4fb81a0 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -47,7 +47,8 @@ export default defineConfig({
Icons({
compiler: 'vue3',
iconCustomizer(collection, icon, props) {
- props.class = 'text-sm';
+ props.width = '1em';
+ props.height = '1em';
},
customCollections: {
c: FileSystemIconLoader('./src/assets/icons', svg =>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, yeah that's cleaner! But now all the other icons are 18px instead of 20px, the only solution I found for this is changing the global text size in App.vue from base
to md
. Or we could add text-md
to each icon.
The size of the icons are slightly bigger than, is it possible to get it same as before? Also somehow menu item are missing: Here is see treasury page as menu item Here I don't see it (this PR) I don't see the icons to cast vote also in the feed. |
Done |
Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com>
Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com>
I guess we could workaround this that way, sucks a bit because we are losing consistency. 1.2em seems good when inlining icons along text, but then it becomes troublesome when we actually want to use icon by itself and have good control of its size. diff --git a/vite.config.ts b/vite.config.ts
index 4fb81a0..384f87c 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -47,8 +47,10 @@ export default defineConfig({
Icons({
compiler: 'vue3',
iconCustomizer(collection, icon, props) {
- props.width = '1em';
- props.height = '1em';
+ const size = collection === 'c' ? '1em' : '1.2em';
+
+ props.width = size;
+ props.height = size;
},
customCollections: {
c: FileSystemIconLoader('./src/assets/icons', svg =>
So I think "clean" options for now are:
Honestly I'm not sure what I'd prefer, not big fan of 2 as it's too magical and gets into your way when using standalone icons. Maybe 1 as a start and then coming back to do 3 (maybe with helper class I will let you decide :D |
Doing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing const size = collection === 'c' ? '1em' : '1.2em'; doesn't work well either because the globe icon on Overview page is not from c collection, so would have to be seized separately again.
Not sure what you mean. Right now, on master all icons have 1.2em width/height so if we only change size to 1em for c
collection we don't impact those.
And now with change to 1.11em
we caused all icons across the app to appear different size than they used to be (overview used to have 20px icons, now they are 18px).
As this PR is supposed to just migrate SVGs to icon we should leave unrelated changes out of it, so I'd ideally prefer we end up with one of those 3 options I mentioned (unless there is some other option that is cleaner and doesn't impact how app looks right now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK
* fix: Custom icons * fix: Use link color for more visibility on light mode * Update src/views/Home.vue Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com> * Update src/views/Home.vue Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com> * fix: Revert changes * fix: Size consistency using em * fix: Use link color * fix: Use larger em value * fix: Use hard coded 20px again --------- Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com>
Summary
unplugin-icons
, for example,<IC-icon-file-name />
.fill
attribute from the icon SVGs to allow setting the color withtext-color
.assets/icons
.How to test