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

feat(Icon): switch to nuxt-icon with dynamic prop or app config #862

Merged
merged 6 commits into from Nov 6, 2023

Conversation

benjamincanac
Copy link
Member

@benjamincanac benjamincanac commented Oct 25, 2023

πŸ”— Linked issue

#267

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR allows to pass a dynamic prop to the UIcon so it uses nuxt-icon underneath, this can be quite useful when using dynamic class names or for icons coming from a database for example.

This behaviour can be changed globally in your app.config.ts through ui.icons.dynamic:

export default defineAppConfig({
  ui: {
    primary: 'green',
    gray: 'slate',
    icons: {
      dynamic: true
    }
  }
})

There is however a little issue with this, as we're using the i-{collection}-{name} syntax due to egoist/tailwindcss-icons, it won't work with nuxt-icon when using collections with dashes. In other words, <UIcon name="i-simple-icons-github" dynamic /> will not work so be careful when activating dynamic icons.

The issue lies in the iconify stringToIcon function used in the loadIcon here: https://github.com/nuxt-modules/icon/blob/main/src/runtime/Icon.vue#L91

EDIT: This has been solved by nuxt-modules/icon#116

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Oct 25, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
ui βœ… Ready (Inspect) Visit Preview Nov 6, 2023 5:24pm

@benjamincanac benjamincanac removed the request for review from Atinux October 27, 2023 22:27
@benjamincanac benjamincanac changed the title feat(Icon): fallback to nuxt-icon with dynamic prop or app config feat(Icon): switch to nuxt-icon with dynamic prop or app config Nov 4, 2023
@benjamincanac benjamincanac marked this pull request as ready for review November 6, 2023 17:03
@benjamincanac benjamincanac merged commit c601fc6 into dev Nov 6, 2023
2 checks passed
@benjamincanac benjamincanac deleted the feat/dynamic-icon branch November 6, 2023 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants