I'm currently working on an angularjs project and trying to build reuseable components - heavily inspired by this article (which also spawned the angular component spec).
I'm wondering how I should go about packaging images/stylesheets that I want to include in the components?
Some things I want:
- Sass styles
- A place to store images inside the component directory, and a way to reference them in stylesheets
- Override-able styles in application using components
Currently my thinking is:
Create the component in my bower components directory (app/public/components
), so I have
app
|-- public
|-- components
|-- prefix-component-name
|-- assets
|-- img
|-- ...
|-- views
|-- templates
|-- sass
|-- styles.scss <-- Component styles
|-- img
|-- css
|-- js
index.html
|-- views
|-- sass
|-- application.scss <-- Application styles
The application.scss would import the styles of the components with something like
@import "../../public/components/prefix-component-name/views/sass/styles";
Things I'm not sure about:
- How should I reference images - what if the path changes for the application developer? Create a sass variable for that path in the component?
- How would I override variables in sass files in the application? Do I want the application developer to do that? It seems if you override a variable in sass it propagates downwards from where it changes, so the application can only change it for itself.
- Can you pass paths to a sass file when you import?
My use case is specific to angularjs, but I'm sure the same issues apply to W3C web components, and libraries like polymer and mozilla brick.
Any ideas?
Edit: views
folder is same level as assets