Ver Fonte

Development docs - refine `classname` convention

- Update template example to be in a more logical order & use the correct template syntax
- Update `class_name` as no longer preferred as we have adopted a normalised approach for icon
LB Johnston há 2 anos atrás
pai
commit
eb808116f0
1 ficheiros alterados com 25 adições e 10 exclusões
  1. 25 10
      docs/contributing/general_guidelines.md

+ 25 - 10
docs/contributing/general_guidelines.md

@@ -34,15 +34,7 @@ Examples:
 
 #### Django template tag
 
-```django+html
-{% dialog_toggle classname='button button-primary' %}
-```
-
-```django+html
-<button type="button" class="{{ classname }}" data-a11y-dialog-show="{{ dialog_id }}">
-    {{ text }}
-</button>
-```
+Example template tag definition
 
 ```python
 @register.inclusion_tag("wagtailadmin/shared/dialog/dialog_toggle.html")
@@ -53,6 +45,29 @@ def dialog_toggle(dialog_id, classname="", text=None):
     }
 ```
 
+Example template
+
+```html+django
+{% comment "text/markdown" %}
+
+    Variables accepted by this template:
+
+    - `classname` - {string?} if present, adds classname to button
+    - `dialog_id` - {string} unique id to use to reference the modal which will be triggered
+
+{% endcomment %}
+
+<button type="button" class="{{ classname }}" data-a11y-dialog-show="{{ dialog_id }}">
+    {{ text }}
+</button>
+```
+
+Example usage
+
+```html+django
+{% dialog_toggle classname='button button-primary' %}
+```
+
 ### Python / Django class driven content
 
 ```python
@@ -69,7 +84,7 @@ class Panel:
 | `classname`   | ✅ Preferred for any new code.                                                                                      |
 | `class`       | ✳️ Only if used as part of a generic `attrs`-like dict; however avoid due to conflicts with Python `class` keyword. |
 | `classnames`  | ❌ Avoid for new code.                                                                                              |
-| `class_name`  | ✳️ Some existing code may use this; avoid for new code.                                                             |
+| `class_name`  | ❌ Avoid for new code.                                                                                              |
 | `class_names` | ❌ Avoid for new code.                                                                                              |
 | `className`   | ❌ Avoid for new code.                                                                                              |
 | `classNames`  | ❌ Avoid for new code.                                                                                              |