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
6 changes: 6 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
footerText: null, // Text to display in the footer of the palette.
// If null (default), do not add footer.
commands: [
// Commands go here
]
Expand Down Expand Up @@ -232,6 +234,10 @@ The styles used by command-pal are included in the package. However you can over
#CommandPal [slot=items] { background-color: yellow;}
/* item text */
#CommandPal .item { color:black; }
/* footers (optional) in all command-pal instances */
.footer[slot=footer] { background-color: gold; color: black;}
/* explicitly override footer styling for one instance */
#CommandPal .footer { background-color: gold; color: black;}
```

You can also assign a custom `id` to the CommandPal instance.
Expand Down
1 change: 1 addition & 0 deletions public/cp-advanced/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ <h2>Output Events</h2>
hotkey: "ctrl+space",
hotkeysGlobal: true,
placeholder: "Custom placeholder text...",
footerText: "Click background, press ESC key or ctrl+space to close.",
commands: [
{
name: "Toggle Dark/Light Theme",
Expand Down
1 change: 1 addition & 0 deletions public/cp-advanced/local-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h2>Output</h2>
const c = new CommandPal({
id: 'MyCommandPal',
hotkey: "ctrl+space",
footerText: "Click background or press ESC key to close.",
commands: [
{
name: "Toggle Dark/Light Theme",
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;
export let hideButton;
export let paletteId;
export let footerText;

const optionsFuse = {
isCaseSensitive: false,
Expand Down Expand Up @@ -160,5 +161,14 @@
{selectedIndex}
on:clickedIndex={onClickedIndex} />
</div>
<!-- when svelte gets conditional slots
https://github.com/sveltejs/svelte/issues/5604
re-implement to remove the empty div.hidden.
-->
<div class="{ footerText === null ? 'hidden': 'footer' }" slot="footer">
{#if footerText !== null }
{footerText}
{/if}
</div>
</PaletteContainer>
</div>
9 changes: 9 additions & 0 deletions src/PaletteContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
.search-box {
padding: 7px;
}
:global(.footer) {
background-color: rgba(0, 0, 0, 0.33);
border-block-start: black ridge 2px;
color: #ddd;
font-size: smaller;
padding-block-start: 0.1em;
padding-inline: 0.5em;
}
/* .search:focus {
color: white;
} */
Expand All @@ -55,6 +63,7 @@
</div>
<div>
<slot name="items" />
<slot name="footer" />
</div>
</div>
</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,
footerText: this.options.footerText || null,
},
});
const ctx = this;
Expand Down