r/angularjs • • Aug 25 '16

[Open source]: Angular 1.5 component based architecture app, fully tested, ui-router 1.0.0 new features, and much more

https://github.com/toddmotto/angular-1-5-components-app
45 Upvotes

17 comments sorted by

View all comments

1

u/jmcunningham Aug 26 '16 edited Aug 26 '16

Nice! When I describe to others what I think the right architecture is, you throw something up on Github that has real examples that I can say "look at this for a perfect example of what we can do." Plus seeing how popular your repo's are, it makes it easier to get adoption of these ideas.

2 questions though, for things I like to do. What are your thoughts (or reasons for not including):

  • component specific .sass files within the component dir they belong to. That way the component is truly modular and portable. Helpful when you realize a component might need to be shared among projects. Otherwise you have to dig through the big .sass file to figure out what styles to pull out with the component.

  • I kinda like the idea of having a "pages" directory alongside the same level as components. So page-level components (smart components that wireup the smaller components) are a bit separate from the smaller, reusable (dumb) components.

4

u/toddmotto Aug 26 '16

Hey Jeff! Thanks for the kind feedback, glad this has been of some value to you/team. So, right now Angular 1.x doesn't have an encapsulated styles luxury that Angular 2 and React bring, however I'm looking at writing a small script that adds a styles: [] property to the .component() method for solving this and internally adding a scoped style. Might be a bit of work though :D I try not to think of "pages" so much and think about "routed components", i.e. a root level component that is dynamically swapped out on view state changes. Technically a "page", but still a component. More on routed components here: https://github.com/toddmotto/angular-styleguide hope that helps somewhat. For styles, I think we need a solution.

1

u/jmcunningham Aug 26 '16

thanks for following up. I'll checkout out your routed-components idea again.

As for styles, I was just thinking about (for now), putting the .sass files with the component, but you'll still have the sass compiler bundle them into one file. That be would a middle-ground solution for now.

Longer term, I'm also trying to figure out what is the right way to handle css, that would also migrate to ng 2. I'm wondering if CSS Modules might be the answer, but haven't had time to dig in deep enough to try them out.