Skip to content

Commit e29a384

Browse files
authored
Revert "Svelte child components (#331)" (#355)
This reverts commit c5a5271.
1 parent e6908c0 commit e29a384

28 files changed

+148
-226
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ npm/*
1010
*.log
1111
components/**/index.js
1212
components/**/index.js.map
13-
components/**/nylas-component.css
1413
components/**/main.js
1514
components/**/main.js.map
1615
components/**/styles.css

commons/src/components/DefaultError.svelte

Lines changed: 0 additions & 67 deletions
This file was deleted.

commons/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ export {
4343
} from "./methods/component";
4444
export { silence } from "./methods/api";
4545
export { ErrorStore } from "./store/error";
46+
/**
47+
* Esbuild tree shakes NError, however it is used in each component
48+
* This code prevents Esbuild from tree-shaking NError
49+
*/
50+
import _ from "./components/NError.svelte";
51+
void _;

commons/src/store/conversations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ConversationQuery,
77
StoredMessage,
88
} from "@commons/types/Nylas";
9-
import { silence } from "@commons/methods/api";
9+
import { silence } from "@commons";
1010

1111
function initializeConversations() {
1212
const { subscribe, set, update } = writable<Record<string, Conversation>>({});

components/agenda/src/Agenda.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import { tick } from "svelte";
55
import { get_current_component, onMount } from "svelte/internal";
66
import { spring } from "svelte/motion";
7-
import "@commons/components/NError.svelte";
87
import { CalendarStore, EventStore, ManifestStore } from "@commons";
98
import {
109
buildInternalProps,

components/availability/src/Availability.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
isValidTimezone,
77
setTimeZoneOffset,
88
} from "@commons/methods/convertDateTimeZone";
9-
import "@commons/components/NError.svelte";
109
import {
1110
ManifestStore,
1211
AvailabilityStore,

components/composer/rollup.config.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import config, { svelteWebConfig } from "../../rollup.common.config";
1+
import config, { svelteConfig } from "../../rollup.common.config";
2+
import svelte from "rollup-plugin-svelte";
3+
import svelteSVG from "rollup-plugin-svelte-svg";
4+
import json from "@rollup/plugin-json";
25

3-
config.plugins = [
4-
...svelteWebConfig({ svg: true, json: true }),
5-
...config.plugins,
6-
];
6+
config.plugins.unshift(svelteSVG());
7+
8+
config.plugins.unshift(
9+
svelte({
10+
...svelteConfig,
11+
}),
12+
);
13+
config.plugins.unshift(json());
714

815
export default { ...config, input: "src/main.ts" };

components/composer/src/Composer.wc.svelte renamed to components/composer/src/Composer.svelte

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<svelte:options tag="nylas-composer" immutable />
22

33
<script lang="ts">
4-
import HTMLEditor from "./components/HTMLEditor.svelte";
5-
import AlertBar from "./components/AlertBar.svelte";
6-
import ComposerAttachment from "./components/Attachment.svelte";
7-
import DatepickerModal from "./components/DatepickerModal.svelte";
8-
import ContactsSearch from "./components/ContactsSearch.svelte";
9-
import NylasError from "@commons/components/DefaultError.svelte";
4+
import "./components/HTMLEditor.svelte";
5+
import "./components/AlertBar.svelte";
6+
import "./components/Attachment.svelte";
7+
import "./components/DatepickerModal.svelte";
8+
import "./components/ContactsSearch.svelte";
109
import LoadingIcon from "./assets/loading.svg";
1110
1211
import {
@@ -155,10 +154,6 @@
155154
$: subject = value?.subject ?? $message.subject;
156155
157156
onMount(async () => {
158-
const style = document.createElement("style");
159-
style.innerHTML = '@import "../nylas-component.css"';
160-
document.querySelector("nylas-composer").shadowRoot.prepend(style);
161-
162157
isLoading = true;
163158
await tick();
164159
@@ -671,7 +666,7 @@
671666
}
672667
</style>
673668

674-
<NylasError {id} />
669+
<nylas-error {id} />
675670

676671
{#if themeUrl}
677672
<link
@@ -748,8 +743,8 @@
748743
</div>
749744
{/if}
750745
{#if _this.show_to}
751-
<ContactsSearch
752-
id="to-field"
746+
<nylas-contacts-search
747+
data-cy="to-field"
753748
placeholder="To:"
754749
change={handleContactsChange("to")}
755750
contacts={to}
@@ -784,8 +779,8 @@
784779
</div>
785780
{#if _this.show_cc}
786781
<div class="cc-container">
787-
<ContactsSearch
788-
id="cc-field"
782+
<nylas-contacts-search
783+
data-cy="cc-field"
789784
placeholder="CC:"
790785
contacts={cc}
791786
value={$message.cc}
@@ -807,8 +802,8 @@
807802
{/if}
808803
{#if _this.show_bcc}
809804
<div class="cc-container">
810-
<ContactsSearch
811-
id="bcc-field"
805+
<nylas-contacts-search
806+
data-cy="bcc-field"
812807
placeholder="BCC:"
813808
contacts={bcc}
814809
value={$message.bcc}
@@ -845,7 +840,8 @@
845840
{/if}
846841

847842
<!-- HTML Editor -->
848-
<HTMLEditor
843+
<nylas-html-editor
844+
data-cy="html-editor"
849845
html={$message.body || template}
850846
onchange={handleBodyChange}
851847
replace_fields={_this.replace_fields}
@@ -858,7 +854,7 @@
858854
<div class="attachments-caption">Attachments:</div>
859855

860856
{#each $attachments as fileAttachment}
861-
<ComposerAttachment
857+
<nylas-composer-attachment
862858
attachment={fileAttachment}
863859
remove={handleRemoveFile}
864860
/>
@@ -895,25 +891,29 @@
895891
</footer>
896892
<!-- Date Picker Component -->
897893
{#if showDatepicker}
898-
<DatepickerModal close={datePickerClose} {schedule} />
894+
<nylas-composer-datepicker-modal close={datePickerClose} {schedule} />
899895
{/if}
900896
<!-- Datepicker Alert (if message is scheduled) -->
901897
{#if $message.send_at && !sendError && !sendSuccess}
902-
<AlertBar type="info" dismissible={true} ondismiss={removeSchedule}>
898+
<nylas-composer-alert-bar
899+
type="info"
900+
dismissible={true}
901+
ondismiss={removeSchedule}
902+
>
903903
Send scheduled for
904904
<span>{formatDate(new Date(datepickerTimestamp))}</span>
905-
</AlertBar>
905+
</nylas-composer-alert-bar>
906906
{/if}
907907
<!-- Alerts -->
908908
{#if sendError}
909-
<AlertBar type="danger" dismissible={true}>
909+
<nylas-composer-alert-bar type="danger" dismissible={true}>
910910
Error: Failed to send the message.
911-
</AlertBar>
911+
</nylas-composer-alert-bar>
912912
{/if}
913913
{#if sendSuccess}
914-
<AlertBar type="success" dismissible={true}>
914+
<nylas-composer-alert-bar type="success" dismissible={true}>
915915
Message sent successfully!
916-
</AlertBar>
916+
</nylas-composer-alert-bar>
917917
{/if}
918918
{/if}
919919
</div>

components/composer/src/components/AlertBar.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<svelte:options tag="nylas-composer-alert-bar" />
2+
13
<script>
24
export let type = "primary";
35
export let dismissible = true;

components/composer/src/components/Attachment.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<svelte:options tag="nylas-composer-attachment" />
2+
13
<script lang="ts">
24
import CloseIcon from "../assets/close.svg";
35
import LoadingIcon from "../assets/loading.svg";
@@ -17,7 +19,7 @@
1719

1820
<style lang="scss">
1921
@import "../../../theming/variables.scss";
20-
.composer-attachment {
22+
.wrapper {
2123
padding: 0.3rem 0;
2224
}
2325
@@ -85,7 +87,7 @@
8587
</style>
8688

8789
{#if attachment}
88-
<div class="composer-attachment">
90+
<div class="wrapper">
8991
<div class="file-item">
9092
<div class="file-info">
9193
{#if !attachment.error}

components/composer/src/components/ContactsSearch.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<svelte:options tag="nylas-contacts-search" immutable={true} />
2+
13
<script lang="ts">
24
import { debounce, isValidEmail } from "../lib/utils";
35
import { tick } from "svelte";
@@ -14,7 +16,6 @@
1416
export let single: boolean = false;
1517
export let change: ChangeCallback | void;
1618
export let show_dropdown: boolean = true;
17-
export let id: string;
1819
1920
let selectedContacts: Participant[] = [];
2021
let term: string = ""; // TODO: rename to "term"
@@ -325,7 +326,6 @@
325326
{#if (single && !selectedContacts.length) || !single}
326327
<form on:submit|preventDefault={handleSubmit} class="search-form">
327328
<input
328-
{id}
329329
data-cy="contacts-search-field"
330330
type="text"
331331
name="email"

components/composer/src/components/DatepickerModal.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
<svelte:options tag="nylas-composer-datepicker-modal" />
2+
13
<script type="ts">
2-
import "../../../datepicker/src/Datepicker.wc.svelte"; // TODO: for local development. This'll update your bundle on commons changes.
4+
import "../../../datepicker/src/Datepicker.svelte"; // TODO: for local development. This'll update your bundle on commons changes.
35
import CloseIcon from "../assets/close.svg";
46
import type {
57
DatepickerCallback,

components/composer/src/components/HTMLEditor.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
<svelte:options tag="nylas-html-editor" />
2+
13
<script lang="ts">
24
import { defaultActions } from "../lib/html-editor";
35
import type { ReplaceFields, ToolbarItem } from "@commons/types/Composer";
46
57
export let onchange = (_html: string) => Promise.resolve({});
68
export let html = "";
7-
export let show_editor_toolbar: boolean;
9+
export let show_editor_toolbar = true;
810
export let replace_fields: ReplaceFields[] | null = null;
911
1012
let container: HTMLDivElement;

0 commit comments

Comments
 (0)