rodneylab / svelte-social-icons

Beautiful, easy SVG social icons in Svelte
BSD 3-Clause "New" or "Revised" License
13 stars 1 forks source link

Exposing networks and maybe colours #1

Open 0xcharchar opened 3 years ago

0xcharchar commented 3 years ago

Is your feature request related to a problem? Please describe.

I am including social icons as part of another component in my project but running into two things that would be nice to have officially added:

Describe the solution you'd like

Official functions to get details is probably my preferred access:

import SocialIcons, { networkExists, color } from '@rodneylab/svelte-social-icons'

console.log(networkExists('tweeter'), color('twitter'))
// Result: false #00aced

Describe alternatives you've considered

Exporting a simple object would also work and make adding new features easier (imho):

import SocialIcons, { networks } from '@rodneylab/svelte-social-icons'

console.log(networks.twitter)
// Result: { color: #00aced }

Additional context

Here is how I am currently accessing that data, my biggest concern being that the _network-db.js file moves or changes drastically to suit the project better.

import iconDef from '@rodneylab/svelte-social-icons/src/_networks-db.js'

console.log(iconDef.twitter)
// Result: { icon: '', mask: '', color: '' }

Happy to provide a PR if this is a feature you're interested in and don't have time to work on.

rodneylab commented 2 years ago

Hi, Thanks for the feedback. Great idea about a mechanism for knowing which networks are available. I added TypeScript types to the component definition in this commit which should give network autocompletion in your editor.

Just trying to understand your use. Do you have external code potentially requesting a network which does not exist? Are you using TypeScript? I'm exporting a Network type now, wonder if that helps?

0xcharchar commented 2 years ago

For my use case, the network names come from an external list so I don't have control over the data.