Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ const c = new CommandPal({
placeholder: "Custom placeholder text...", // Changes placeholder text of input
debugOuput: false, // if true report debugging info to console
hideButton: false, // if true, do not generate mobile button
headerText: null, // Text to display in the header of the palette.
// If null (default), do not add header.
commands: [
// Commands go here
]
Expand Down
10 changes: 10 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
export let placeholderText: string;
export let hideButton: boolean;;
export let paletteId: string;
export let headerText: string;

const optionsFuse = {
isCaseSensitive: false,
Expand Down Expand Up @@ -142,6 +143,15 @@
<MobileButton on:click={onMobileClick} />
{/if}
<PaletteContainer bind:show={showModal}>
<!-- when svelte gets conditional slots
https://github.com/sveltejs/svelte/issues/5604
re-implement to remove the empty div.hidden.
-->
<div class="{ headerText === null ? 'hidden': 'header' }" slot="header">
{#if headerText !== null }
{headerText}
{/if}
</div>
<div slot="search">
<SearchField
placeholderText={placeholderText}
Expand Down
11 changes: 11 additions & 0 deletions src/PaletteContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
.search-box {
padding: 7px;
}

:global(.header) {
background-color: rgba(0, 0, 0, 0.33);
border-block-end: black ridge 2px;
color: #ddd;
font-size: smaller;
padding-block-end: 0.1em;
padding-block-start: 0.5em;
padding-inline: 0.5em;
}
/* .search:focus {
color: white;
} */
Expand All @@ -50,6 +60,7 @@
<div class="modal-mask" class:hidden={!show}>
<div class="modal-wrapper">
<div class="modal-container">
<slot name="header" />
<div class="search-box">
<slot name="search" />
</div>
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CommandPal {
placeholderText: this.options.placeholder || "What are you looking for?",
hotkeysGlobal: this.options.hotkeysGlobal || false,
hideButton: this.options.hideButton || false,
headerText: this.options.headerText || null,
},
});
const ctx = this;
Expand Down