Skip to content

Commit a8ac697

Browse files
committed
Assets: mention plugins
1 parent 13f6504 commit a8ac697

File tree

2 files changed

+129
-17
lines changed

2 files changed

+129
-17
lines changed

.docs/assets.md

Lines changed: 129 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,116 @@
11
# Assets
22

3-
- [CDN](#cdn)
4-
- [Bundler](#bundler)
5-
- [Files](#files)
3+
- [Architecture](#architecture)
4+
- [Plugins](#plugins)
5+
- [Installation](#installation)
6+
- [CDN](#cdn)
7+
- [Bundler](#bundler)
8+
- [Example](#example)
69

710
-----
811

12+
# Architecture
13+
14+
The front-end part of the datagrid is completely rewritten in TypeScript, supports modern browsers and is fully customizable via plugins.
15+
16+
## Plugins
17+
18+
Datagrid has a lot of plugins. You can use them all or just some of them.
19+
20+
**Plugins (features)**
21+
22+
- AutosubmitPlugin
23+
- Sends form on change
24+
- CheckboxPlugin
25+
- Check/uncheck rows
26+
- ConfirmPlugin
27+
- Confirmation dialog before action
28+
- InlinePlugin (advanced)
29+
- Inline editing
30+
- EditablePlugin (advanced)
31+
- Inline editing
32+
- ItemDetailPlugin
33+
- Item detail view
34+
- TreeViewPlugin (advanced)
35+
- Tree view
36+
37+
**Plugins (integrations)**
38+
39+
- DatepickerPlugin
40+
- Abstraction for datepickers
41+
- HappyPlugin
42+
- Abstraction for happy-inputs
43+
- NetteFormsPlugin
44+
- Abstraction for Nette Forms
45+
- SelectpickerPlugin
46+
- Abstraction for selectpickers
47+
- SortablePlugin
48+
- Abstraction for sorting
49+
50+
**Integrations**
51+
52+
- Happy (+HappyPlugin)
53+
- Implementation for happy-inputs
54+
- [SortableJS](https://sortablejs.github.io/Sortable/) (+SortablePlugin)
55+
- Implementation for sorting
56+
- [TomSelect](https://tom-select.js.org/) (+SelectpickerPlugin)
57+
- Implementation of selectpicker
58+
- [VanillaDatepicker](https://github.com/mymth/vanillajs-datepicker) (+DatepickerPlugin)
59+
- Implementation of datepicker
60+
61+
**Example**
62+
63+
```js
64+
import {
65+
AutosubmitPlugin,
66+
CheckboxPlugin,
67+
ConfirmPlugin,
68+
createDatagrids,
69+
DatepickerPlugin,
70+
Happy,
71+
HappyPlugin,
72+
InlinePlugin,
73+
ItemDetailPlugin,
74+
NetteFormsPlugin,
75+
SelectpickerPlugin,
76+
SortableJS,
77+
SortablePlugin,
78+
TomSelect,
79+
TreeViewPlugin,
80+
VanillaDatepicker
81+
} from "../../vendor/ublaboo/datagrid/assets"
82+
83+
document.addEventListener("DOMContentLoaded", () => {
84+
createDatagrids(new NajaAjax(naja), {
85+
datagrid: {
86+
plugins: [
87+
new AutosubmitPlugin(),
88+
new CheckboxPlugin(),
89+
new ConfirmPlugin(),
90+
new InlinePlugin(),
91+
new ItemDetailPlugin(),
92+
new NetteFormsPlugin(netteForms),
93+
new HappyPlugin(new Happy()),
94+
new SortablePlugin(new SortableJS()),
95+
new DatepickerPlugin(new VanillaDatepicker({ buttonClass: 'btn' })),
96+
new SelectpickerPlugin(new TomSelect(Select)),
97+
new TreeViewPlugin(),
98+
],
99+
},
100+
});
101+
});
102+
```
103+
104+
# Installation
105+
9106
There are prepare JS/TS and CSS files for precise functionality.
10107

11108
You have 2 ways to use datagrid's assets:
12109

13-
1. Use frontend bundler.
14110
2. Use CDN assets.
111+
1. Use frontend bundler.
15112

16-
# CDN
113+
## CDN
17114

18115
Assets are available as NPM package [@contributte/datagrid](https://www.npmjs.com/package/@contributte/datagrid).
19116

@@ -28,9 +125,9 @@ You can use CDN assets like this:
28125
```
29126

30127
> [!NOTE]
31-
> CDN assets are not recommended for production. But you can use them for development.
128+
> CDN assets are not ideal for customization and optimization. Use bundler instead.
32129
33-
# Bundler
130+
## Bundler
34131

35132
This example uses [Vite](https://vitejs.dev). You can see example of using bundler in [datagrid-skeleton](https://github.com/contributte/datagrid-skeleton).
36133

@@ -75,9 +172,12 @@ Follow these steps:
75172
<script defer src="{$basePath}/dist/app.js"></script>
76173
```
77174

78-
### Files
175+
# Example
79176

80-
**package.json**
177+
This example uses [Vite](https://vitejs.dev). You can see example of using bundler in [datagrid-skeleton](https://github.com/contributte/datagrid-skeleton).
178+
179+
<details>
180+
<summary>**package.json**</summary>
81181

82182
```json
83183
{
@@ -107,7 +207,10 @@ Follow these steps:
107207
}
108208
```
109209

110-
**assets/js/main.js**
210+
</details>
211+
212+
<details>
213+
<summary>**assets/js/main.js**</summary>
111214

112215
```js
113216
import naja from "naja";
@@ -168,17 +271,27 @@ document.addEventListener("DOMContentLoaded", () => {
168271
});
169272
```
170273

171-
**assets/css/main.css**
274+
</details>
275+
276+
<details>
277+
<summary>**assets/css/main.css**</summary>
172278

173279
```css
174280
/* Datagrid styles */
175-
@import '../../vendor/ublaboo/datagrid/assets/css/datagrid-all.css';
281+
@import "@fortawesome/fontawesome-free/css/all.css";
282+
@import 'bootstrap/dist/css/bootstrap.css';
283+
@import 'vanillajs-datepicker/css/datepicker-bs5.css';
284+
@import "tom-select/dist/css/tom-select.css";
285+
@import '../../vendor/ublaboo/datagrid/assets/css/happy.css';
286+
@import '../../vendor/ublaboo/datagrid/assets/css/datagrid.css';
176287

177-
/* App styles */
178288
/* Your styles */
179289
```
180290

181-
**vite.config.mjs**
291+
</details>
292+
293+
<details>
294+
<summary>**vite.config.mjs**</summary>
182295

183296
```js
184297
import { defineConfig } from 'vite';
@@ -226,3 +339,5 @@ export default defineConfig(({ mode }) => {
226339
}
227340
});
228341
```
342+
343+
</details>

assets/css/datagrid-full.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/*
2-
* Use bootstrap and fontawesome from the CDN.
3-
*/
41
@import 'vanillajs-datepicker/dist/css/datepicker-bs5.css';
52
@import "tom-select/dist/css/tom-select.css";
63
@import './happy.css';

0 commit comments

Comments
 (0)