creecros / MetaMagik

Custom Fields for Kanboard - Plugin MetaMagik
MIT License
98 stars 16 forks source link

Add data-key and data-value to HTML elements #91

Open h-e-l-l-o-w-o-r-l-d opened 1 year ago

h-e-l-l-o-w-o-r-l-d commented 1 year ago

Hi,

I would like to style the metamagik information in the card footer and tables. For example hide key x, or set background color for value y or add an icon before value y via CSS :before and so on. Right now this is not possible with plain CSS and I don't want to use JS. It would be possible by adding a lowercased data-key (for title and value) and data-value (for value) to the html elements in these files:

https://github.com/creecros/MetaMagik/blob/761e6d373258e21df7a6a93fae393525853e999f/Template/task/meta_footers.php https://github.com/creecros/MetaMagik/blob/761e6d373258e21df7a6a93fae393525853e999f/Template/task/metatable.php

So instead of

<span class="metamagik-footer-title"><strong> <?= $custom_field['beauty_name'] ?>: </strong></span>

go with

<span class="metamagik-footer-title" data-key="<?= $custom_field['machine_name'] ?>"><strong> <?= $custom_field['beauty_name'] ?>: </strong></span>

and instead of

<span class="metamagik-footer-value"><?= $this->task->taskMetadataModel->get($task['id'], $custom_field['human_name'], '') ?></span>

go with

<span class="metamagik-footer-value" data-key="<?= $custom_field['machine_name'] ?>" data-value="<?= strtolower($this->task->taskMetadataModel->get($task['id'], $custom_field['human_name'], '')) ?>"><?= $this->task->taskMetadataModel->get($task['id'], $custom_field['human_name'], '') ?></span>

Same for other span elements of course (textarea, number, date...) and in metatable.php accordingly.

The changes would be very small but making the plugin more flexible and nothing would break. ;o)

Thanks in advance and thank you for this very useful plugin.