budibase/packages/builder/src/userInterface/NewComponent.svelte

68 lines
1.3 KiB
Svelte
Raw Normal View History

<script>
import ComponentSearch from "./ComponentSearch.svelte";
import { store } from "../builderStore";
import PropsView from "./PropsView.svelte";
import Textbox from "../common/Textbox.svelte";
2019-08-14 23:11:59 +02:00
import Button from "../common/Button.svelte";
import ButtonGroup from "../common/ButtonGroup.svelte";
import { pipe } from "../common/core";
import UIkit from "uikit";
import {
getNewComponentInfo
} from "./pagesParsing/createProps";
import { isRootComponent } from "./pagesParsing/searchComponents";
2019-08-14 23:11:59 +02:00
import {
cloneDeep,
join,
split,
map,
keys,
isUndefined
} from "lodash/fp";
import { assign } from "lodash";
2019-08-14 23:11:59 +02:00
2019-08-16 16:48:45 +02:00
let modalElement;
let allComponents;
2019-08-14 23:11:59 +02:00
2019-08-16 16:48:45 +02:00
store.subscribe(s => {
allComponents = s.allComponents;
})
2019-08-14 23:11:59 +02:00
2019-08-16 16:48:45 +02:00
export const close = () => {
2019-08-14 23:11:59 +02:00
UIkit.modal(modalElement).hide();
}
2019-08-16 16:48:45 +02:00
export const show = () => {
UIkit.modal(modalElement).show();
2019-08-14 23:11:59 +02:00
}
2019-08-16 16:48:45 +02:00
const onComponentChosen = (c) => {
store.createDerivedComponent(c.name);
close();
}
</script>
2019-08-14 23:11:59 +02:00
<div bind:this={modalElement} id="new-component-modal" uk-modal>
<div class="uk-modal-dialog">
<div class="uk-modal-header">
<h1>New Component</h1>
</div>
<div class="uk-modal-body">
2019-08-16 16:48:45 +02:00
<ComponentSearch onComponentChosen={onComponentChosen} />
2019-08-14 23:11:59 +02:00
</div>
</div>
2019-08-14 23:11:59 +02:00
</div>
<style>
2019-08-14 23:11:59 +02:00
h1 {
font-size:1.2em;
}
</style>