100 lines
No EOL
4.6 KiB
JSON
100 lines
No EOL
4.6 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "7d743307-e3d8-4664-a105-cfea980468a2"
|
|
}
|
|
],
|
|
"langcode": [
|
|
{
|
|
"value": "en"
|
|
}
|
|
],
|
|
"type": [
|
|
{
|
|
"target_id": "daily_email",
|
|
"target_type": "node_type",
|
|
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
|
}
|
|
],
|
|
"revision_timestamp": [
|
|
{
|
|
"value": "2025-04-21T01:21:27+00:00"
|
|
}
|
|
],
|
|
"revision_uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"revision_log": [],
|
|
"status": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"title": [
|
|
{
|
|
"value": "CSS, data attributes and feature flags"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2024-08-25T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-04-21T01:21:27+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2024\/08\/25\/css--data-attributes-and-feature-flags",
|
|
"langcode": "en"
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>I recently used <a href=\"https:\/\/www.drupal.org\/project\/feature_toggle\">Drupal's Feature Toggle module<\/a> to set a data attribute which enabled some new styling for buttons.<\/p>\n\n<p>Firstly, within the theme's .theme file, I added this code:<\/p>\n\n<pre><code class=\"php\">\/**\n * Implements hook_preprocess_html().\n *\/\nfunction mytheme_preprocess_html(array &$variables): void {\n $variables['attributes']['data-use-new-button-styles'] = \\Drupal::service('feature_toggle.feature_status')->getStatus('use_the_new_button_styling');\n}\n<\/code><\/pre>\n\n<p>If the feature toggle is enabled, it adds a <code>data-use-new-button-styles=\"\"<\/code> attribute to the <code>body<\/code> element.<\/p>\n\n<p>If it is disabled, the attribute is not added, so I can write CSS that's applied when the data attribute is present:<\/p>\n\n<pre><code class=\"css\">[data-use-new-button-styles] .btn-primary {\n background-color: red;\n}\n<\/code><\/pre>\n\n<p>In a Tailwind CSS project (this isn't), the same could be achiveable with a custom interaction state - similar to <code>hover<\/code>, <code>focus<\/code> and <code>active<\/code>. Something like <code>new-button-styles:bg-red-500<\/code>.<\/p>\n\n<p>I like using feature flags and was happy to find a way to use them when adding this new CSS.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>I recently used <a href=\"https:\/\/www.drupal.org\/project\/feature_toggle\">Drupal's Feature Toggle module<\/a> to set a data attribute which enabled some new styling for buttons.<\/p>\n\n<p>Firstly, within the theme's .theme file, I added this code:<\/p>\n\n<pre><code class=\"php\">\/**\n * Implements hook_preprocess_html().\n *\/\nfunction mytheme_preprocess_html(array &$variables): void {\n $variables['attributes']['data-use-new-button-styles'] = \\Drupal::service('feature_toggle.feature_status')->getStatus('use_the_new_button_styling');\n}\n<\/code><\/pre>\n\n<p>If the feature toggle is enabled, it adds a <code>data-use-new-button-styles=\"\"<\/code> attribute to the <code>body<\/code> element.<\/p>\n\n<p>If it is disabled, the attribute is not added, so I can write CSS that's applied when the data attribute is present:<\/p>\n\n<pre><code class=\"css\">[data-use-new-button-styles] .btn-primary {\n background-color: red;\n}\n<\/code><\/pre>\n\n<p>In a Tailwind CSS project (this isn't), the same could be achiveable with a custom interaction state - similar to <code>hover<\/code>, <code>focus<\/code> and <code>active<\/code>. Something like <code>new-button-styles:bg-red-500<\/code>.<\/p>\n\n<p>I like using feature flags and was happy to find a way to use them when adding this new CSS.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
],
|
|
"feeds_item": [
|
|
{
|
|
"imported": "2025-04-21T01:21:27+00:00",
|
|
"guid": null,
|
|
"hash": "290ba77a217288ad367ab07bf02a2265",
|
|
"target_type": "feeds_feed",
|
|
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
|
|
}
|
|
]
|
|
} |