Skip to content

Commit f77fba9

Browse files
authored
Refine the visual display of the comment reply form help text (#1434)
This PR wraps the help text in and alert, and adjust the spacing between the reply form and the comment above. The goal is to more clearly distinguish the reply form from the comment, and make it clear that the help text is connected to the reply form, not the comment above.|
1 parent 4ca63be commit f77fba9

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

.changeset/cold-melons-boil.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Refine the visual display of the comment reply form help text

src/components/comment-form/comment-form.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
.c-comment-form {
55
display: grid;
6-
grid-gap: ms.step(2, 1rem) ms.step(4, 1rem);
6+
grid-gap: size.$spacing-gap-comment-form-vertical
7+
size.$spacing-gap-comment-form-horizontal;
78
grid-template-columns: 1fr 1fr;
89
}
910

src/components/comment-form/comment-form.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The form used to add a comment to an article. Including the `heading_id` and `he
6262
</Story>
6363
</Canvas>
6464

65-
There is also a reply version of this component (`is_reply: true`), used to reply to an existing comment. (You'll also want to modify `heading_tag`, `heading_id`, `heading_class`, and `heading_text`. When using the [Comment pattern](/docs/components-comment--with-reply-button) this will be done automatically.)
65+
There is also a reply version of this component (`is_reply: true`), used to reply to an existing comment. (You'll also want to modify `heading_tag`, `heading_id`, `heading_class`, `heading_text`, and `main_label`. When using the [Comment pattern](/docs/components-comment--with-reply-button) this will be done automatically.)
6666

6767
<Canvas>
6868
<Story

src/components/comment-form/comment-form.twig

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212
>
1313
{{ heading_text|default("Leave a Comment") }}
1414
</{{_heading_tag}}>
15-
<p {% if help_text_id %}id="{{ help_text_id }}"{% endif %}>
16-
Please be kind, courteous and constructive.
17-
You may use simple HTML or
18-
<a href="https://en.support.wordpress.com/markdown-quick-reference">Markdown</a>
19-
in your comments.
20-
All fields are required.
21-
</p>
15+
16+
{% embed '@cloudfour/components/alert/alert.twig' %}
17+
{% block content %}
18+
<p {% if help_text_id %}id="{{ help_text_id }}"{% endif %}>
19+
Please be kind, courteous and constructive.
20+
You may use simple HTML or
21+
<a href="https://en.support.wordpress.com/markdown-quick-reference">Markdown</a>
22+
in your comments.
23+
All fields are required.
24+
</p>
25+
{% endblock %}
26+
{% endembed %}
2227
{% endblock %}
2328
{% embed '@cloudfour/objects/form-group/form-group.twig' with { label: main_label|default('Message') } %}
2429
{% block control %}

src/components/comment/comment.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050

5151
.c-comment.is-replying .c-comment__reply-form {
5252
display: block;
53+
/// The top margin matches the grid gap spacing applied to the comment form.
54+
/// Otherwise, the form's help text appears visually closer to the comment
55+
/// you're responding to than to the form.
56+
margin-top: size.$spacing-gap-comment-form-vertical;
5357
}
5458

5559
/// Named object for consistency with the Media component.
@@ -134,10 +138,6 @@
134138
// Visually centers the child avatars with the indentation of the parent
135139
// comment. Without this, the replies feel nested too far to the right.
136140
margin-left: math.div(size.$square-avatar-small, -2);
137-
}
138-
139-
.c-comment__replies,
140-
.c-comment__reply-form {
141141
// Since the replies are likely wrapped in a Rhythm object intended to inherit
142142
// the parent rhythm, we can use that custom property to inherit that same
143143
// spacing between the meta and replies.

src/tokens/size/spacing.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { modularEm } = require('../../scripts/modular-scale');
1+
const { modularEm, modularRem } = require('../../scripts/modular-scale');
22

33
module.exports = {
44
size: {
@@ -49,6 +49,10 @@ module.exports = {
4949
logo_group: {
5050
value: modularEm(3),
5151
},
52+
comment_form: {
53+
horizontal: { value: modularRem(4) },
54+
vertical: { value: modularRem(2) },
55+
},
5256
},
5357
control: {
5458
text_inset: { value: modularEm(-1) },

0 commit comments

Comments
 (0)