1
0
mirror of https://github.com/tabler/tabler.git synced 2026-06-17 12:50:03 +04:00

Add selectable table functionality with active background color (#2171)

This commit is contained in:
Paweł Kuna
2025-02-19 03:16:53 +01:00
committed by GitHub
parent 378fba89f5
commit edbaa1eddd
7 changed files with 26 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@tabler/core": minor
---
Add selectable table functionality with active background color
+1
View File
@@ -864,6 +864,7 @@ $table-th-bg: var(--#{$prefix}bg-surface-tertiary) !default;
$table-striped-order: even !default; $table-striped-order: even !default;
$table-striped-bg: var(--#{$prefix}bg-surface-tertiary) !default; $table-striped-bg: var(--#{$prefix}bg-surface-tertiary) !default;
$table-group-separator-color: var(--#{$prefix}border-color-translucent) !default; $table-group-separator-color: var(--#{$prefix}border-color-translucent) !default;
$table-active-bg: var(--#{$prefix}active-bg) !default;
$table-sort-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1'><path d='M5 7l3 -3l3 3'/><path d='M5 10l3 3l3 -3'/></svg>") !default; $table-sort-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1'><path d='M5 7l3 -3l3 3'/><path d='M5 10l3 3l3 -3'/></svg>") !default;
$table-sort-asc-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1' d='M5 7l3 3l3 -3'/></svg>") !default; $table-sort-asc-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1' d='M5 7l3 3l3 -3'/></svg>") !default;
+11
View File
@@ -148,3 +148,14 @@ Table sort
background: transparent; background: transparent;
} }
} }
//
// Table selectable
//
.table-selectable {
tbody tr {
&:has(.table-selectable-check:checked) {
background-color: $table-active-bg;
}
}
}
+3 -3
View File
@@ -504,11 +504,11 @@ export default function (eleventyConfig) {
}); });
eleventyConfig.addFilter("random_date", function (x, startDate = null, endDate = null) { eleventyConfig.addFilter("random_date", function (x, startDate = null, endDate = null) {
const start = startDate ? new Date(startDate).getTime() : Date.now() - 100 * 24 * 60 * 60 * 1000; const start = new Date(startDate ? startDate : '2024-01-01').getTime() / 1000;
const end = endDate ? new Date(endDate).getTime() : Date.now(); const end = new Date(endDate ? endDate : '2024-12-30').getTime() / 1000;
const randomTimestamp = randomNumber(x, start, end); const randomTimestamp = randomNumber(x, start, end);
return new Date(randomTimestamp); return new Date(randomTimestamp * 1000);
}); });
eleventyConfig.addFilter("random_item", function (x, items) { eleventyConfig.addFilter("random_item", function (x, items) {
+2 -2
View File
@@ -23,7 +23,7 @@
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table card-table table-vcenter text-nowrap datatable"> <table class="table table-selectable card-table table-vcenter text-nowrap datatable">
<thead> <thead>
<tr> <tr>
<th class="w-1"><input class="form-check-input m-0 align-middle" type="checkbox" aria-label="Select all invoices"></th> <th class="w-1"><input class="form-check-input m-0 align-middle" type="checkbox" aria-label="Select all invoices"></th>
@@ -41,7 +41,7 @@
<tbody> <tbody>
{% for invoice in invoices limit: 8 %} {% for invoice in invoices limit: 8 %}
<tr> <tr>
<td><input class="form-check-input m-0 align-middle" type="checkbox" aria-label="Select invoice"></td> <td><input class="form-check-input m-0 align-middle table-selectable-check" type="checkbox" aria-label="Select invoice"></td>
<td><span class="text-secondary">00{{ forloop.index | plus: 1400 }}</span></td> <td><span class="text-secondary">00{{ forloop.index | plus: 1400 }}</span></td>
<td><a href="invoice.html" class="text-reset" tabindex="-1">{{ invoice.name }}</a></td> <td><a href="invoice.html" class="text-reset" tabindex="-1">{{ invoice.name }}</a></td>
<td> <td>
+3 -3
View File
@@ -3,18 +3,18 @@
<h3 class="card-title">Tasks</h3> <h3 class="card-title">Tasks</h3>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table card-table table-vcenter"> <table class="table table-selectable card-table table-vcenter">
{% for task in tasks-list %} {% for task in tasks-list %}
<tr> <tr>
<td class="w-1 pe-0"> <td class="w-1 pe-0">
<input type="checkbox" class="form-check-input m-0 align-middle" aria-label="Select task"{% if task.checked %} checked{% endif %} > <input type="checkbox" class="form-check-input m-0 align-middle table-selectable-check" aria-label="Select task"{% if task.checked %} checked{% endif %} >
</td> </td>
<td class="w-100"> <td class="w-100">
<a href="#" class="text-reset">{{ task.name }}</a> <a href="#" class="text-reset">{{ task.name }}</a>
</td> </td>
<td class="text-nowrap text-secondary"> <td class="text-nowrap text-secondary">
{% include "ui/icon.html" icon="calendar" %} {% include "ui/icon.html" icon="calendar" %}
{{ forloop.index | random_date: site.randomDateFrom, site.randomDateTo | date: '%B %d, %Y' }} {{ forloop.index | random_date | date: '%B %d, %Y' }}
</td> </td>
<td class="text-nowrap"> <td class="text-nowrap">
<a href="#" class="text-secondary"> <a href="#" class="text-secondary">
+1 -1
View File
@@ -33,7 +33,7 @@ permalink: datatables.html
<td class="sort-city">{{ rc.city }}</td> <td class="sort-city">{{ rc.city }}</td>
<td class="sort-type">{{ rc.type }}</td> <td class="sort-type">{{ rc.type }}</td>
<td class="sort-score">{{ rc.score }}</td> <td class="sort-score">{{ rc.score }}</td>
<td class="sort-date" data-date="{{ forloop.index | random_date: site.randomDateFrom, site.randomDateTo | date: '%s' }}">{{ forloop.index | random_date: site.randomDateFrom, site.randomDateTo | date: '%B %d, %Y' }}</td> <td class="sort-date" data-date="{{ forloop.index | random_date | date: '%s' }}">{{ forloop.index | random_date | date: '%B %d, %Y' }}</td>
<td class="sort-quantity">{{ forloop.index | random_number: 1, 200 }}</td> <td class="sort-quantity">{{ forloop.index | random_number: 1, 200 }}</td>
<td class="sort-progress" data-progress="{{ progress }}"> <td class="sort-progress" data-progress="{{ progress }}">
<div class="row align-items-center"> <div class="row align-items-center">