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

Combine all icons into one file? #73

Closed
davewhitley opened this issue Nov 12, 2015 · 5 comments
Closed

Combine all icons into one file? #73

davewhitley opened this issue Nov 12, 2015 · 5 comments
Labels
enhancement Improve existing functionality

Comments

@davewhitley
Copy link
Contributor

This would make requiring icons easier. Instead of requiring each icon one by one, we could just require one component.

For example:

var Icon = require( 'components/simplenote-icons' );

render: function() {
    return <Icon icon="trash" />;
}

Not sure how to do this though, it's a bit over my head.

@davewhitley davewhitley added the enhancement Improve existing functionality label Nov 12, 2015
@davewhitley davewhitley added this to the 1.0 milestone Nov 12, 2015
@beaucollins
Copy link
Contributor

Another option is to have a folder of icons whose index.js required and exported each one:

// icons/index.js

import Trash from './trash'
import Back from './back'
import Plus from './plus'

export { Trash, Back, Plus }

Then where you're using them you could import only what you were using:

import { Trash } from './icons'

render() {
   return <Trash />
}

Or reference all of them:

import * as Icons from './icons'

render: function() {
   return <Icons.Trash />
}

@srgpqt
Copy link
Contributor

srgpqt commented Nov 16, 2015

While this can certainly be done, I don't see the benefit?

@beaucollins
Copy link
Contributor

I think @drw158 is trying to reduce the amount of characters to type when putting in icons.

@srgpqt
Copy link
Contributor

srgpqt commented Nov 16, 2015

Doesn't seem like much of a benefit. There aren't that many icons per component.

@davewhitley
Copy link
Contributor Author

Yep, the main benefit is reducing the amount of work when creating new components. Instead of searching for the icon you need, looking up the icon name, and then adding an import for each one, you could just import the entire set. Beau's solution would probably be better for long term than what we have now.

It's not a lot of trouble now because we only have a handful of icons, but it's possible that we'll add more. If it becomes cumbersome, we can reopen this issue.

@davewhitley davewhitley removed this from the 1.0 milestone Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants