@@ -79,47 +79,75 @@ Add svantic and modify `src/App.svelte` file in the following way
7979 import { Button } from ' svantic'
8080 </script >
8181
82- <button >Hello world</button >
82+ <Button >Hello world</button >
8383```
8484
8585``` html
8686<script >
8787 // import modules
88- import { Dropdown , Icon } from ' svantic' ;
88+ import { Dropdown , initDropdown , controllable , Icon } from ' svantic' ;
89+
90+ // call this function if you want to use Module.SubModule syntax, ex: Dropdown.Item
91+ initDropdown ()
92+
93+ const dropdownController = controllable (controller => {
94+ // called when the module is mounted and ready
95+ // access the controller and manupilate dropdown
96+ })
8997
90- </script >
9198
92- // Every module have two props: onMount{function} and setting{object}
99+ </ script >
93100
94- // onMount function : allows control module behaviors
101+ // onMount: allows control module behaviors
95102// settings: pass module settings
96- <Dropdown selection onMount ={(controller) => {}} settings={{}}>
103+ <Dropdown
104+ bind:this ={$dropdownController}
105+ onMount ={(domElem) => {}}
106+ settings={{}}
107+ selection >
97108 <Icon name =" caret down" />
98- <Dropdown .text >Select language</Dropdown .text >
99- <Dropdown .menu >
100- <Dropdown .item >English</Dropdown .item >
101- <Dropdown .item >Arabic</Dropdown .item >
102- <Dropdown .item >Spanish</Dropdown .item >
103- <Dropdown .item >German</Dropdown .item >
104- </Dropdown .menu >
109+ <Dropdown .Text >Select language</Dropdown .Text >
110+ <Dropdown .Menu >
111+ <Dropdown .Item >English</Dropdown .Item >
112+ <Dropdown .Item >Arabic</Dropdown .Item >
113+ <Dropdown .Item >Spanish</Dropdown .Item >
114+ <Dropdown .Item >German</Dropdown .Item >
115+ </Dropdown .Menu >
105116</Dropdown >
106117```
107118
108- ...then start [ Rollup ] ( https://rollupjs.org/ )
119+ Another way to use Module.SubModule syntax
109120
110- ``` bash
111- npm run dev
121+ ``` html
122+ <script >
123+ import { Icon } from ' svantic'
124+ import * as Dropdown from ' svantic/modules/dropdown' ;
125+ </script >
126+
127+ <Dropdown .default selection >
128+ <Icon name =" caret down" />
129+ <Dropdown .Text >Select language</Dropdown .Text >
130+ <Dropdown .Menu >
131+ <Dropdown .Item >English</Dropdown .Item >
132+ <Dropdown .Item >Arabic</Dropdown .Item >
133+ <Dropdown .Item >Spanish</Dropdown .Item >
134+ <Dropdown .Item >German</Dropdown .Item >
135+ </Dropdown .Menu >
136+ </Dropdown .default >
112137```
138+ ** Breaking Change**
139+
140+ - onMount prop: allows acces to the top level dom elem instead of module controller
141+
142+ - module controller: to controll a module you use bind: this ={varname} on the component to save an instance of its controller
113143
114- Navigate to [ localhost:5000 ] ( http://localhost:5000 )
144+ - controllable store is a reactive store that allows subscribtion to a module and execute a callback
115145
116146## Development
117147
1181481 . Clone this repo: ` git clone https://github.com/ryu-man/svantic.git `
1191492 . Install dependencies: ` npm i `
1201503 . Start building fomantic: ` npm run build:fomantic `
121- 4 . Start the automated build: ` npm run build `
122- 5 . Open url that console prints in your browser
123151
124152## License
125153
0 commit comments