-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic integration in install docs
- Loading branch information
Showing
8 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<pre class="shiki" style="background-color: #0d1117"><code><span class="line"><span style="color: #FF7B72">import</span><span style="color: #C9D1D9"> { defineAction } </span><span style="color: #FF7B72">from</span><span style="color: #C9D1D9"> </span><span style="color: #A5D6FF">'solid-command-palette'</span><span style="color: #C9D1D9">;</span></span> | ||
<span class="line"></span> | ||
<span class="line"><span style="color: #FF7B72">const</span><span style="color: #C9D1D9"> </span><span style="color: #79C0FF">minimalAction</span><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">=</span><span style="color: #C9D1D9"> </span><span style="color: #D2A8FF">defineAction</span><span style="color: #C9D1D9">({</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> id: </span><span style="color: #A5D6FF">'minimal'</span><span style="color: #C9D1D9">,</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> title: </span><span style="color: #A5D6FF">'Minimal Action'</span><span style="color: #C9D1D9">,</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </span><span style="color: #D2A8FF">run</span><span style="color: #C9D1D9">: () </span><span style="color: #FF7B72">=></span><span style="color: #C9D1D9"> {</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> console.</span><span style="color: #D2A8FF">log</span><span style="color: #C9D1D9">(</span><span style="color: #A5D6FF">'ran minimal action'</span><span style="color: #C9D1D9">);</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> },</span></span> | ||
<span class="line"><span style="color: #C9D1D9">});</span></span> | ||
<span class="line"></span> | ||
<span class="line"><span style="color: #FF7B72">const</span><span style="color: #C9D1D9"> </span><span style="color: #79C0FF">incrementCounterAction</span><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">=</span><span style="color: #C9D1D9"> </span><span style="color: #D2A8FF">defineAction</span><span style="color: #C9D1D9">({</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> id: </span><span style="color: #A5D6FF">'increment-counter'</span><span style="color: #C9D1D9">,</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> title: </span><span style="color: #A5D6FF">'Increment Counter by 1'</span><span style="color: #C9D1D9">,</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> subtitle: </span><span style="color: #A5D6FF">'Press CMD + E to trigger this.'</span><span style="color: #C9D1D9">,</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> shortcut: </span><span style="color: #A5D6FF">'$mod+e'</span><span style="color: #C9D1D9">, </span><span style="color: #8B949E">// $mod = Command on Mac & Control on Windows.</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </span><span style="color: #D2A8FF">run</span><span style="color: #C9D1D9">: ({ </span><span style="color: #FFA657">rootContext</span><span style="color: #C9D1D9"> }) </span><span style="color: #FF7B72">=></span><span style="color: #C9D1D9"> {</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> rootContext.</span><span style="color: #D2A8FF">increment</span><span style="color: #C9D1D9">();</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> },</span></span> | ||
<span class="line"><span style="color: #C9D1D9">});</span></span> | ||
<span class="line"></span> | ||
<span class="line"><span style="color: #FF7B72">export</span><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">const</span><span style="color: #C9D1D9"> </span><span style="color: #79C0FF">actions</span><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">=</span><span style="color: #C9D1D9"> {</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> [minimalAction.id]: minimalAction,</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> [incrementCounterAction.id]: incrementCounterAction,</span></span> | ||
<span class="line"><span style="color: #C9D1D9">};</span></span> | ||
<span class="line"></span></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<pre class="shiki" style="background-color: #0d1117"><code><span class="line"><span style="color: #FF7B72">import</span><span style="color: #C9D1D9"> { Root, CommandPalette } </span><span style="color: #FF7B72">from</span><span style="color: #C9D1D9"> </span><span style="color: #A5D6FF">'solid-command-palette'</span><span style="color: #C9D1D9">;</span></span> | ||
<span class="line"><span style="color: #FF7B72">import</span><span style="color: #C9D1D9"> { actions } </span><span style="color: #FF7B72">from</span><span style="color: #C9D1D9"> </span><span style="color: #A5D6FF">'./actions'</span><span style="color: #C9D1D9">;</span></span> | ||
<span class="line"><span style="color: #FF7B72">import</span><span style="color: #C9D1D9"> </span><span style="color: #A5D6FF">'solid-command-palette/pkg-dist/style.css'</span><span style="color: #C9D1D9">;</span></span> | ||
<span class="line"></span> | ||
<span class="line"><span style="color: #FF7B72">const</span><span style="color: #C9D1D9"> </span><span style="color: #D2A8FF">App</span><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">=</span><span style="color: #C9D1D9"> () </span><span style="color: #FF7B72">=></span><span style="color: #C9D1D9"> {</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">const</span><span style="color: #C9D1D9"> </span><span style="color: #79C0FF">actionsContext</span><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">=</span><span style="color: #C9D1D9"> {</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </span><span style="color: #D2A8FF">increment</span><span style="color: #C9D1D9">() {</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> console.</span><span style="color: #D2A8FF">log</span><span style="color: #C9D1D9">(</span><span style="color: #A5D6FF">'increment count state by 1'</span><span style="color: #C9D1D9">);</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> },</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> };</span></span> | ||
<span class="line"></span> | ||
<span class="line"><span style="color: #C9D1D9"> </span><span style="color: #FF7B72">return</span><span style="color: #C9D1D9"> (</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> <</span><span style="color: #7EE787">div</span><span style="color: #C9D1D9"> </span><span style="color: #79C0FF">class</span><span style="color: #FF7B72">=</span><span style="color: #A5D6FF">"my-app"</span><span style="color: #C9D1D9">></span></span> | ||
<span class="line"><span style="color: #C9D1D9"> <</span><span style="color: #7EE787">Root</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </span><span style="color: #79C0FF">actions</span><span style="color: #FF7B72">=</span><span style="color: #C9D1D9">{actions}</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </span><span style="color: #79C0FF">actionsContext</span><span style="color: #FF7B72">=</span><span style="color: #C9D1D9">{actionsContext}</span></span> | ||
<span class="line"><span style="color: #C9D1D9"> ></span></span> | ||
<span class="line"><span style="color: #C9D1D9"> <</span><span style="color: #7EE787">CommandPalette</span><span style="color: #C9D1D9"> /></span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </</span><span style="color: #7EE787">Root</span><span style="color: #C9D1D9">></span></span> | ||
<span class="line"><span style="color: #C9D1D9"> </</span><span style="color: #7EE787">div</span><span style="color: #C9D1D9">></span></span> | ||
<span class="line"><span style="color: #C9D1D9"> );</span></span> | ||
<span class="line"><span style="color: #C9D1D9">};</span></span> | ||
<span class="line"></span></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<pre class="shiki" style="background-color: #0d1117"><code><span class="line"><span style="color: #8B949E"># Core Library</span></span> | ||
<span class="line"><span style="color: #C9D1D9">npm install solid-command-palette</span></span> | ||
<span class="line"></span> | ||
<span class="line"><span style="color: #8B949E"># Peer Dependencies</span></span> | ||
<span class="line"><span style="color: #C9D1D9">npm install solid-transition-group tinykeys fuse.js</span></span> | ||
<span class="line"></span></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { defineAction } from 'solid-command-palette'; | ||
|
||
const minimalAction = defineAction({ | ||
id: 'minimal', | ||
title: 'Minimal Action', | ||
run: () => { | ||
console.log('ran minimal action'); | ||
}, | ||
}); | ||
|
||
const incrementCounterAction = defineAction({ | ||
id: 'increment-counter', | ||
title: 'Increment Counter by 1', | ||
subtitle: 'Press CMD + E to trigger this.', | ||
shortcut: '$mod+e', // $mod = Command on Mac & Control on Windows. | ||
run: ({ rootContext }) => { | ||
rootContext.increment(); | ||
}, | ||
}); | ||
|
||
export const actions = { | ||
[minimalAction.id]: minimalAction, | ||
[incrementCounterAction.id]: incrementCounterAction, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Root, CommandPalette } from 'solid-command-palette'; | ||
import { actions } from './actions'; | ||
import 'solid-command-palette/pkg-dist/style.css'; | ||
|
||
const App = () => { | ||
const actionsContext = { | ||
increment() { | ||
console.log('increment count state by 1'); | ||
}, | ||
}; | ||
|
||
return ( | ||
<div class="my-app"> | ||
<Root | ||
actions={actions} | ||
actionsContext={actionsContext} | ||
> | ||
<CommandPalette /> | ||
</Root> | ||
</div> | ||
); | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters