Ejemplo: "Tabla con todo", de código HTML, para maquetar el componente: "Table Advanced", versión: 12.1.0, del sistema de diseño DESY
Para compilar el css del siguiente código deberás instalar Tailwind CSS y usar el archivo tailwind.config.js del proyecto: https://bitbucket.org/sdaragon/desy-html/
Para que funcione el comportamiento del siguiente código deberás importar el archivo index.js y todos los archivos javascript de la carpeta /src/js y /src/js/aria del proyecto: https://bitbucket.org/sdaragon/desy-html/
Usar sólo el código que está dentro de la siguiente etiqueta <code>.
<!-- table-advanced -->
<table class="c-table-advanced border-t-2 border-b-2 border-neutral-base min-w-full" data-module="c-table-advanced" role="grid" aria-readonly="true">
<thead>
<tr class="border-t border-neutral-base divide-x divide-neutral-base">
<th scope="col" class="align-top px-base py-xs">
<span class="sr-only">Seleccionar fila</span>
</th>
<th scope="col" id="table-with-all-header-0" class="align-top px-base py-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark">
<span class="inline-block relative">
Identificador
</span>
</th>
<th aria-sort="none" scope="col" id="table-with-all-header-1" class="align-top px-base py-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark">
<span class="inline-block relative" tabindex="-1" role="button">
Mes de pago
<span class="c-table-advanced__order">
<span class="sr-only">Pulsa para ordenar por esta columna</span>
<span class="c-table-advanced__ascending">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" aria-hidden="true" width="1em" height="1em">
<path d="M112.07 37.93l-35-35a10 10 0 00-14.14 0l-35 35a10 10 0 0014.14 14.14l13.66-13.66A2.5 2.5 0 0160 40.18V130a10 10 0 0020 0V40.18a2.5 2.5 0 014.27-1.77l13.66 13.66a10 10 0 0014.14-14.14z" fill="currentColor" />
</svg>
</span>
<span class="c-table-advanced__descending">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" aria-hidden="true" width="1em" height="1em">
<path d="M27.93 102.07l35 35a10 10 0 0014.14 0l35-35a10 10 0 00-14.14-14.14l-13.66 13.66A2.5 2.5 0 0180 99.82V10a10 10 0 00-20 0v89.82a2.5 2.5 0 01-4.27 1.77L42.07 87.93a10 10 0 00-14.14 14.14z" fill="currentColor" />
</svg>
</span>
<span class="c-table-advanced__none">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" class="text-neutral-dark" aria-hidden="true" width="1em" height="1em">
<path d="M94.7 97.2l-17.2 17.19V25.61L94.7 42.8a7.5 7.5 0 0010.6-10.6l-30-30a7.49 7.49 0 00-10.6 0l-30 30a7.5 7.5 0 0010.6 10.6l17.2-17.19v88.78L45.3 97.2a7.5 7.5 0 10-10.6 10.6l30 30a7.48 7.48 0 0010.6 0l30-30a7.5 7.5 0 00-10.6-10.6z" fill="currentColor" />
</svg>
</span>
</span>
</span>
</th>
<th aria-sort="none" scope="col" id="table-with-all-header-2" class="align-top px-base py-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark text-right">
<span class="inline-block relative" tabindex="-1" role="button">
Primer pago
<span class="c-table-advanced__order">
<span class="sr-only">Pulsa para ordenar por esta columna</span>
<span class="c-table-advanced__ascending">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" aria-hidden="true" width="1em" height="1em">
<path d="M112.07 37.93l-35-35a10 10 0 00-14.14 0l-35 35a10 10 0 0014.14 14.14l13.66-13.66A2.5 2.5 0 0160 40.18V130a10 10 0 0020 0V40.18a2.5 2.5 0 014.27-1.77l13.66 13.66a10 10 0 0014.14-14.14z" fill="currentColor" />
</svg>
</span>
<span class="c-table-advanced__descending">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" aria-hidden="true" width="1em" height="1em">
<path d="M27.93 102.07l35 35a10 10 0 0014.14 0l35-35a10 10 0 00-14.14-14.14l-13.66 13.66A2.5 2.5 0 0180 99.82V10a10 10 0 00-20 0v89.82a2.5 2.5 0 01-4.27 1.77L42.07 87.93a10 10 0 00-14.14 14.14z" fill="currentColor" />
</svg>
</span>
<span class="c-table-advanced__none">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" class="text-neutral-dark" aria-hidden="true" width="1em" height="1em">
<path d="M94.7 97.2l-17.2 17.19V25.61L94.7 42.8a7.5 7.5 0 0010.6-10.6l-30-30a7.49 7.49 0 00-10.6 0l-30 30a7.5 7.5 0 0010.6 10.6l17.2-17.19v88.78L45.3 97.2a7.5 7.5 0 10-10.6 10.6l30 30a7.48 7.48 0 0010.6 0l30-30a7.5 7.5 0 00-10.6-10.6z" fill="currentColor" />
</svg>
</span>
</span>
</span>
</th>
<th aria-sort="none" scope="col" id="table-with-all-header-3" class="align-top px-base py-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark text-right">
<span class="inline-block relative" tabindex="-1" role="button">
Segundo pago
<span class="c-table-advanced__order">
<span class="sr-only">Pulsa para ordenar por esta columna</span>
<span class="c-table-advanced__ascending">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" aria-hidden="true" width="1em" height="1em">
<path d="M112.07 37.93l-35-35a10 10 0 00-14.14 0l-35 35a10 10 0 0014.14 14.14l13.66-13.66A2.5 2.5 0 0160 40.18V130a10 10 0 0020 0V40.18a2.5 2.5 0 014.27-1.77l13.66 13.66a10 10 0 0014.14-14.14z" fill="currentColor" />
</svg>
</span>
<span class="c-table-advanced__descending">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" aria-hidden="true" width="1em" height="1em">
<path d="M27.93 102.07l35 35a10 10 0 0014.14 0l35-35a10 10 0 00-14.14-14.14l-13.66 13.66A2.5 2.5 0 0180 99.82V10a10 10 0 00-20 0v89.82a2.5 2.5 0 01-4.27 1.77L42.07 87.93a10 10 0 00-14.14 14.14z" fill="currentColor" />
</svg>
</span>
<span class="c-table-advanced__none">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" class="text-neutral-dark" aria-hidden="true" width="1em" height="1em">
<path d="M94.7 97.2l-17.2 17.19V25.61L94.7 42.8a7.5 7.5 0 0010.6-10.6l-30-30a7.49 7.49 0 00-10.6 0l-30 30a7.5 7.5 0 0010.6 10.6l17.2-17.19v88.78L45.3 97.2a7.5 7.5 0 10-10.6 10.6l30 30a7.48 7.48 0 0010.6 0l30-30a7.5 7.5 0 00-10.6-10.6z" fill="currentColor" />
</svg>
</span>
</span>
</span>
</th>
</tr>
</thead>
<tbody>
<tr class="divide-x divide-neutral-base">
<td></td>
<td tabindex="-1" class="align-top px-base pb-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark">
</td>
<td tabindex="-1" class="align-top px-base pb-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark">
<!-- searchbar -->
<!-- label -->
<label class="block sr-only sr-only" for="table-with-all-header-filter-1">Filtrar en esta columna</label>
<!-- /label -->
<div class="relative">
<input class="c-input block border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base pr-12 w-full c-input--sm" id="table-with-all-header-filter-1" name="table-with-all-header-filter-1" type="search" placeholder="Filtrar" aria-describedby="table-with-all-header-1">
<button type="submit" class="absolute top-0 right-0 m-sm p-0.5 text-primary-base hover:text-primary-dark focus:bg-warning-base focus:outline-none focus:shadow-outline-focus m-xs p-0.5 text-xs">
<span class="sr-only">Buscar</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1.375em" height="1.375em" aria-hidden="true">
<path d="M23.498 23.487a1.713 1.713 0 000-2.421l-4.572-4.575a.43.43 0 01-.062-.539 10.283 10.283 0 10-2.911 2.911.43.43 0 01.539.055l4.574 4.574a1.712 1.712 0 002.433-.005zM3.451 10.289a6.85 6.85 0 116.85 6.85 6.85 6.85 0 01-6.85-6.85z" fill="currentColor" />
</svg>
</button>
</div>
<!-- /searchbar -->
</td>
<td tabindex="-1" class="align-top px-base pb-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark text-right">
<!-- select -->
<div class="c-form-group -mt-sm mb-0">
<!-- label -->
<label class="block sr-only" for="table-with-all-header-select-2">Filtrar en esta columna</label>
<!-- /label -->
<select class="c-select block mt-sm transition duration-150 ease-in-out border-black rounded font-semibold focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base c-select--sm w-full" id="table-with-all-header-select-2" name="table-with-all-header-select-2" aria-describedby="table-with-all-header-2">
<option value="" selected disabled hidden>Filtrar por...</option>
<option value="1">Opción 1</option>
<option value="2">Opción 2</option>
<option value="3">Opción 3</option>
</select>
</div>
<!-- /select -->
</td>
<td tabindex="-1" class="align-top px-base pb-sm border-neutral-base border-b-0 text-left text-sm font-normal text-neutral-dark text-right">
<!-- select -->
<div class="c-form-group -mt-sm mb-0">
<!-- label -->
<label class="block sr-only" for="table-with-all-header-select-3">Filtrar en esta columna</label>
<!-- /label -->
<select class="c-select block mt-sm transition duration-150 ease-in-out border-black rounded font-semibold focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base c-select--sm w-full" id="table-with-all-header-select-3" name="table-with-all-header-select-3" aria-describedby="table-with-all-header-3">
<option value="" selected disabled hidden>Filtrar por...</option>
<option value="1">Opción 1</option>
<option value="2">Opción 2</option>
<option value="3">Opción 3</option>
</select>
</div>
<!-- /select -->
<div class="pb-sm"></div>
<!-- searchbar -->
<!-- label -->
<label class="block sr-only sr-only" for="table-with-all-header-filter-3">Filtrar en esta columna</label>
<!-- /label -->
<div class="relative">
<input class="c-input block border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base pr-12 w-full c-input--sm" id="table-with-all-header-filter-3" name="table-with-all-header-filter-3" type="search" placeholder="Filtrar" aria-describedby="table-with-all-header-3">
<button type="submit" class="absolute top-0 right-0 m-sm p-0.5 text-primary-base hover:text-primary-dark focus:bg-warning-base focus:outline-none focus:shadow-outline-focus m-xs p-0.5 text-xs">
<span class="sr-only">Buscar</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1.375em" height="1.375em" aria-hidden="true">
<path d="M23.498 23.487a1.713 1.713 0 000-2.421l-4.572-4.575a.43.43 0 01-.062-.539 10.283 10.283 0 10-2.911 2.911.43.43 0 01.539.055l4.574 4.574a1.712 1.712 0 002.433-.005zM3.451 10.289a6.85 6.85 0 116.85 6.85 6.85 6.85 0 01-6.85-6.85z" fill="currentColor" />
</svg>
</button>
</div>
<!-- /searchbar -->
</td>
</tr>
<tr class="border-t border-b border-neutral-base hover:bg-neutral-lighter">
<td class="px-base py-sm" tabindex="-1">
<div class="c-checkboxes c-checkboxes--sm">
<div>
<div class="relative flex items-start">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base text-primary-base" id="table-with-all-checkbox-0" name="table-with-all-checkbox-0" type="checkbox" value="table-checkbox">
</div>
<div class="pt-0.5 leading-5">
<label class="sr-only block text-sm -mt-1" for="table-with-all-checkbox-0">Selecciona fila 3</label>
</div>
</div>
</div>
</div>
</td>
<th scope="row" class="px-base py-xs border-neutral-base border-b-0 border-r text-left font-normal text-sm text-neutral-dark">A</th>
<td tabindex="-1" class="px-base py-sm">Enero</td>
<td tabindex="-1" class="px-base py-sm text-right">85€</td>
<td tabindex="-1" class="px-base py-sm text-right">95€</td>
</tr>
<tr class="border-t border-b border-neutral-base hover:bg-neutral-lighter">
<td class="px-base py-sm" tabindex="-1">
<div class="c-checkboxes c-checkboxes--sm">
<div>
<div class="relative flex items-start">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base text-primary-base" id="table-with-all-checkbox-1" name="table-with-all-checkbox-1" type="checkbox" value="table-checkbox">
</div>
<div class="pt-0.5 leading-5">
<label class="sr-only block text-sm -mt-1" for="table-with-all-checkbox-1">Selecciona fila 4</label>
</div>
</div>
</div>
</div>
</td>
<th scope="row" class="px-base py-xs border-neutral-base border-b-0 border-r text-left font-normal text-sm text-neutral-dark">B</th>
<td tabindex="-1" class="px-base py-sm">Febrero</td>
<td tabindex="-1" class="px-base py-sm text-right">75€</td>
<td tabindex="-1" class="px-base py-sm text-right">55€</td>
</tr>
<tr class="border-t border-b border-neutral-base hover:bg-neutral-lighter">
<td class="px-base py-sm" tabindex="-1">
<div class="c-checkboxes c-checkboxes--sm">
<div>
<div class="relative flex items-start">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base text-primary-base" id="table-with-all-checkbox-2" name="table-with-all-checkbox-2" type="checkbox" value="table-checkbox">
</div>
<div class="pt-0.5 leading-5">
<label class="sr-only block text-sm -mt-1" for="table-with-all-checkbox-2">Selecciona fila 5</label>
</div>
</div>
</div>
</div>
</td>
<th scope="row" class="px-base py-xs border-neutral-base border-b-0 border-r text-left font-normal text-sm text-neutral-dark">C</th>
<td tabindex="-1" class="px-base py-sm">Marzo</td>
<td tabindex="-1" class="px-base py-sm text-right">165€</td>
<td tabindex="-1" class="px-base py-sm text-right">125€</td>
</tr>
</tbody>
<tfoot>
<tr class="border-t-2 border-b border-neutral-base hover:bg-neutral-lighter">
<td class="px-base py-sm" tabindex="-1">
<div class="c-checkboxes c-checkboxes--sm">
<div>
<div class="relative flex items-start">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base text-primary-base" id="table-with-all-tfoot-checkbox-0" name="table-with-all-tfoot-checkbox-0" type="checkbox" value="table-checkbox">
</div>
<div class="pt-0.5 leading-5">
<label class="sr-only block text-sm -mt-1" for="table-with-all-tfoot-checkbox-0">Selecciona fila 2</label>
</div>
</div>
</div>
</div>
</td>
<th scope="row" class="px-base py-xs border-neutral-base border-b-0 border-r text-left font-normal text-sm text-neutral-dark uppercase">Suma</th>
<td tabindex="-1" class="px-base py-sm"></td>
<td tabindex="-1" class="px-base py-sm text-right">325€</td>
<td tabindex="-1" class="px-base py-sm text-right">275€</td>
</tr>
</tfoot>
</table>
<!-- /table-advanced -->
Ejemplo: "Tabla con todo", de código Nunjucks, para maquetar el componente: "Table Advanced", versión: 12.1.0, del sistema de diseño DESY
Pegar en la página: pagina-prueba-EDITA-PARA-EMPEZAR.html del proyecto: https://bitbucket.org/sdaragon/desy-html-starter/
Usar sólo el código que está dentro de la siguiente etiqueta <code>.
{% from "components/table-advanced/_macro.table-advanced.njk" import componentTableAdvanced %}
{{ componentTableAdvanced({
"idPrefix": "table-with-all",
"hasCheckboxes": true,
"firstCellIsHeader": true,
"head": [
{
"text": "Identificador"
},
{
"text": "Mes de pago",
"orderBy": "none",
"hasFilter": true
},
{
"text": "Primer pago",
"orderBy": "none",
"classes": "text-right",
"select": {
"items": [
{
"value": "",
"text": "Filtrar por...",
"disabled": true,
"selected": true,
"hidden": true
},
{
"value": 1,
"text": "Opción 1"
},
{
"value": 2,
"text": "Opción 2"
},
{
"value": 3,
"text": "Opción 3"
}
]
}
},
{
"text": "Segundo pago",
"orderBy": "none",
"classes": "text-right",
"hasFilter": true,
"select": {
"items": [
{
"value": "",
"text": "Filtrar por...",
"disabled": true,
"selected": true,
"hidden": true
},
{
"value": 1,
"text": "Opción 1"
},
{
"value": 2,
"text": "Opción 2"
},
{
"value": 3,
"text": "Opción 3"
}
]
}
}
],
"rows": [
[
{
"text": "A"
},
{
"text": "Enero"
},
{
"text": "85€",
"classes": "text-right"
},
{
"text": "95€",
"classes": "text-right"
}
],
[
{
"text": "B"
},
{
"text": "Febrero"
},
{
"text": "75€",
"classes": "text-right"
},
{
"text": "55€",
"classes": "text-right"
}
],
[
{
"text": "C"
},
{
"text": "Marzo"
},
{
"text": "165€",
"classes": "text-right"
},
{
"text": "125€",
"classes": "text-right"
}
]
],
"foot": [
[
{
"text": "Suma",
"classes": "uppercase"
},
{
"text": ""
},
{
"text": "325€",
"classes": "text-right"
},
{
"text": "275€",
"classes": "text-right"
}
]
],
"classes": "min-w-full"
}) }}