Skip to content

Commit c5940cc

Browse files
committed
feat: fix formatting of moderation notes using css grid
1 parent 90ea2d9 commit c5940cc

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
lines changed

src/assets/scss/_global-components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ a:hover { color: $color-primary-alt; }
1212
.right { float: right; }
1313
.red { color: red; }
1414
.centered-text { text-align: center; }
15+
.inline-block { display: inline-block; }
1516

1617
img {
1718
max-width: 100%;

src/components/modals/profile/ModerationNotes.vue

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,31 @@
99
<div class="avatar" :class="defaultAvatarShape">
1010
<img :src="comment.author_avatar || defaultAvatar" @error="$event.target.src=defaultAvatar" :style="avatarHighlight(comment.author_highlight_color)">
1111
</div>
12-
<div class="content">
13-
<div class="title">
14-
<div class="bold inline-block" :style="usernameHighlight(comment.author_highlight_color)">{{ comment.author_name}}</div>
15-
<span class="date">{{ humanDate(comment.created_at) }}</span>
16-
<span v-if="comment.created_at !== comment.updated_at" class="date hide-mobile">&mdash;&nbsp;Edited {{ humanDate(comment.updated_at) }}</span>
17-
<div class="right" v-if="comment.author_id === authedUser.id">
18-
<!-- TODO(akinsey): data-balloon="Delete" -->
19-
<a v-if="accessControl.delete && !comment.showConfirmDelete" class="action" @click="comment.showConfirmDelete = true">
20-
<i class="fa fa-trash"></i>
21-
</a>
22-
<a v-if="comment.showConfirmDelete" @click="deleteUserNote(comment)">&nbsp;Confirm&nbsp;</a>
23-
<a v-if="comment.showConfirmDelete" @click="comment.showConfirmDelete = false">&nbsp;Cancel&nbsp;</a>
24-
&nbsp;&nbsp;
25-
<!-- TODO(akinsey): data-balloon="Edit" -->
26-
<a v-if="accessControl.update" href="#" class="action" @click="comment.showEdit = !comment.showEdit; comment.noteEdit = ''">
27-
<i class="fa fa-edit"></i>
28-
</a>
29-
</div>
30-
<span v-if="comment.created_at !== comment.updated_at" class="date inline-block show-mobile">Edited {{ humanDate(comment.updated_at) }}</span>
31-
12+
<div class="title">
13+
<div class="bold inline-block" :style="usernameHighlight(comment.author_highlight_color)">{{ comment.author_name}}</div>
14+
<span class="date">{{ humanDate(comment.created_at) }}</span>
15+
<span v-if="comment.created_at !== comment.updated_at" class="date">&mdash;&nbsp;Edited {{ humanDate(comment.updated_at) }}</span>
16+
<div class="right" v-if="comment.author_id === authedUser.id">
17+
<!-- TODO(akinsey): data-balloon="Delete" -->
18+
<a v-if="accessControl.delete && !comment.showConfirmDelete" class="action pointer" @click="comment.showConfirmDelete = true">
19+
<i class="fa fa-trash"></i>
20+
</a>
21+
<a class="pointer" v-if="comment.showConfirmDelete" @click="deleteUserNote(comment)">&nbsp;Confirm&nbsp;</a>
22+
<a class="pointer" v-if="comment.showConfirmDelete" @click="comment.showConfirmDelete = false">&nbsp;Cancel&nbsp;</a>
23+
&nbsp;&nbsp;
24+
<!-- TODO(akinsey): data-balloon="Edit" -->
25+
<a v-if="accessControl.update" href="#" class="action pointer" @click="comment.showEdit = !comment.showEdit; comment.noteEdit = ''">
26+
<i class="fa fa-edit"></i>
27+
</a>
3228
</div>
33-
<div v-if="!comment.showEdit">{{ comment.note }}</div>
34-
<div v-if="comment.showEdit">
35-
<textarea v-model="comment.noteEdit"></textarea>
36-
<div class="right">
37-
<span v-if="comment.noteEdit.length < 3 || comment.noteEdit === comment.note">&nbsp;Save&nbsp;</span>
38-
<a v-if="comment.noteEdit.length > 2 && comment.noteEdit !== comment.note" @click="editUserNote(comment)">&nbsp;Save&nbsp;</a>
39-
<a @click="comment.showEdit = false;">&nbsp;Cancel&nbsp;</a>
40-
</div>
29+
</div>
30+
<div class="note" v-if="!comment.showEdit">{{ comment.note }}</div>
31+
<div class="note" v-if="comment.showEdit">
32+
<textarea v-model="comment.noteEdit"></textarea>
33+
<div class="right">
34+
<span v-if="comment.noteEdit.length < 3 || comment.noteEdit === comment.note">&nbsp;Save&nbsp;</span>
35+
<a class="pointer" v-if="comment.noteEdit.length > 2 && comment.noteEdit !== comment.note" @click="editUserNote(comment)">&nbsp;Save&nbsp;</a>
36+
<a class="pointer" @click="comment.showEdit = false;">&nbsp;Cancel&nbsp;</a>
4137
</div>
4238
</div>
4339
</div>
@@ -150,12 +146,17 @@ export default {
150146
margin-top: -0.625rem;
151147
.comment-container {
152148
.comment {
149+
display: grid;
150+
grid-template-columns: 2.5rem 1fr;
151+
grid-column-gap: 1rem;
152+
grid-template-areas: "avatar title" "avatar note";
153153
@include clearfix;
154154
padding: 1rem;
155155
border-bottom: 1px solid $border-color;
156156
&:nth-of-type(odd) { background-color: $sub-header-color; }
157157
&:last-child { margin-bottom: 1rem; }
158158
.avatar {
159+
grid-area: avatar;
159160
&.circle {
160161
img {
161162
@include border-radius(100px);
@@ -170,16 +171,17 @@ export default {
170171
}
171172
}
172173
}
173-
.content {
174-
.title {
175-
margin-bottom: 0.5rem;
176-
.date { @include pad(0 0 0 0.25rem); font-size: 0.8rem; color: $secondary-font-color; }
177-
.action { color: $secondary-font-color; }
178-
&:hover .action { color: $secondary-font-color-dark; }
179-
&:hover .action:hover { color: $color-primary;; }
180-
}
181-
textarea { min-height: 3.25rem; }
174+
.title {
175+
grid-area: title;
176+
margin-bottom: 0.5rem;
177+
.date { @include pad(0 0 0 0.25rem); font-size: 0.8rem; color: $secondary-font-color; }
178+
.action { color: $secondary-font-color; }
179+
&:hover .action { color: $secondary-font-color-dark; }
180+
&:hover .action:hover { color: $color-primary;; }
182181
}
182+
.note { grid-area: note; }
183+
textarea { grid-area: note; min-height: 4.5rem; resize: vertical; }
184+
183185
}
184186
.mod-notes.pagination-simple {
185187
margin: 1rem 0;
@@ -191,12 +193,11 @@ export default {
191193
@include break-mobile-sm {
192194
.comment {
193195
.avatar { display: none; }
194-
.content { }
195196
}
196197
}
197198
}
198199
}
199200
h5.no-comments { text-align: center; margin: 0.625rem 0; }
200-
.input-section.textarea textarea { height: 4.5rem; }
201201
.modal-container .modal-actions { margin-top: 0; }
202+
.input-section.textarea textarea { height: 4.5rem; resize: vertical; }
202203
</style>

0 commit comments

Comments
 (0)