Skip to content

Commit

Permalink
perf: move repetitive plugin code to plugin.js (#1285)
Browse files Browse the repository at this point in the history
* [plugins.js] Move repetitive Plugin code to plugin.js

* Update index.js

* Update index.js

* Update index.js

* Update plugins.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* docs: Use shorter plugin import path

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update meta.json

* Update README.md
  • Loading branch information
tmorehouse committed Nov 5, 2017
1 parent e1e701b commit 6ba8c46
Show file tree
Hide file tree
Showing 47 changed files with 181 additions and 309 deletions.
4 changes: 2 additions & 2 deletions docs/components/importdoc.vue
Expand Up @@ -37,10 +37,10 @@
</p>
<p class="mb-0">
<code v-if="$route.name === 'docs-components-slug'">
import {{pluginName}} from 'bootstrap-vue/es/components/{{$route.params.slug}};
import { {{pluginName}} } from 'bootstrap-vue/es/components;
</code>
<code v-else>
import {{pluginName}} from 'bootstrap-vue/es/directives/{{$route.params.slug}};
import { {{pluginName}} } from 'bootstrap-vue/es/directives;
</code>
</p>
<p>
Expand Down
9 changes: 5 additions & 4 deletions docs/markdown/intro/README.md
Expand Up @@ -110,29 +110,30 @@ Vue.directive('b-modal', bModalDirective);
Vue and ES2015 allow for various syntaxes here, so feel free to utilize kebab-casing (shown),
camel-casing, pascal-casing, and/or object property shorthand.

### Components and Directives as Vue plugins
### Component groups and Directives as Vue plugins

You can also import component groups and directives as Vue plugins by importing
the component group or directive directory:

```js
// This imports <b-modal> as well as the v-b-modal directive as a plugin:
import Modal from 'bootstrap-vue/es/components/modal';
import { Modal } from 'bootstrap-vue/es/components';
Vue.use(Modal);

// This imports <b-card> along with all the <b-card-*> sub-components as a plugin:
import Card from 'bootstrap-vue/es/components/card';
import { Card } from 'bootstrap-vue/es/components';
Vue.use(Card);

// This imports directive v-b-scrollspy as a plugin:
import Scrollspy from 'bootstrap-vue/es/directives/scrollspy';
import { Scrollspy } from 'bootstrap-vue/es/directives';
Vue.use(Scrollspy);
```

When importing as plugins, all subcomponents and related directives are imported in most cases.
i.e. When importing `<b-nav>`, all the `<nav-*>` sub components are also included, as well all
dropdown sub components.

Reffer to the component and directive documentation for details.

### Webpack + Babel

Expand Down
2 changes: 1 addition & 1 deletion docs/markdown/intro/meta.json
@@ -1,3 +1,3 @@
{
"name": "intro"
"name": "Intro"
}
10 changes: 3 additions & 7 deletions src/components/alert/index.js
@@ -1,5 +1,5 @@
import bAlert from './alert';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -9,14 +9,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/badge/index.js
@@ -1,5 +1,5 @@
import bBadge from './badge';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -9,14 +9,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/breadcrumb/index.js
@@ -1,7 +1,7 @@
import bBreadcrumb from './breadcrumb';
import bBreadcrumbItem from './breadcrumb-item';
import bBreadcrumbLink from './breadcrumb-link';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -13,14 +13,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/button-group/index.js
@@ -1,5 +1,5 @@
import bButtonGroup from './button-group';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -10,14 +10,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/button-toolbar/index.js
@@ -1,5 +1,5 @@
import bButtonToolbar from './button-toolbar';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -10,14 +10,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/button/index.js
@@ -1,7 +1,7 @@
import bButton from './button';
import bButtonClose from './button-close';
import bLink from './link';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -15,14 +15,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/card/index.js
Expand Up @@ -4,7 +4,7 @@ import bCardBody from './card-body';
import bCardFooter from './card-footer';
import bCardImg from './card-img';
import bCardGroup from './card-group';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -19,14 +19,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin
10 changes: 3 additions & 7 deletions src/components/carousel/index.js
@@ -1,6 +1,6 @@
import bCarousel from './carousel';
import bCarouselSlide from './carousel-slide';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -11,14 +11,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/collapse/index.js
@@ -1,6 +1,6 @@
import bCollapse from './collapse';
import togglePlugin from '../../directives/toggle';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -10,15 +10,11 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
Vue.use(togglePlugin);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/dropdown/index.js
Expand Up @@ -3,7 +3,7 @@ import bDropdownItem from './dropdown-item';
import bDropdownItemButton from './dropdown-item-button';
import bDropdownHeader from './dropdown-header';
import bDropdownDivider from './dropdown-divider';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -24,14 +24,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/embed/index.js
@@ -1,5 +1,5 @@
import bEmbed from './embed';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -9,14 +9,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/form-checkbox/index.js
@@ -1,6 +1,6 @@
import bFormCheckbox from './form-checkbox';
import bFormCheckboxGroup from './form-checkbox-group';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -15,14 +15,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;
10 changes: 3 additions & 7 deletions src/components/form-file/index.js
@@ -1,5 +1,5 @@
import bFormFile from './form-file';
import { registerComponent } from '../../utils';
import { registerComponents, vueUse } from '../../utils';

/* eslint-disable no-var, no-undef, guard-for-in, object-shorthand */

Expand All @@ -10,14 +10,10 @@ const components = {

const VuePlugin = {
install(Vue) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
registerComponents(Vue, components);
}
};

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VuePlugin);
};
vueUse(VuePlugin);

export default VuePlugin;

0 comments on commit 6ba8c46

Please sign in to comment.