-
Notifications
You must be signed in to change notification settings - Fork 1
Rewrite guides using skills (final) #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from all commits
ec660c4
8fb6c86
a98f9bf
c8137cb
98c90af
1a27d20
00b7bce
07111cc
9c4af58
3b123cf
0418ac5
da6c167
1696039
3b13a20
c09e6fc
7368a73
7eb3b1e
97e22bd
0fefd63
133ca8e
4145d02
606f70f
840a185
7414a86
1d1b003
c9769f4
2114018
e6b1c87
f46c43e
668a7de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,37 +6,139 @@ description: You can learn about the customization in the documentation of the D | |
|
|
||
| # Customization | ||
|
|
||
| Besides configuring Kanban, you can customize its appearance and behaviour. The widget allows you to specify a custom template for cards, modify a context menu for cards, columns and rows, change the Toolbar structure and functionality, and apply custom css styles to Kanban. | ||
| You can customize the Kanban appearance and behavior with the following properties: | ||
|
|
||
| - [`cardTemplate`](api/config/js_kanban_cardtemplate_config.md) — render cards with a custom HTML template | ||
| - [`cardShape.menu`](api/config/js_kanban_cardshape_config.md), [`columnShape.menu`](api/config/js_kanban_columnshape_config.md), [`rowShape.menu`](api/config/js_kanban_rowshape_config.md) — modify the context menu for cards, columns, and rows | ||
| - [`columnShape.headerTemplate`](api/config/js_kanban_columnshape_config.md), [`columnShape.collapsedTemplate`](api/config/js_kanban_columnshape_config.md) — replace column header templates | ||
| - [`cardShape.css`](api/config/js_kanban_cardshape_config.md), [`columnShape.css`](api/config/js_kanban_columnshape_config.md), [`rowShape.css`](api/config/js_kanban_rowshape_config.md) — apply CSS classes conditionally | ||
| - [`items`](api/config/toolbar_items_config.md) — rearrange Toolbar structure and add custom controls | ||
| - CSS variables — adjust visual styles (see the [Stylization](guides/stylization.md) section) | ||
|
|
||
| ## Custom cards | ||
|
|
||
| To display cards by a custom template, you can use the [`cardTemplate`](api/config/js_kanban_cardtemplate_config.md) property. It is a callback function that allows you to define the desired styles and logic and apply it to Kanban. See the snippet below: | ||
| Use the [`cardTemplate`](api/config/js_kanban_cardtemplate_config.md) property to render cards with a custom HTML template. The callback returns the markup for each card. | ||
|
|
||
| The callback receives an object with the following parameters: | ||
|
|
||
| - `cardFields` — card data | ||
| - `selected` — whether the card is selected | ||
| - `dragging` — whether the card is being dragged | ||
| - `cardShape` — card configuration | ||
|
|
||
| To embed a context menu trigger in a custom card template, wrap the menu icon in a `<div>` with the `data-menu-id=${cardFields.id}` attribute (the same structure as the built-in card). The widget binds the menu to the wrapper through this attribute. | ||
|
|
||
| The following demo applies a custom card template: | ||
|
|
||
| <iframe src="https://snippet.dhtmlx.com/8rhdq81d?mode=js&tag=kanban" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe> | ||
|
|
||
| ## Custom context menu | ||
|
|
||
| To customize a context menu for cards, columns and rows, you can use the corresponding [`cardShape`](api/config/js_kanban_cardshape_config.md), [`columnShape`](api/config/js_kanban_columnshape_config.md) and [`rowShape`](api/config/js_kanban_rowshape_config.md) properties. See the snippet below: | ||
| Configure the context menu for cards, columns, and rows through the [`cardShape.menu`](api/config/js_kanban_cardshape_config.md), [`columnShape.menu`](api/config/js_kanban_columnshape_config.md), and [`rowShape.menu`](api/config/js_kanban_rowshape_config.md) properties. Each `menu.items` entry can use a built-in action ID to invoke a default operation, or define a custom `onClick` handler for any other behavior. | ||
|
|
||
| <iframe src="https://snippet.dhtmlx.com/8eo65gr5?mode=js&tag=kanban" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe> | ||
| ### `cardShape.menu` | ||
|
|
||
| By default the card menu shows **Duplicate** and **Delete** options. The **Edit** option appears only when card editing is enabled and selection is disabled. Available built-in action IDs: | ||
|
|
||
| ## Custom toolbar | ||
| - `"duplicate-card"` — duplicate the card | ||
| - `"delete-card"` — delete the card | ||
| - `"set-edit"` — open the card editor (shown when editing is available) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah no. set-edit is shown under very specific circumstances:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...so I would not place it in the default options at all |
||
|
|
||
| To customize the Toolbar structure and its functionality, you can use the [`items`](api/config/toolbar_items_config.md) property. In the array of this config you can define controls you need, arrange them in the desired order as well as modify their behaviour. | ||
| ### `columnShape.menu` | ||
|
|
||
| In the snippet below you can see how to customize the following: | ||
| - `"add-card"` — add a new card to the column | ||
| - `"set-edit"` — rename the column | ||
| - `"move-column:left"`, `"move-column:right"` — move the column left or right | ||
| - `"delete-column"` — delete the column | ||
|
|
||
| ### `rowShape.menu` | ||
|
|
||
| - `"set-edit"` — rename the row | ||
| - `"move-row:up"`, `"move-row:down"` — move the row up or down | ||
| - `"delete-row"` — delete the row | ||
|
|
||
| Set `menu.items` to a function to render a different menu per card, column, or row. Return `null` or `false` from the function to hide the menu for a specific item. | ||
|
|
||
| The following demo applies a custom context menu: | ||
|
|
||
| <iframe src="https://snippet.dhtmlx.com/8eo65gr5?mode=js&tag=kanban" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe> | ||
|
|
||
| - an order of controls arrangement | ||
| - a searchbar and its behaviour | ||
| - a sort control and its behaviour | ||
| - a custom control and its behaviour | ||
| ## Custom column headers | ||
|
|
||
| The [`columnShape`](api/config/js_kanban_columnshape_config.md) property provides templates and behavior for column headers: | ||
|
|
||
| - [`columnShape.headerTemplate`](api/config/js_kanban_columnshape_config.md) — HTML template of the column header in the expanded state | ||
| - [`columnShape.collapsedTemplate`](api/config/js_kanban_columnshape_config.md) — HTML template of the column header in the collapsed state | ||
| - [`columnShape.fixedHeaders`](api/config/js_kanban_columnshape_config.md) — freeze column headers during vertical scroll (default: `true`) | ||
|
|
||
| The following code snippet sets a custom header template with a collapse icon, label with card count, and menu trigger: | ||
|
|
||
| ~~~jsx {5-21} | ||
| new kanban.Kanban("#root", { | ||
| columns, | ||
| cards, | ||
| columnShape: { | ||
| headerTemplate: kanban.template(({ column, columnState }) => { | ||
| return `<div class="wx-collapse-icon" data-action="collapse"> | ||
| <i class="${column.collapsed ? "wxi-angle-right" : "wxi-angle-left"}"></i> | ||
| </div> | ||
| ${!column.collapsed | ||
| ? `<div class="wx-label" data-action="rename"> | ||
| ${column.label} (${columnState.cardsCount}) | ||
| </div> | ||
| <div class="wx-menu" data-menu-id="${column.id}"> | ||
| <i class="wxi-dots-h"></i> | ||
| </div>` | ||
| : ""}`; | ||
| }), | ||
| collapsedTemplate: kanban.template(({ column }) => `<div class="wx-collapsed-label">${column.label}</div>`) | ||
| } | ||
| }); | ||
| ~~~ | ||
|
|
||
| :::tip | ||
| For `fixedHeaders` to take effect, set a fixed height on the Kanban container so the board scrolls vertically. | ||
| ::: | ||
|
|
||
| ## Conditional CSS classes | ||
|
|
||
| To apply a CSS class conditionally, pass a function to the `css` parameter of [`cardShape`](api/config/js_kanban_cardshape_config.md), [`columnShape`](api/config/js_kanban_columnshape_config.md), or [`rowShape`](api/config/js_kanban_rowshape_config.md). The function returns a class name based on the current data: | ||
|
|
||
| - [`cardShape.css: (card) => string`](api/config/js_kanban_cardshape_config.md) — class applied to a card | ||
| - [`columnShape.css: (column, cards) => string`](api/config/js_kanban_columnshape_config.md) — class applied to a column | ||
| - [`rowShape.css: (row, cards) => string`](api/config/js_kanban_rowshape_config.md) — class applied to a row | ||
|
|
||
| The following code snippet highlights overdue cards and underloaded columns: | ||
|
|
||
| ~~~jsx {5,8} | ||
| new kanban.Kanban("#root", { | ||
| columns, | ||
| cards, | ||
| cardShape: { | ||
| css: (card) => card.end_date < new Date() ? "overdue" : "" | ||
| }, | ||
| columnShape: { | ||
| css: (column, cards) => cards.length < 5 ? "low-load" : "" | ||
| } | ||
| }); | ||
| ~~~ | ||
|
|
||
| ## Custom Toolbar | ||
|
|
||
| Use the [`items`](api/config/toolbar_items_config.md) property to customize the Toolbar structure. The array defines which controls appear, their order, and their behavior. An entry can be: | ||
|
|
||
| - a built-in control: `"search"`, `"sort"`, `"undo"`, `"redo"`, `"addColumn"`, `"addRow"`, `"spacer"` | ||
| - an object that overrides the searchbar or sort control with custom options | ||
| - a custom control passed as a string identifier or a function | ||
|
|
||
| The following demo customizes the order of controls, the searchbar, the sort control, and a custom control: | ||
|
|
||
| <iframe src="https://snippet.dhtmlx.com/s5r5h4ju?mode=js&tag=kanban" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe> | ||
|
|
||
| ## Custom styles | ||
|
|
||
| You can customize the appearance of Kanban by changing values of the corresponding *CSS variables*. Refer to the [**Stylization**](guides/stylization.md) section for details. | ||
| Change the values of CSS variables to customize the Kanban appearance. See the [Stylization](guides/stylization.md) section for the full list. | ||
|
|
||
| In this snippet you can see how to apply custom styles to Kanban: | ||
| The following snippet applies custom styles to Kanban: | ||
|
|
||
| <iframe src="https://snippet.dhtmlx.com/oj18xwb5?mode=html&tag=kanban" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe> | ||
Uh oh!
There was an error while loading. Please reload this page.