Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
fix: Sets default portal id via plugin options
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianKienle committed May 19, 2019
1 parent 127ba51 commit ded20c5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/Popover/Popover.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<k-pop
ref="kpop"
:portalId="$fdDefaultPortalId"
:bodyClass="fdBodyClass"
arrowClass="fd-popover__arrow"
:placement="placement"
Expand Down
6 changes: 3 additions & 3 deletions src/docs/pages/__tests__/examples.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ describe("All Examples", () => {
let html = "";
// We are not using chai's doesNotThrow-assertion because we want to have the wrapper to get the html
try {
const componentModule = await import(
`./../${page.name}/${example}.vue`
);
const componentModule = await import(`./../${
page.name
}/${example}.vue`);
const component =
componentModule.default != null
? componentModule.default
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const FD_AUTO_INSTALL_DISABLED_KEY = "__FD_AUTO_INSTALL_DISABLED_KEY__";

const install = (vue, options) => {
const normalized = normalizedPluginOptions(options);
vue.prototype.$fdDefaultPortalId = normalized.defaultPortalId;
vue.use(Directives, normalized);
vue.use(FundamentalVuePlugin, normalized);
if (normalized.log.welcome) {
Expand Down
10 changes: 8 additions & 2 deletions src/util/PluginOptions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const makeDefaultOptions = () => ({
log: { welcome: false, registerComponent: false }
log: {
welcome: false,
registerComponent: false
},
defaultPortalId: "fd-portal-container"
});

export const normalizedPluginOptions = (options = makeDefaultOptions()) => {
const { log = {} } = options;
const { log = {}, defaultPortalId = "fd-portal-container" } = options;
const defaultLog = makeDefaultOptions().log;
return {
defaultPortalId,
log: {
...defaultLog,
...log
Expand Down

0 comments on commit ded20c5

Please sign in to comment.