File tree Expand file tree Collapse file tree 6 files changed +445
-24
lines changed
packages/svelte/src/toolbar Expand file tree Collapse file tree 6 files changed +445
-24
lines changed Original file line number Diff line number Diff line change 11<script >
22 import { draggable } from ' @neodrag/svelte' ;
33 import Icon from ' ./Icon.svelte' ;
4- import { configure , getConfig } from ' svelte/toolbar' ;
54
5+ let {
6+ /** @type import('./public.d.ts').ResolvedConfig */
7+ config
8+ } = $props ();
69 let open = $state (true ); // todo change this to false
710
8- configure ({
9- tools: [
10- { name: ' state' },
11- {
12- name: ' inspector' ,
13- activate : () => {
14- console .log (' inspector activated' );
15- }
16- },
17- { name: ' a11y' },
18- { name: ' config' }
19- ]
20- });
21-
22- let config = getConfig ();
2311 /** @type {string[]} */
2412 let active_tool_names = $state ([]);
2513
Original file line number Diff line number Diff line change 22 * toolbar config
33 * @type {import('./public.d.ts').ResolvedConfig }
44 */
5- const config = {
5+ const config = $state ( {
66 tools : [ ]
7- } ;
7+ } ) ;
88
99/**
1010 * @param {Partial<import('./public.d.ts').Config> } options
1111 */
12- export function configure ( options ) {
12+ export function configureSvelte ( options ) {
1313 for ( const [ key , value ] of Object . entries ( options ) ) {
1414 if ( key === 'tools' ) {
1515 continue ;
@@ -40,6 +40,5 @@ export function configure(options) {
4040 * @return {import('./public.d.ts').ResolvedConfig }
4141 */
4242export function getConfig ( ) {
43- // TODO clone to avoid direct manipulation
4443 return config ;
4544}
Original file line number Diff line number Diff line change 1- export { default as ToolBar } from './ToolBar.svelte' ;
2- export * from './configure.js' ;
3- export { mountUI as default } from './runtime.js' ;
1+ import { mountUI } from './runtime.svelte.js' ;
2+ import { configureSvelte } from './configure.svelte.js' ;
3+ import { svelte_inspector } from './tools/inspector/index.js' ;
4+ export * from './configure.svelte.js' ;
5+
6+
7+ configureSvelte ( { tools :[ svelte_inspector ] } ) ;
8+ mountUI ( ) ;
Original file line number Diff line number Diff line change 11import ToolBar from './ToolBar.svelte' ;
22import { mount } from 'svelte' ;
3+ import { getConfig } from './configure.svelte.js' ;
34
45export function mountUI ( ) {
56 if ( typeof window !== 'undefined' ) {
@@ -8,10 +9,12 @@ export function mountUI() {
89 console . debug ( 'svelte-toolbar-host already exists, skipping' ) ;
910 return
1011 }
12+ const props = $state ( { config : getConfig ( ) } )
13+
1114 const el = document . createElement ( 'div' ) ;
1215 el . setAttribute ( 'id' , id ) ;
1316 // appending to documentElement adds it outside of body
1417 document . documentElement . appendChild ( el ) ;
15- mount ( ToolBar , { target : el } ) ;
18+ mount ( ToolBar , { target : el , props } ) ;
1619 }
1720}
You can’t perform that action at this time.
0 commit comments