Skip to content

Commit

Permalink
Add Bootstrap 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Jan 9, 2024
1 parent cc9bc9f commit 252edb3
Show file tree
Hide file tree
Showing 20 changed files with 604 additions and 21 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ composer require nepada/file-upload-control

### Register and configure container extension

The only required configuration option is `uploadDirectory`, which determines where are the uploaded files temporarily stored.
The only required configuration option is `uploadDirectory`, which determines where are the uploaded files temporarily stored.
```yaml
extensions:
fileUploadControl: Nepada\Bridges\FileUploadControlDI\FileUploadControlExtension
Expand Down Expand Up @@ -90,7 +90,7 @@ interface FormFactory
public function create(): Form;
}
```
```


Usage
Expand All @@ -112,15 +112,22 @@ fileUpload:
height: 150
```

The package includes templates and styles build for Bootstrap [version 4](https://getbootstrap.com/docs/4.6/) and [version 5](https://getbootstrap.com/docs/5.3/). By default, version 4 is used, but to improve forward compatibility you should always explicitly specify which version you'd like to be used:
```yaml
fileUpload:
templateFile: ::constant(Nepada\FileUploadControl\FileUploadControl::TEMPLATE_FILE_BOOTSTRAP4)
# or for Bootstrap 5
# templateFile: ::constant(Nepada\FileUploadControl\FileUploadControl::TEMPLATE_FILE_BOOTSTRAP5)
```

### Validation

All standard Nette file upload related validations work as expected. Furthermore, you can limit the number of allowed uploads by "length" rules.
All standard Nette file upload related validations work as expected. Furthermore, you can limit the number of allowed uploads by "length" rules.

### Client side

This package comes with client side built on top of [blueimp-file-upload](https://yarnpkg.com/package/blueimp-file-upload). It is published as npm package [@nepada/file-upload-control](https://yarnpkg.com/package/@nepada/file-upload-control).

The default Latte template and bundled styles are build for [Bootstrap 4](https://yarnpkg.com/package/bootstrap).
![Bootstrap 4 theme](docs/example.png)

#### Using precompiled bundle
Expand All @@ -129,18 +136,21 @@ Using precompiled bundles is the quick'n'dirty way of getting client side to wor

```html
<link rel="stylesheet" href="https://unpkg.com/@nepada/file-upload-control@%5E1.7/dist/css/file-upload-control-bootstrap4.min.css">
<!-- or for Bootstrap 5
<link rel="stylesheet" href="https://unpkg.com/@nepada/file-upload-control@%5E1.7/dist/css/file-upload-control-bootstrap5.min.css">
-->
<script src="https://unpkg.com/jquery@%5E3.5.0/dist/jquery.min.js"></script>
<script src="https://unpkg.com/blueimp-file-upload@%5E10.10.0/js/vendor/jquery.ui.widget.js"></script>
<script src="https://unpkg.com/blueimp-file-upload@%5E10.10.0/js/jquery.fileupload.js"></script>
<script src="https://unpkg.com/nette-forms@%5E3.0.3/src/assets/netteForms.min.js"></script>
<script src="https://unpkg.com/@nepada/file-upload-control@%5E1.0/dist/js/file-upload-control.min.js"></script>
<script src="https://unpkg.com/@nepada/file-upload-control@%5E1.7/dist/js/file-upload-control.min.js"></script>
```

#### Building your own bundle

It is highly recommended to install the client side package via nmp and compile your own bundle.

Here is an example script for initialization of file upload control and Nette forms.
Here is an example script for initialization of file upload control and Nette forms.

```js
import Nette from 'nette-forms';
Expand All @@ -151,4 +161,6 @@ initializeFileUploadControl(Nette);
Nette.initOnLoad();
```

You can also customize the default look by importing the [source sass files](src/assets/scss/_file-upload-control-module-bootstrap4.scss), or writing your own from scratch.
If you use Bootstrap 4 or 5, you can easily customize the default look by importing the source SCSS files into your Sass styles:
- [_file-upload-control-module-bootstrap4.scss](src/assets/scss/_file-upload-control-module-bootstrap4.scss), see also available [variables](src/assets/scss/partials-bootstrap4/_variables.scss) for overrides
- [_file-upload-control-module-bootstrap5.scss](src/assets/scss/_file-upload-control-module-bootstrap5.scss), see also available [variables](src/assets/scss/partials-bootstrap5/_variables.scss) for overrides
144 changes: 144 additions & 0 deletions dist/css/file-upload-control-bootstrap5.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/css/file-upload-control-bootstrap5.css.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/css/file-upload-control-bootstrap5.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 252edb3

Please sign in to comment.