Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 432b186

Browse files
committed
Show content warnings and allow expand/contract
1 parent 33bda27 commit 432b186

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

lib/depject/message/html/layout/default.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,33 @@ exports.create = function (api) {
7474
classList.push('-unread')
7575
}
7676

77+
let cw = msg.value.content.contentWarning
78+
if (typeof cw !== 'string' || cw.length === 0) {
79+
cw = undefined;
80+
} else {
81+
// TODO: emoji shortcodes?
82+
// TODO: truncate very long content warning, maybe use max-height?
83+
classList.push('-hasContentWarning');
84+
}
85+
7786
return h('div', {
7887
classList,
7988
hooks
8089
}, [
8190
messageHeader(msg, { replyInfo, priority }),
82-
h('section', {
91+
cw
92+
? h('a.contentWarning',
93+
{
94+
href: '#',
95+
'ev-click': toggleAndTrack(expanded),
96+
},
97+
cw,
98+
)
99+
: undefined,
100+
h('section.content', {
83101
classList: [when(expanded, '-expanded')],
84102
hooks: [ExpanderHook(needsExpand)]
85-
}, [content]),
103+
}, content),
86104
computed(msg.key, (key) => {
87105
if (ref.isMsg(key)) {
88106
return h('footer', [

lib/depject/message/html/layout/mini.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ exports.create = function (api) {
7373
messageHeader(msg, {
7474
replyInfo, priority, miniContent
7575
}),
76-
h('section', {
76+
h('section.content', {
7777
classList: [when(expanded, '-expanded')],
7878
hooks: [ExpanderHook(needsExpand)]
7979
}, [content]),

styles/base/message.mcss

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ Message {
118118
}
119119
}
120120
}
121-
section {
121+
a.contentWarning {
122+
padding: 10px 20px
123+
font-weight: bold
124+
}
125+
section.content {
122126
margin: 0
123127
padding: 0 20px
124128
max-height: 1170px
@@ -293,4 +297,16 @@ Message {
293297
-new, -unread {
294298
z-index: 1
295299
}
300+
-hasContentWarning {
301+
section.content {
302+
max-height: 0px
303+
}
304+
footer {
305+
div.expander {
306+
-webkit-mask-image: none !important
307+
padding-top: 0px !important
308+
margin-top: 0px !important
309+
}
310+
}
311+
}
296312
}

styles/dark/message.mcss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Message {
7979
}
8080
}
8181
}
82+
a.contentWarning {
83+
background: #000
84+
}
8285
a.backlink {
8386
padding: 10px 20px
8487
background: #2d2c2c

styles/light/message.mcss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Message {
6969
}
7070
}
7171
}
72+
a.contentWarning {
73+
background: #ddd
74+
}
7275
a.backlink {
7376
border-top: 1px solid #eee
7477
padding: 10px 15px

0 commit comments

Comments
 (0)