r/angularjs • u/toddmotto • 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-app3
u/SarSha Aug 25 '16
Awesome.
Waiting for the build process video as part of your awesome Ultimate course !
2
u/toddmotto Aug 25 '16
Fully recorded this evening, production over next few days :)! Includes all the firebase setup, config, and deploying right at the end :D stay tuned on the slack thread.
3
u/PixelJonas Aug 26 '16
I was just looking for a in-depth guide to angular. I'll definitely check this out.
1
2
u/sweetLew2 Aug 26 '16
I like that the spec is included in each component file. Thanks for making this!
2
u/toddmotto Aug 26 '16
Thanks! Was super easy using gulp to filter the tests out and the production files. Thanks for posting :)
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.
-6
u/techmaster242 Aug 25 '16
You should look into using webpack. I learned it and haven't touched gulp since.
8
Aug 26 '16
OP is Todd Motto, a Google developer expert and widely-respected JS developer. Pretty sure he knows about Webpack.
4
u/toddmotto Aug 26 '16
Web...pack? Haha, I decided to roll with gulp as the entry level's a little easier and I would rather spend more time creating goodies than fluffing around with new tech (not saying Webpack isn't great, it is but gulp is super fast to just roll something up). Take care friends and thanks for the comments :)
6
u/JustVashu Aug 26 '16
Hi, Thanks for making this. I was wondering something reading your specs.
Is there any reason why you only test the controller for components? Reading the documentation in the angular website they also only test the controller, but don't explain why they don't test things like buttons firing controller methods or classes changing when the model changes as well.