Skip to content

Reorganize sidebar and some content; cannibalize reactivity page #1086

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

Merged
merged 6 commits into from
Aug 28, 2017

Conversation

chrisvfritz
Copy link
Contributor

@chrisvfritz chrisvfritz commented Aug 18, 2017

Browse the PR live here.

What I did

  • Split Advanced sidebar category into smaller, more meaningful categories.
  • Renamed some page titles.
  • Removed Reactivity page, as I think a lot of its content may actually be too advanced for end users, but I've kept it hidden for future adaptation into a detailed Contributor's Guide to Vue's internals. Though removed, the essential information has been spread out throughout the Guide and API.
    • API entries for mounted and updated now cover vm.$nextTick.
    • Covered change detection caveats for objects (including Vue.set/vm.$set) under List Rendering, where the caveats for arrays were already listed.
    • Reorganized List Rendering, most notably putting the component section at the end. I discovered that many people were skipping the rest of the page once they got to components, since they hadn't learned components yet. Then they never came back. The result is that many people never even read about array change detection and some of the more niche v-for features. 😬
    • Rewrote The Vue Instance, as many beginner and intermediate users were glazing over at terms like constructor, proxy, etc, leading to many assuming that the reactivity system is more complicated than it is (and not absorbing essential tips). I also tried to make some essential information more clear, e.g. data that starts out empty or non-existant still has to be registered with a starting value.
    • Added note about the devtools on the Installation page
  • I noticed we were using a combination of -> and => to represent expression return values, so I arbitrarily standardized on =>.
  • Moved Filters to its own page, removing it from Syntax, because it's not really an essential feature.

Questions

  • Are the new sidebar categories meaningful to you? When you see what's inside them, are they the kinds of pages you'd expect to see? Is there anything that feels out of place?
  • Do the new page titles make sense to you?
  • How is this intro paragraph of the devtools? Reading this as a user who has just decided to install Vue, do you feel it will entice people enough to click through to learn more?
  • In the rewrite of The Vue Instance, I've vastly simplified the explanation of the reactivity system. In that simplification, are there any details I've left out that you feel are essential for users to build successful applications, avoiding common mistakes?
  • With the reorganization of List Rendering, do you feel the page still flows well? Do you feel the sections are generally ordered by most to least essential?

@@ -16,46 +16,68 @@ var vm = new Vue({

Although not strictly associated with the [MVVM pattern](https://en.wikipedia.org/wiki/Model_View_ViewModel), Vue's design was partly inspired by it. As a convention, we often use the variable `vm` (short for ViewModel) to refer to our Vue instance.

When you instantiate a Vue instance, you need to pass in an **options object** which can contain options for data, template, element to mount on, methods, lifecycle callbacks, and more. The full list of options can be found in the [API reference](../api/#Options-Data).
When you create a Vue instance, you pass in an **options object**. The majority of this guide describes how you can use these options to create your desired behavior. For reference, you can also browse the full list of options can in the [API reference](../api/#Options-Data).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full list of options in, not can in.

```

Although it is possible to create extended instances imperatively, most of the time it is recommended to compose them declaratively in templates as custom elements. We will talk about [the component system](components.html) in detail later. For now, you just need to know that all Vue components are essentially extended Vue instances.
We'll talk about [the component system](components.html) in detail later. For now, just know know that all Vue components are also Vue instances, and so accept the same options object (except for a few root-specific options).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate know.

vm.a // => 3
```

When this data changes, the view will re-render. It should be noted that properties in `data` are only **reactive** if they existed when the instance was created. That means if you add a new property, like:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't "data" plural?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, yes, but in practical use I think most people treat it as singular, e.g. "My data is backed up."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phanan I'm still open to changing it though. What do you think?

visitCount: 0,
hideCompletedTodos: false,
todos: [],
errorMessage: null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest error instead of errorMessage, as a "message" would imply a string type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, though in this case, I'd still actually still have errorMessage be null when it'll be a string later. The reason is a blank error message can still mean something different than a non-existent one.

Each Vue instance goes through a series of initialization steps when it is created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it will also invoke some **lifecycle hooks**, which give us the opportunity to execute custom logic. For example, the [`created`](../api/#created) hook is called after the instance is created:
Each Vue instance goes through a series of initialization steps when it's created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it also runs functions called **lifecycle hooks**, giving users the opportunity to add their own code at specific stages.

For example, the [`created`](../api/#created) hook can be used to run code after an instance is created:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean can be use to run after?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, can be used to run code after does actually say what I mean. What meaning does it have for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I misread it then. Yeah, it makes perfect sense to me now.

!!!!!!!!!!!!!!!!!!!!!!!!!!
!! NOTE FOR TRANSLATORS !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Don't both translating changes to this page yet, !!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't bother?

@chrisvfritz
Copy link
Contributor Author

@phanan Thanks for your excellent review. 😻 Great attention to detail!

Copy link
Member

@hootlex hootlex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, Chris.

  • I think the new sidebar categories are a nice improvement. Easy to navigate and contain the expected content. 🙂 Maybe the Transitions & Animation can go above Reusability & Composition but I am not sure since the latter contains some more advanced features like JSX and Plugins. Also, I wonder why Single File Components page is under tooling. Wouldn't it fit better in the Components category?
  • Yes!
  • I like it, a small screenshot of DevTools in action would also look nice.
  • It's just fine.
  • Still good, didn't even notice the reorganization. ☺️ How about adding a warning on the key section to note that it's required when iterating components? I'd also like to have a warning in the array caveats section, just to draw attention.

<div v-bind:id="rawId | formatId"></div>
```

<p class="tip">Vue 2.x filters can only be used inside mustache interpolations and `v-bind` expressions (the latter supported in 2.1.0+), because filters are primarily designed for text transformation purposes. For more complex data transforms in other directives, you should use [Computed properties](computed.html) instead.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph repeats the way of using filters.
The part "(the latter supported in 2.1.0+)" can be moved to the intro paragraph, so this can be: "Filters are primarily designed for text transformation purposes. For more complex data transforms....."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I just removed the redundancy. 🙂

|- EditTodoButton
|- TodoListFooter
|- ClearTodosButton
|- TodoListStatistics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it's a good idea to show an example component tree at this point. My concern is that even though it's just an example, people with little experience may get confused or try to follow it as a rule.

If you are going to keep it, maybe it's safer to make it more general. For example:

Root Instance
    |- TodoList   
        |- TodoItem
            |- CreateTodoItem
            |- ShowTodoItem
    ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this to my attention! I'll do a little more user testing on this part.

@chrisvfritz
Copy link
Contributor Author

Thanks for the review @hootlex! 😄

Maybe the Transitions & Animation can go above Reusability & Composition

I might be misunderstanding, but isn't it already above Reusability & Composition? If you're suggesting the opposite of what I'm thinking though, then I put Transition & Animation first because it allows you to do something new, whereas Reusability & Composition just allow you to build the same kinds of apps and components, just organized or optimized differently. Does that make sense?

why Single File Components page is under tooling. Wouldn't it fit better in the Components category?

Because they're not actually a feature of Vue core, but of vue-loader/vueify/etc. They're not possible without build tools.

a small screenshot of DevTools in action would also look nice

I actually experimented with adding a screenshot there, but I worried that it took up too much vertical space. Once people have the devtools, I'd like it to be easy to skip over this section to the actual installing of Vue. Once people click through, they'll see a nice screenshot. 🙂

the key section to note that it's required when iterating components?

We do currently have it stand out in a version note and users also receive a warning in the console when using the dev build, so I feel like we might have this well-covered already.

I'd also like to have a warning in the array caveats section, just to draw attention.

This is something a lot of people have missed in the past, because it was below the section about components that we encouraged people to skip. 😅 My hope now is that with the reordering of this page, many more people will see it.

It is important though, so if we still notice a problem with new users, this is a measure I'll consider. I'm just not sure which part we'd turn into a warning, as the entire section is really a sort of warning - and hopefully, the fact that "Caveats" exists in the title will draw attention to it.

@hootlex
Copy link
Member

hootlex commented Aug 22, 2017

@chrisvfritz it seems that you have thought everything 😄

Regarding the "Animations & Transitions", I wanted to say the opposite. Hadn't thought of it this way. It makes sense to show more features before diving into specific needs. 👍🏻

About "Array Caveats", hopefully, people will notice it with the new order. Otherwise, it's hard to decide in which part to emphasize. It's like the whole section should be a warning.

@chrisvfritz
Copy link
Contributor Author

We got a couple reviews, so I'm going ahead and merging this. I at least feel confident there's nothing disasterous here. 😄

@chrisvfritz chrisvfritz merged commit 2355fbc into master Aug 28, 2017
@cwill
Copy link

cwill commented Aug 29, 2017

Just weighing in, spreading info about reactivity throughout the guide as it's relevant seems pretty helpful, but I've found the 'Reactivity In Depth' page an extremely useful reference, especially when working with vuex mutations & dealing with some harder-to-diagnose bugs resulting from setting fields incorrectly. It'd be nice if a consolidated summary of this behavior could stick around somewhere - I needed to reference it today and had to pull it up from archive.

@chrisvfritz
Copy link
Contributor Author

@cwill The page is also still here in source, partially rewritten. The plan is to expand it into a Contributor's Guide that's even more detailed than the current document.

As for the use cases you're thinking of, if the information isn't easily searchable either here or in the Vuex docs, opening an issue would be very welcome. In the API doc in particular, we've been adding more of these kinds of warnings.

@cwill
Copy link

cwill commented Aug 31, 2017

Ah, adding the relevant warnings to the API docs mostly covers the cases I was concerned about -- I'll keep an eye out :)

@chrisvfritz
Copy link
Contributor Author

@cwill Thanks! 😄

@chrisvfritz chrisvfritz deleted the sidebar-reorg branch August 31, 2017 04:27
@yyx990803
Copy link
Member

Maybe a bit late, but I still think the Reactivity Page should be preserved somewhere, especially for those who wish to have a go-to place when they need to point co-workers to a "source" where explains the whole thing in one place.

I'm thinking maybe we should one extra section titled "Advanced / Internals" that hosts the reactivity chapter and the render function chapter, as both of these somewhat relies on knowledge of how Vue actually works under the hood. IMO these are not only valuable for contributors but also for normal users.

@rpkilby
Copy link
Contributor

rpkilby commented Sep 1, 2017

As a normal user, the reactivity docs have been invaluable in the past. Definitely agree that they should live in a separate section.

@chrisvfritz
Copy link
Contributor Author

@yyx990803 Sounds good! I'll have it back up in a new section soon.

kazupon pushed a commit to kazupon/vuejs.org that referenced this pull request Oct 1, 2017
* Reorganize sidebar and some content; cannibalize reactivity page (vuejs#1086)

* reorganize sidebar and some content; cannibalize reactivity page

* Fix typo in instance.md

* Fix typo in instance.md

* Change errorMessage: null to error: null in instance.md

* Fix typo in reactivity.md.hidden

* remove redundant note about filters

# Conflicts:
#	src/v2/api/index.md
#	src/v2/guide/deployment.md
#	src/v2/guide/events.md
#	src/v2/guide/forms.md
#	src/v2/guide/installation.md
#	src/v2/guide/instance.md
#	src/v2/guide/list.md
#	src/v2/guide/migration-vue-router.md
#	src/v2/guide/reactivity.md.hidden
#	src/v2/guide/render-function.md
#	src/v2/guide/syntax.md
#	src/v2/guide/transitioning-state.md
#	src/v2/guide/transitions.md
#	themes/vue/layout/partials/toc.ejs

* Update date

* Fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants