|
| 1 | +# Nova + Element UI |
| 2 | + |
| 3 | +This is a set of component Element UI for Laravel Nova |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +1) ```composer require nightkit/nova-element-ui``` |
| 8 | +2) Add NightKit\NovaElements\NovaElementsServiceProvider::class to your config/app.php in providers section |
| 9 | +3) ``` php artisan vendor:publish ``` |
| 10 | + |
| 11 | +### Components |
| 12 | + |
| 13 | +This is awailable component for this time. |
| 14 | + |
| 15 | +#### ElementInput |
| 16 | + |
| 17 | +ElementInput just simple unput element with couple of cool features |
| 18 | + |
| 19 | +You can add it like that |
| 20 | +```php |
| 21 | + public function fields(Request $request) |
| 22 | + { |
| 23 | + return [ |
| 24 | + ID::make()->sortable(), |
| 25 | + ElementInput::make('String') |
| 26 | + ]; |
| 27 | + } |
| 28 | +``` |
| 29 | + |
| 30 | + |
| 31 | +To make this input with clear action just add ```clearable()``` |
| 32 | + |
| 33 | +```php |
| 34 | + public function fields(Request $request) |
| 35 | + { |
| 36 | + return [ |
| 37 | + ID::make()->sortable(), |
| 38 | + ElementInput::make('String') |
| 39 | + ->clearable() |
| 40 | + ]; |
| 41 | + } |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +You can also add prefix or suffix icon with ```prefixIcon()``` and```suffixIcon()``` |
| 46 | + |
| 47 | +```php |
| 48 | + public function fields(Request $request) |
| 49 | + { |
| 50 | + return [ |
| 51 | + ID::make()->sortable(), |
| 52 | + ElementInput::make('String') |
| 53 | + ->clearable() |
| 54 | + ->prefixIcon('el-icon-date') //icon css class |
| 55 | + ]; |
| 56 | + } |
| 57 | +``` |
| 58 | + |
| 59 | + |
| 60 | +If you need a textarea you can simple make it by ```textarea()``` |
| 61 | + |
| 62 | +```php |
| 63 | + public function fields(Request $request) |
| 64 | + { |
| 65 | + return [ |
| 66 | + ID::make()->sortable(), |
| 67 | + ElementInput::make('String') |
| 68 | + ->textarea(4, true) |
| 69 | + ]; |
| 70 | + } |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | +Textarea accepts several parameters, number of rows and autosize |
| 75 | + |
| 76 | +#### ElementAutocomplete |
| 77 | + |
| 78 | +ElementAutocomplete looks like a input but is used if you need autocomplete |
| 79 | + |
| 80 | +```php |
| 81 | + return [ |
| 82 | + ID::make()->sortable(), |
| 83 | + ElementAutocomplete::make('String') |
| 84 | + ->suggestions(['vue', 'laravel', 'nova']) |
| 85 | + ]; |
| 86 | +``` |
| 87 | + |
| 88 | + |
| 89 | +This field has a few method |
| 90 | + |
| 91 | +```placement() @string``` |
| 92 | +Placement of the popup menu (top / top-start / top-end / bottom / bottom-start / bottom-end) default bottom-start |
| 93 | + |
| 94 | +```triggerOnFocus @bool``` |
| 95 | +Whether show suggestions when input focus (default true) |
| 96 | + |
| 97 | +```debounce() @int``` |
| 98 | +Debounce delay when typing, in milliseconds (default 300) |
| 99 | + |
| 100 | + |
| 101 | +#### ELementSelect |
| 102 | + |
| 103 | +Just simple select field with more beautiful design |
| 104 | + |
| 105 | +```php |
| 106 | +public function fields(Request $request) |
| 107 | + { |
| 108 | + return [ |
| 109 | + ID::make()->sortable(), |
| 110 | + ElementSelect::make('String') |
| 111 | + ->options(['vue', 'laravel', 'nova']) |
| 112 | + ]; |
| 113 | + } |
| 114 | +``` |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +#### ElementTimezoneSelect and ElementTimezoneAutocomplete |
| 119 | + |
| 120 | +This two fields depends on ElementSelect and ElementAutocompele to choice timezone more comfortable |
| 121 | + |
| 122 | +```php |
| 123 | +public function fields(Request $request) |
| 124 | + { |
| 125 | + return [ |
| 126 | + ID::make()->sortable(), |
| 127 | + ElementTimezoneAutocomplete::make('String'), |
| 128 | + ElementTimezoneSelect::make('String') |
| 129 | + ]; |
| 130 | + } |
| 131 | +``` |
| 132 | + |
| 133 | + |
| 134 | +#### ElementNumber |
| 135 | + |
| 136 | +The number input field on steroids:) |
| 137 | + |
| 138 | +It's depend on Nova native Number field and support all its functions |
| 139 | + |
| 140 | +```php |
| 141 | +public function fields(Request $request) |
| 142 | + { |
| 143 | + return [ |
| 144 | + ID::make()->sortable(), |
| 145 | + ElementNumber::make('Number') |
| 146 | + ->min(2) |
| 147 | + ->max(6) |
| 148 | + ->step(2) |
| 149 | + ]; |
| 150 | + } |
| 151 | +``` |
| 152 | + |
| 153 | + |
| 154 | +Also this field provide several methods |
| 155 | + |
| 156 | +```precision() @int``` |
| 157 | +Precision of input value |
| 158 | + |
| 159 | +```showControls() @bool``` |
| 160 | +whether to enable the control buttons |
| 161 | + |
| 162 | +```rightControls()``` |
| 163 | +Move the control buttons to the right |
| 164 | + |
| 165 | +#### ElementRadio |
| 166 | + |
| 167 | +Radio element |
| 168 | + |
| 169 | +```php |
| 170 | +public function fields(Request $request) |
| 171 | + { |
| 172 | + return [ |
| 173 | + ID::make()->sortable(), |
| 174 | + ElementRadio::make('String') |
| 175 | + ->options([ |
| 176 | + ['value' => '1', 'label' => 'vue'], |
| 177 | + ['value' => '2', 'label' => 'laravel'], |
| 178 | + ['value' => '3', 'label' => 'nova'], |
| 179 | + ]) |
| 180 | + ]; |
| 181 | + } |
| 182 | +``` |
| 183 | + |
| 184 | + |
| 185 | +If you want button style radio just use ```buttons()``` method |
| 186 | + |
| 187 | +```php |
| 188 | +public function fields(Request $request) |
| 189 | + { |
| 190 | + return [ |
| 191 | + ID::make()->sortable(), |
| 192 | + ElementRadio::make('String') |
| 193 | + ->options([ |
| 194 | + ['value' => '1', 'label' => 'vue'], |
| 195 | + ['value' => '2', 'label' => 'laravel'], |
| 196 | + ['value' => '3', 'label' => 'nova'], |
| 197 | + ])->buttons() |
| 198 | + ]; |
| 199 | + } |
| 200 | + ``` |
| 201 | + |
| 202 | + |
| 203 | +Or bordered style with ```bordered()``` |
| 204 | + |
| 205 | +```php |
| 206 | +public function fields(Request $request) |
| 207 | + { |
| 208 | + return [ |
| 209 | + ID::make()->sortable(), |
| 210 | + ElementRadio::make('String') |
| 211 | + ->options([ |
| 212 | + ['value' => '1', 'label' => 'vue'], |
| 213 | + ['value' => '2', 'label' => 'laravel'], |
| 214 | + ['value' => '3', 'label' => 'nova'], |
| 215 | + ])->bordered() |
| 216 | + ]; |
| 217 | + } |
| 218 | + ``` |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | +#### ElementCheckbox |
| 223 | + |
| 224 | +ElementCheckbox depends on native Nova Boolean field with couple cool features |
| 225 | + |
| 226 | +```php |
| 227 | +public function fields(Request $request) |
| 228 | + { |
| 229 | + return [ |
| 230 | + ID::make()->sortable(), |
| 231 | + ElementCheckbox::make('Boolean') |
| 232 | + ]; |
| 233 | + } |
| 234 | +``` |
| 235 | + |
| 236 | + |
| 237 | +On detail page and index it's cool looks with el-tag element |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | +Of course you can change standart 'True' 'False' labels on what want to |
| 242 | + |
| 243 | +```php |
| 244 | +public function fields(Request $request) |
| 245 | + { |
| 246 | + return [ |
| 247 | + ID::make()->sortable(), |
| 248 | + ElementCheckbox::make('Boolean') |
| 249 | + ->falseLabel('Off') |
| 250 | + ->trueLabel('On') |
| 251 | + ]; |
| 252 | + } |
| 253 | +``` |
| 254 | + |
| 255 | + |
| 256 | +If you d'not want to be displayed el-tag you can hide it with ```showTagOnIndex()``` ```showTagOnDetail()``` |
| 257 | + |
| 258 | +```php |
| 259 | +public function fields(Request $request) |
| 260 | + { |
| 261 | + return [ |
| 262 | + ID::make()->sortable(), |
| 263 | + ElementCheckbox::make('Boolean') |
| 264 | + ->falseLabel('Off') |
| 265 | + ->trueLabel('On') |
| 266 | + ->showTagOnDetail(false) |
| 267 | + ->showTagOnIndex(false) |
| 268 | + ]; |
| 269 | + } |
| 270 | +``` |
| 271 | + |
| 272 | +When you just see only label |
| 273 | + |
| 274 | +#### ElementSwitch |
| 275 | + |
| 276 | +ElementSwitch is depends on ElementCheckbox |
| 277 | + |
| 278 | +```php |
| 279 | +public function fields(Request $request) |
| 280 | + { |
| 281 | + return [ |
| 282 | + ID::make()->sortable(), |
| 283 | + ElementSwitch::make('Boolean') |
| 284 | + ->falseLabel('Off') |
| 285 | + ->trueLabel('On') |
| 286 | + ]; |
| 287 | + } |
| 288 | +``` |
| 289 | + |
| 290 | + |
| 291 | + |
| 292 | +If you want to show your labels on switch use ```showLabels()``` method |
| 293 | + |
| 294 | +```php |
| 295 | +public function fields(Request $request) |
| 296 | + { |
| 297 | + return [ |
| 298 | + ID::make()->sortable(), |
| 299 | + ElementSwitch::make('Boolean') |
| 300 | + ->falseLabel('Off') |
| 301 | + ->trueLabel('On') |
| 302 | + ->showLabels() |
| 303 | + ]; |
| 304 | + } |
| 305 | +``` |
| 306 | + |
| 307 | + |
| 308 | +Also you can change active/inactive colors on switch |
| 309 | + |
| 310 | +```php |
| 311 | +public function fields(Request $request) |
| 312 | + { |
| 313 | + return [ |
| 314 | + ID::make()->sortable(), |
| 315 | + ElementSwitch::make('Boolean') |
| 316 | + ->falseLabel('Off') |
| 317 | + ->trueLabel('On') |
| 318 | + ->showLabels() |
| 319 | + ->activeColor('#13ce66') |
| 320 | + ->inactiveColor('#ff4949') |
| 321 | + ]; |
| 322 | + } |
| 323 | +``` |
| 324 | + |
| 325 | + |
| 326 | + |
| 327 | + |
| 328 | +## Components in progress |
| 329 | + |
| 330 | +* ~~Input~~ |
| 331 | +* ~~Number~~ |
| 332 | +* ~~Select~~ |
| 333 | +* ~~Autocomplete~~ |
| 334 | +* ~~Checkbox~~ |
| 335 | +* ~~Radio~~ |
| 336 | +* ~~Switch~~ |
| 337 | +* Date |
| 338 | +* Time |
| 339 | +* DateTime |
| 340 | +* DataTimeRange |
| 341 | +* Tabs |
| 342 | +* Upload |
| 343 | +* Slider |
| 344 | +* Cascader |
| 345 | +* Upload |
| 346 | +* Transfer |
| 347 | + |
| 348 | +## Built With |
| 349 | + |
| 350 | +* [Laravel Nova](http://nova.laravel.com) - The best admin panel for Laravel |
| 351 | +* [Element UI](http://element.eleme.io/#/en-US/) - The best set of components for Vue.js |
| 352 | + |
| 353 | +## License |
| 354 | + |
| 355 | +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details |
0 commit comments