-
Notifications
You must be signed in to change notification settings - Fork 434
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
Added initial Angular content #47
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I proofread the English version. There are a few minor copy changes but it all looks great! 👍
|
||
We’ve now successfully built out a component without needing a server or running the entire frontend application. The next step is to build out the remaining Taskbox components one by one in a similar fashion. | ||
|
||
As you can see, getting started building components in in isolation is easy and fast. We can expect to produce a higher-quality UI with less bugs and more polish because it’s possible to dig in and test every possible state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Double "in" here
|
||
# Assemble a composite component | ||
|
||
Last chapter we built our first component; this chapter extends what we learned to build TaskListComponent, a list of Tasks. Let’s combine components together and see what happens when more complexity is introduced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to "a list of TaskComponents"
Our component is still rough but now we have an idea of the stories to work toward. You might be thinking that the `.list-items` wrapper is overly simplistic. You're right – in most cases we wouldn’t create a new component just to add a wrapper. But the **real complexity** of `TaskListComponent` is revealed in the edge cases `withPinnedTasks`, `loading`, and `empty`. | ||
|
||
```javascript | ||
iimport { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iimport --> import
|
||
Note that we’ve been able to reuse the `withPinnedTasks` list of tasks in both story and unit test; in this way we can continue to leverage an existing resource (the examples that represent interesting configurations of a component) in more and more ways. | ||
|
||
Notice as well that this test is quite brittle. It's possible that as the project matures, and the exact implementation of the `Task` changes --perhaps using a different classname or a `textarea` rather than an `input`--the test will fail, and need to be updated. This is not necessarily a problem, but rather an indication to be careful liberally using unit tests for UI. They're not easy to maintain. Instead rely on visual, snapshot, and visual regression (see [testing chapter](/test/)) tests where possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Task
--> TaskComponent
content/angular/en/screen.md
Outdated
}; | ||
}); | ||
``` | ||
We see that although the `default` story works just fine (because we have default data in our store), we have an issue in the `error` story, because the `error` field is connected to the store itself and we can't just modify it from outside. We need to dispatch and action on the store. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...dispatch and action" ---> "...dispatch an action"
content/angular/en/test.md
Outdated
Import Chromatic in your `.storybook/config.js` file. | ||
|
||
```javascript | ||
import { configure } from '@storybook/react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/react ---> /angular
Can you add link to the Angular English and Spanish editions in these locations:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can help with the spanish translation.
@icarlossz, well, I've already started with that one. As soon as I get a first draft I'll submit it and you can proofread it. Does that work? 😄 |
@alterx It sounds great to me! |
@icarlossz I've added the Spanish version |
content/angular/en/test.md
Outdated
import 'storybook-chromatic/storybook-addon'; | ||
import '../src/styles.less'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should remain .css. The user is not actually running less, rather they're including the pre-compiled .css file included in the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I changed that in both the code and in the tutorial. I've configured the cli to use LESS. It didn't really make sense to use gulp and compile less when the @angular/cli + webpack can allow use of .less files.
You can see the commit here: chromaui/learnstorybook-code@c15b751
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm thanks for the explanation 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed, the spanish translation is good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so great! Can't wait to get it out!!
Two things:
-
We can add syntax highlighting for typescript and json by changing
Highlight.js
to includeloadLanguages(['bash', 'typescript', 'json']);
. Looks nice! -
I wonder why you decided not to do the
PureTaskList
and demonstrate the pattern of splitting the presentational part of a container out for its stories?
Is this difficult to do in angular? I feel like it is a useful trick, and without it the data chapter feels a bit weird, like there is no lesson in it, it is just setting up the next chapter.
content/angular/en/deploy.md
Outdated
```javascript | ||
{ | ||
"scripts": { | ||
"build-storybook": "build-storybook -c .storybook -o .storybook-static" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove -o .storybook-static
-- I just made this change to master
Hey @tmeasday, regarding the In React, when we use In Angular, in order to create a "connected" component we just inject the store and then we can select the data inside. It felt a bit unnecessary to add that part since we already have a presentational component ( In other words, there's no similar way to have the Because of that, it felt weird to add it. It's basically replicating the same thing twice. I don't know if this is clear enough, tho. Let me know if you get what I'm trying to say. I do agree that the |
@alterx -- thanks for the write up, that makes perfect sense to me. I feel like the issue involved here is simply that it isn't convenient to define two components in the one file in Angular as it is in React. Otherwise everything you've said above applies to React as well, and I struggled as well with the fact that Here's what I was thinking and I'll let you decide if it is worth the awkwardness of defining another component:
Although in this example app it really doesn't make a lot of sense to have the container not at the top-level, in order to try and demonstrate both of the above I made things a bit convoluted and showed errors at the screen level, but fetch the data at the I realise you wouldn't write an app like this in reality but things are typically way more complex and you are often tempted to embed containers deep in the hierarchy. So these techniques are good to know! (As we mention in the screen chapter it is possible to avoid embedded containers completely in your app and not ever do the data-mocking technique, but that's not a good fit for a lot of (esp. redux) apps). I wonder: if splitting the presentational part from the data access in a container is unnatural in Angular, is there a way to do the first technique in some other way? I feel like it's a good idea for people to know about! |
Exactly!, I was struggling to see the need for the two components even in the React app but now that you explain why I get it and it makes sense. The main difference is that, in Angular, that separation of components isn't as "convenient" and felt even more awkward without knowing the context. The way of doing this in Angular is actually creating both components. I think I could add that and clarify a bit the message 😄 |
Awesome! I think maybe I need to work on the text a bit to make the above reasoning a bit more obvious so people aren't thinking "this is weird why would I ever do this" ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
So, after a bit of thinking, I'm still not sure this part is really useful in the Angular app. In Angular, as in React, we do have
After this explanation and reviewing the code I've added to that branch do you feel like it makes sense to add it to this PR? I just can't shake the feeling that we'd just be repeating ourselves here |
Hey @alterx thanks again for bearing with me and explaining things to me, I appreciate it. I'm still not sure things are so different between Angular and React--notice that we could also achieve an equivalent thing to your // This Angular:
.addDecorator(
moduleMetadata({
declarations: [],
imports: [TaskModule, NgxsModule.forRoot([TasksState])],
providers: [Store],
}),
)
// Is equivalent to this React:
import { Provider } from 'react-redux';
import store from '../lib/redux';
.addDecorator((story) => (
<Provider store={store}>{story()}</Provider>
); (I think anyway, apologies if I am getting this wrong). So, again, I'm not sure things are all that different, I think I still just haven't explained why I did it this way well enough ;). Let me have another try:
For this reason, I really think it's good to show people that technique, definitely for React where the splitting is pretty easy and natural and probably advisable for other reasons too. For Angular, where it is awkward, I get why you aren't keen to do it. I'm not sure. I still think the technique may be useful for Angular people, and I would suggest we show it to them even if it doesn't really make sense for this particular app. But I am by no means an Angular expert (or even user) so I will completely defer to your instincts on this. Let me know what you want to do! |
Yeah, I think my main issue is that we're basically creating two components that are fundamentally the same thing ( I'll add the new components. |
@tmeasday , I've added the new text in english, please take a look and tell me what you think. I had to change the "We see that although the This is one of the things I thought wouldn't make a lot of sense to add (the Please let me know if the text makes sense and conveys what you wanted to convey in the React text so I can translate the missing parts to spanish. |
I think this last commit solves the whole thing while showing an alternate way of defining stories :) |
I think this is great @alterx! Let's get this merged! |
We probably still need to fix up the commit links .. I can do in the morning.. |
* Update: Introduction revise * ✍️ Update: create an addon > decorators 번역 교정 * ✍️ Update: create an addon > getting started 번역 교정 * ✍️ Update: create an addon > getting started 번역 교정 * ✍️ Update: create an addon > introduction 번역 교정 * ✍️ Update: create an addon > preset 번역 교정 * ✍️ Update: create an addon > register addon 번역 교정 * ✍️ Update: create an addon > track state 번역 교정 * ✍️ Update: design systems for developers > distribute 번역 교정 * ✍️ Update: design systems for developers > architecture 번역 교정 * ✍️ Update: design systems for developers > build 번역 교정 * ✍️ Update: design systems for developers > conclusion 번역 교정 * ✍️ Update: design systems for developers > document 번역 교정 * ✍️ Update: design systems for developers > introduction 번역 교정 * ✍️ Update: design systems for developers > reivew 번역 교정 * ✍️ Update: design systems for developers > test 번역 교정 * ✍️ Update: design systems for developers > workflow 번역 교정 * ✍️ Update: ui testing handbook > conclusion 번역 교정 * ✍️ Update: ui testing handbook > automate 번역 교정 * ✍️ Update: ui testing handbook > introduction 번역 교정 * ✍️ Update: ui testing handbook > workflow 번역 교정 * ✍️ Update: ui testing handbook > accessibility testing 번역 교정 * ✍️ Update: ui testing handbook > composition testing 번역 교정 * ✍️ Update: ui testing handbook > visual testing 번역 교정 * ✍️ Update: ui testing handbook > interaction testing 번역 교정 * ✍️ Update: ui testing handbook > user flow testing 번역 교정 * ✍️ Update: visual testing handbook > workflow 번역 교정 * ✍️ Update: visual testing handbook > vtdd 번역 교정 * ✍️ Update: visual testing handbook > introduction 번역 교정 * ✍️ Update: visual testing handbook > automate 번역 교정 * ✍️ Update: visual testing handbook > conclusion 번역 교정 * ✍️ Update: visual testing handbook > component explorer 번역 교정 * ✍️ Update: intro to storybook > composite component 번역 교정 * ✍️ Update: intro to storybook > conclusion 번역 교정 * ✍️ Update: intro to storybook > contribute 번역 교정 * ✍️ Update: intro to storybook > data 번역 교정 * ✍️ Update: intro to storybook > deploy 번역 교정 * ✍️ Update: intro to storybook > get started 번역 교정 * ✍️ Update: intro to storybook > screen 번역 교정 * ✍️ Update: intro to storybook > simple component 번역 교정 * ✍️ Update: intro to storybook > test 번역 교정 * ✍️ Update: intro to storybook > using addons 번역 교정
This PR accompanies chromaui/learnstorybook-code#4 and addreses #2
What's inside:
What's missing: