Skip to content

Commit 639940b

Browse files
authored
feature (#169): add migration badges (#181)
* feature (#169): add new migration badges * docs (#169): update badges on parts of migration guide * feature (#169): update migration badges
1 parent 17fd2e5 commit 639940b

18 files changed

+168
-44
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<script>
2+
const validBadges = ['new', 'breaking', 'removed', 'updated']
3+
4+
export default {
5+
props: {
6+
badges: {
7+
type: Array,
8+
default: () => [],
9+
validator(value) {
10+
return validBadges.includes(value)
11+
}
12+
}
13+
}
14+
}
15+
</script>
16+
17+
<template>
18+
<div class="migration-badge-wrapper">
19+
<span
20+
v-for="badgeType in badges"
21+
:class="`migration-badge is-${badgeType}`"
22+
:key="`badge-type-${badgeType}`"
23+
>
24+
{{ badgeType }}
25+
</span>
26+
</div>
27+
</template>
28+
29+
<style lang="scss" scoped>
30+
.migration-badge {
31+
background-color: #ccc;
32+
font-size: 0.8rem;
33+
border: 2px solid #ccc;
34+
border-radius: 5px;
35+
margin-right: 0.5rem;
36+
margin-top: 0.5rem;
37+
color: #222;
38+
padding: 0.25rem 0.25rem;
39+
font-weight: bold;
40+
41+
&:first-child {
42+
margin-left: 1rem;
43+
}
44+
45+
&.is-new {
46+
background-color: #228740;
47+
border-color: #228740;
48+
color: #fff;
49+
}
50+
51+
&.is-breaking {
52+
background-color: #b00000;
53+
border-color: #b00000;
54+
color: #fff;
55+
}
56+
57+
&.is-removed {
58+
background-color: #cf8700;
59+
border-color: #cf8700;
60+
color: #fff;
61+
}
62+
63+
&.is-updated {
64+
background-color: #fcff44;
65+
border-color: #fcff44;
66+
color: #222;
67+
}
68+
}
69+
70+
.migration-badge-wrapper {
71+
display: flex;
72+
margin-top: -0.5rem;
73+
}
74+
</style>

src/.vuepress/theme/styles/index.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ h1, h2, h3, h4, h5, h6
128128

129129
&:first-child
130130
display flex
131+
flex-wrap wrap
131132
align-items center
132133
margin-top -1.5rem
133134
margin-bottom 1rem

src/guide/migration/async-components.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Async Components
1+
---
2+
badges:
3+
- new
4+
---
5+
6+
# Async Components <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

src/guide/migration/attribute-coercion.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Attribute Coercion Behavior
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Attribute Coercion Behavior <MigrationBadges :badges="$frontmatter.badges" />
27

38
::: info Info
49
This is a low-level internal API change and does not affect most developers.
@@ -27,7 +32,7 @@ In 2.x, we had the following strategies for coercing `v-bind` values:
2732

2833
The following table describes how Vue coerce "enumerated attributes" differently with normal non-boolean attributes:
2934

30-
| Binding expression | `foo` <sup>normal</sup> | `draggable` <sup>enumerated</sup> |
35+
| Binding expression | `foo` <sup>normal</sup> | `draggable` <sup>enumerated</sup> |
3136
| ------------------- | ----------------------- | --------------------------------- |
3237
| `:attr="null"` | / | `draggable="false"` |
3338
| `:attr="undefined"` | / | / |
@@ -53,7 +58,7 @@ For non-boolean attributes, Vue will stop removing them if they are `false` and
5358

5459
The following table describes the new behavior:
5560

56-
| Binding expression | `foo` <sup>normal</sup> | `draggable` <sup>enumerated</sup> |
61+
| Binding expression | `foo` <sup>normal</sup> | `draggable` <sup>enumerated</sup> |
5762
| ------------------- | -------------------------- | --------------------------------- |
5863
| `:attr="null"` | / | / <sup>†</sup> |
5964
| `:attr="undefined"` | / | / |

src/guide/migration/custom-directives.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Custom Directives
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Custom Directives <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

src/guide/migration/custom-elements-interop.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
types:
2+
badges:
33
- breaking
44
---
55

6-
# Custom Elements Interop changes <span v-for="type in $frontmatter.types" class="badge" :key="`type-${type}`">{{ type }}</span>
6+
# Custom Elements Interop changes <MigrationBadges :badges="$frontmatter.badges" />
77

88
# Overview
99

src/guide/migration/data-option.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
types:
2+
title: Data Option
3+
badges:
34
- breaking
45
---
56

6-
# Data Option <span v-for="type in $frontmatter.types" class="badge" :key="`type-${type}`">{{ type }}</span>
7+
# {{ $frontmatter.title }} <MigrationBadges :badges="$frontmatter.badges" />
78

89
## Overview
910

src/guide/migration/events-api.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
types:
3-
- removed
2+
badges:
43
- breaking
54
---
65

7-
# Events API <span v-for="type in $frontmatter.types" class="badge" :key="`type-${type}`">{{ type }}</span>
6+
# Events API <MigrationBadges :badges="$frontmatter.badges" />
87

98
## Overview
109

src/guide/migration/filters.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
types:
2+
badges:
33
- removed
4-
- breaking
54
---
65

7-
# Filters <span v-for="type in $frontmatter.types" class="badge" :key="`type-${type}`">{{ type }}</span>
6+
# Filters <MigrationBadges :badges="$frontmatter.badges" />
87

98
## Overview
109

src/guide/migration/fragments.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Fragments
1+
---
2+
badges:
3+
- new
4+
---
5+
6+
# Fragments <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

src/guide/migration/functional-components.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
# Functional Components
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Functional Components <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

510
In terms of what has changed, at a high level:
611

712
- Performance gains from 2.x for functional components are now negligible in 3.x, so we recommend just using stateful components
813
- Functional components can only be created using a plain function that receives `props` and `context` (i.e., `slots`, `attrs`, `emit`)
9-
- **DEPRECATED:** `functional` attribute on single-file component (SFC) `<template>` is deprecated
10-
- **DEPRECATED:** `{ functional: true }` option in components created by functions is deprecated
14+
- **BREAKING:** `functional` attribute on single-file component (SFC) `<template>` is removed
15+
- **BREAKING:** `{ functional: true }` option in components created by functions is removed
1116

1217
For more information, read on!
1318

src/guide/migration/global-api-treeshaking.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Global API Treeshaking
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Global API Treeshaking <MigrationBadges :badges="$frontmatter.badges" />
27

38
## 2.x Syntax
49

@@ -96,11 +101,7 @@ is compiled into something similar to the following:
96101
import { h, Transition, withDirectives, vShow } from 'vue'
97102

98103
export function render() {
99-
return h(Transition, [
100-
withDirectives(h('div', 'hello'), [
101-
[vShow, this.ok]
102-
])
103-
])
104+
return h(Transition, [withDirectives(h('div', 'hello'), [[vShow, this.ok]])])
104105
}
105106
```
106107

src/guide/migration/global-api.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Global API
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Global API <MigrationBadges :badges="$frontmatter.badges" />
27

38
Vue 2.x has a number of global APIs and configurations that globally mutate Vue’s behavior. For instance, to create a global component, you would use the `Vue.component` API like this:
49

@@ -23,18 +28,18 @@ While this approach is convenient, it leads to a couple of problems. Technically
2328

2429
- Global configuration makes it easy to accidentally pollute other test cases during testing. Users need to carefully store original global configuration and restore it after each test (e.g. resetting `Vue.config.errorHandler`). Some APIs like `Vue.use` and `Vue.mixin` don't even have a way to revert their effects. This makes tests involving plugins particularly tricky. In fact, vue-test-utils has to implement a special API `createLocalVue` to deal with this:
2530

26-
```js
27-
import { createLocalVue, mount } from '@vue/test-utils'
31+
```js
32+
import { createLocalVue, mount } from '@vue/test-utils'
2833

29-
// create an extended `Vue` constructor
30-
const localVue = createLocalVue()
34+
// create an extended `Vue` constructor
35+
const localVue = createLocalVue()
3136

32-
// install a plugin “globally” on the “local” Vue constructor
33-
localVue.use(MyPlugin)
37+
// install a plugin “globally” on the “local” Vue constructor
38+
localVue.use(MyPlugin)
3439

35-
// pass the `localVue` to the mount options
36-
mount(Component, { localVue })
37-
```
40+
// pass the `localVue` to the mount options
41+
mount(Component, { localVue })
42+
```
3843

3944
- Global configuration makes it difficult to share the same copy of Vue between multiple "apps" on the same page, but with different global configurations.
4045

src/guide/migration/inline-template-attribute.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
types:
2+
badges:
33
- breaking
4-
- removal
54
---
65

7-
# Inline Template Attribute
6+
# Inline Template Attribute <MigrationBadges :badges="$frontmatter.badges" />
87

98
## Overview
109

@@ -68,7 +67,7 @@ A component previously using `inline-template` can also be refactored using the
6867
</my-comp>
6968
```
7069

71-
The child, instead of providing no template, should now render the default slot*:
70+
The child, instead of providing no template, should now render the default slot\*:
7271

7372
```html
7473
<!--
@@ -80,4 +79,4 @@ The child, instead of providing no template, should now render the default slot*
8079
</template>
8180
```
8281

83-
> * Note: In 3.x, slots can be rendered as the root with native [fragments](/guide/migration/fragments) support!
82+
> - Note: In 3.x, slots can be rendered as the root with native [fragments](/guide/migration/fragments) support!

src/guide/migration/keycode-modifiers.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# KeyCode Modifiers
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# KeyCode Modifiers <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

src/guide/migration/render-function-api.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Render Function API
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Render Function API <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

src/guide/migration/slots-unification.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Slots Unification
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Slots Unification <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

src/guide/migration/v-model.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# `v-model`
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# `v-model` <MigrationBadges :badges="$frontmatter.badges" />
27

38
## Overview
49

0 commit comments

Comments
 (0)