From 490725ecd253bd8c4345f82d5751a772abcd7579 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Thu, 7 Mar 2019 23:13:46 +0100 Subject: [PATCH] Long time no see. A bunch of stuff I cba to summarize. --- marko/components/date/index.marko | 5 + marko/components/markdown/index.marko | 1 + marko/global/base.less | 68 +++++++++++ marko/global/colors.less | 6 +- .../components/chapter-meta/index.marko | 10 +- .../components/chapter-meta/style.less | 4 + .../components/chapter/component.js | 5 + .../components/chapter/index.marko | 14 ++- .../components/chapter/style.less | 26 ++++ .../components/comment/component.js | 18 +++ .../components/comment/index.marko | 110 +++++++++++++++++ .../components/comment/style.less | 113 ++++++++++++++++++ .../create-chapter-modal/component.js | 12 +- .../create-chapter-modal/index.marko | 8 ++ .../create-comment-modal/component.js | 96 +++++++++++++++ .../create-comment-modal/index.marko | 27 +++++ .../edit-chapter-modal/component.js | 10 +- .../components/edit-chapter-modal/index.marko | 12 ++ rpdata/api/Chapter.js | 42 ++++++- rpdata/api/Comment.js | 72 ++++++++++- 20 files changed, 642 insertions(+), 17 deletions(-) create mode 100644 marko/components/date/index.marko create mode 100644 marko/page/story-content/components/comment/component.js create mode 100644 marko/page/story-content/components/comment/index.marko create mode 100644 marko/page/story-content/components/comment/style.less create mode 100644 marko/page/story-content/components/create-comment-modal/component.js create mode 100644 marko/page/story-content/components/create-comment-modal/index.marko diff --git a/marko/components/date/index.marko b/marko/components/date/index.marko new file mode 100644 index 0000000..a98d6fa --- /dev/null +++ b/marko/components/date/index.marko @@ -0,0 +1,5 @@ +import moment from "moment"; + + + ${(input.utc ? moment.utc(input.value) : moment(input.value)).format(input.format || "MMM D, YYYY")} + \ No newline at end of file diff --git a/marko/components/markdown/index.marko b/marko/components/markdown/index.marko index ca647ef..756bb53 100644 --- a/marko/components/markdown/index.marko +++ b/marko/components/markdown/index.marko @@ -1,3 +1,4 @@
+
\ No newline at end of file diff --git a/marko/global/base.less b/marko/global/base.less index e4a07cf..e7f4b74 100644 --- a/marko/global/base.less +++ b/marko/global/base.less @@ -51,3 +51,71 @@ body { background-color: #555; color: #000; } + +/* + * Tooltip magic. + */ +.tooltip { + position: relative; + border-bottom: 0.5px dotted; /* If you want dots under the hoverable text */ + + span { + cursor: default; + } + + > .tooltip-content { + visibility: hidden; + width: 400px; + text-align: left; + padding: 0.25em 1ch; + + position: absolute; + z-index: 11000; + pointer-events: none; + + top: 0; + left: 105%; + + border: 1px solid; + + > h1 { + font-size: 1.5em; + margin: 0; + text-align: center; + border: none; + } + + > h2 { + font-size: 1em; + margin: 0; + margin-bottom: 0.15em; + margin-top: -0.25em; + font-weight: 200; + opacity: 0.5; + text-align: center; + border: none; + } + + p:last-of-type { + padding-bottom: 0; + } + } +} + +.no-tooltip { + position: relative; +} + +.tooltip:hover { + > .tooltip-content { + visibility: visible; + } +} + +@media screen and (max-width: 1200px) { + .tooltip { + > .tooltip-content { + visibility: hidden !important; + } + } +} \ No newline at end of file diff --git a/marko/global/colors.less b/marko/global/colors.less index 050d1f4..ae3bf8a 100644 --- a/marko/global/colors.less +++ b/marko/global/colors.less @@ -92,7 +92,7 @@ body.theme-data { } -div.markdown-content .orange, body.theme-logs div.markdown-content blockquote, body.theme-logs div.markdown-content table, body.theme-logs div.markdown-content pre { +div.markdown-content .orange, body.theme-logs .color-blockquote, body.theme-logs div.markdown-content blockquote, body.theme-logs div.markdown-content table, body.theme-logs div.markdown-content pre { background-color: rgba(221, 170, 17, 0.125); color: #DA1; @@ -100,7 +100,7 @@ div.markdown-content .orange, body.theme-logs div.markdown-content blockquote, b color: #DA1; } } -div.markdown-content .blue, body.theme-story div.markdown-content blockquote, body.theme-story div.markdown-content table, body.theme-story div.markdown-content pre { +div.markdown-content .blue, body.theme-story .color-blockquote, body.theme-story div.markdown-content blockquote, body.theme-story div.markdown-content table, body.theme-story div.markdown-content pre { background-color: rgba(34, 187, 255, 0.125); color: #4BF; @@ -108,7 +108,7 @@ div.markdown-content .blue, body.theme-story div.markdown-content blockquote, bo color: #4BF; // } } -div.markdown-content .green, body.theme-mapp div.markdown-content blockquote, body.theme-mapp div.markdown-content table, body.theme-mapp div.markdown-content pre { +div.markdown-content .green, body.theme-mapp .color-blockquote, body.theme-mapp div.markdown-content blockquote, body.theme-mapp div.markdown-content table, body.theme-mapp div.markdown-content pre { background-color: rgba(17,255,136, 0.125); color: #1F8; diff --git a/marko/page/story-content/components/chapter-meta/index.marko b/marko/page/story-content/components/chapter-meta/index.marko index 747cf07..9165ff5 100644 --- a/marko/page/story-content/components/chapter-meta/index.marko +++ b/marko/page/story-content/components/chapter-meta/index.marko @@ -1,6 +1,14 @@
${state.text} - ${state.text} + + ${state.text} + +
+

${input.character.name}

+

${input.character.author}

+ +
+
\ No newline at end of file diff --git a/marko/page/story-content/components/chapter-meta/style.less b/marko/page/story-content/components/chapter-meta/style.less index 16d07ea..c5a6a1c 100644 --- a/marko/page/story-content/components/chapter-meta/style.less +++ b/marko/page/story-content/components/chapter-meta/style.less @@ -13,6 +13,10 @@ div.chapter-meta { a:hover { border-bottom: 0.5px solid; } + + .tooltip { + border-bottom: 0.25px dotted; + } } div.chapter-meta.weak { diff --git a/marko/page/story-content/components/chapter/component.js b/marko/page/story-content/components/chapter/component.js index 3138782..05929a8 100644 --- a/marko/page/story-content/components/chapter/component.js +++ b/marko/page/story-content/components/chapter/component.js @@ -3,6 +3,11 @@ module.exports = class { this.state = { modal: null, removed: false, + commentLabels: { + Article: "Comment", + Message: "Message", + Chat: "Chat Message", + }, } } diff --git a/marko/page/story-content/components/chapter/index.marko b/marko/page/story-content/components/chapter/index.marko index 24066db..3b7465d 100644 --- a/marko/page/story-content/components/chapter/index.marko +++ b/marko/page/story-content/components/chapter/index.marko @@ -16,10 +16,22 @@ + - +
+ + +
Add ${state.commentLabels[input.chapter.commentMode] || "Comment"}
+
+
+ \ No newline at end of file diff --git a/marko/page/story-content/components/chapter/style.less b/marko/page/story-content/components/chapter/style.less index dd658f6..67698fb 100644 --- a/marko/page/story-content/components/chapter/style.less +++ b/marko/page/story-content/components/chapter/style.less @@ -49,4 +49,30 @@ div.chapter-content { font-size: 1.25em; } + + div.comment-section { + margin: 1em 4ch 2em 4ch; + + div.add-comment { + text-align: center; + margin-top: 1em; + padding: 1em 0; + font-size: 1.5em; + border: 1px solid; + opacity: 0.5; + cursor: pointer; + } + div.add-comment:hover { + opacity: 1; + } + div.add-comment:first-child { + margin-top: 0; + } + } + + @media screen and (max-width: 1200px) { + div.comment-section { + margin: 1em 2ch 2em 2ch; + } + } } \ No newline at end of file diff --git a/marko/page/story-content/components/comment/component.js b/marko/page/story-content/components/comment/component.js new file mode 100644 index 0000000..4c7e0bf --- /dev/null +++ b/marko/page/story-content/components/comment/component.js @@ -0,0 +1,18 @@ +module.exports = class { + onCreate(input) { + this.state = { + showCharacter: false, + paragraphs: input.comment.source.split('\n').filter(l => l.length > 1), + } + } + + onInput(input) { + if (this.state) { + this.state.paragraphs = input.comment.source.split('\n').filter(l => l.length > 1) + } + } + + toggle(key) { + this.state[key] = !this.state[key] + } +} \ No newline at end of file diff --git a/marko/page/story-content/components/comment/index.marko b/marko/page/story-content/components/comment/index.marko new file mode 100644 index 0000000..2cbbe5b --- /dev/null +++ b/marko/page/story-content/components/comment/index.marko @@ -0,0 +1,110 @@ +import moment from "moment" + +
+ + +
+ + + + + + + + + + + + + + + +
Subject:${input.comment.subject}
From: +
+ ${input.comment.characterName} + +
+

${input.comment.character.name}

+

${input.comment.character.author}

+ +
+
+
+ ${input.comment.characterName} +
+
Date:${moment(input.comment.fictionalDate).format("MMM D, YYYY")}
+ +
+
+ +
+
+ + Edit + + + Remove + +
+ +
+ + [ + + + < + + ${input.comment.characterName} + +
+

${input.comment.character.name}

+

${input.comment.character.author}

+ +
+
+ + ${input.comment.characterName} + +
+

(Unknown Character)

+

${input.comment.author}

+
+
+ +
+
+
+
+ + + +
+ +
+ +
\ No newline at end of file diff --git a/marko/page/story-content/components/comment/style.less b/marko/page/story-content/components/comment/style.less new file mode 100644 index 0000000..748d791 --- /dev/null +++ b/marko/page/story-content/components/comment/style.less @@ -0,0 +1,113 @@ +div.comment { + position: relative; + + div.options { + width: 100%; + max-width: 95ch; + } +} + +div.comment.mode-message { + margin-bottom: 1.5em; + font-size: 1em; + + .metadata { + padding-bottom: 0.5em; + } + + .content { + outline: 1px solid; + padding: 0.25em 1ch; + + font-size: 1.25em; + + table.header { + border-bottom: 0.5px solid; + margin: 0; + width: 100%; + + tbody { + tr { + text-align: left; + + th { + width: 12ch; + padding-right: 1ch; + } + + td { + width: 100%; + } + } + } + } + } + + div.body { + padding-top: 0.5em; + + p:first-of-type { + margin-top: 0; + padding-top: 0; + } + } +} + +div.comment.mode-chat { + div.options { + display: none; + bottom: -0.25em; + + a { + background: black; + opacity: 0.666; + } + a:hover { + opacity: 1; + } + } + + div.content { + line-height: 2em; + font-size: 1.125em; + + div.tooltip-content { + text-indent: 0; + } + + div.message-text { + vertical-align: top; + padding-left: 2ch; + text-indent: -2ch; + + div.body { + p:first-of-type { + display: inline; + } + + p:last-of-type { + margin-bottom: 0; + padding-bottom: 0; + } + + p { + line-height: 1.5em; + } + } + } + } +} + +div.comment.mode-article { + margin-bottom: 1em; + + .content { + font-size: 1.25em; + } +} + +div.comment.mode-chat:hover { + div.options { + display: block; + } +} \ No newline at end of file diff --git a/marko/page/story-content/components/create-chapter-modal/component.js b/marko/page/story-content/components/create-chapter-modal/component.js index cf7c03f..184f0d3 100644 --- a/marko/page/story-content/components/create-chapter-modal/component.js +++ b/marko/page/story-content/components/create-chapter-modal/component.js @@ -11,6 +11,7 @@ module.exports = class { title: "", source: "", fictionalDate: "", + commentMode: "Disabled", }, } @@ -19,18 +20,18 @@ module.exports = class { onInput(input) { if (input.chapter && !this.first) { - let {fictionalDate, title, source} = input.chapter + let {fictionalDate, title, source, commentMode, commentsLocked} = input.chapter if (fictionalDate != null) { fictionalDate = moment.utc(fictionalDate).format("MMM D, YYYY") } - this.state.values = {fictionalDate, title, source} + this.state.values = {fictionalDate, title, source, commentMode, commentsLocked} } } change(key, ev) { - this.state.values[key] = ev.target.value + this.state.values = Object.assign({}, this.state.values, {[key]: ev.target.value}) } open() { @@ -60,7 +61,7 @@ module.exports = class { fictionalDate = null } - const input = {storyId: this.input.storyId, title: values.title, source: values.source, fictionalDate} + const input = {storyId: this.input.storyId, title: values.title, source: values.source, fictionalDate, commentMode: values.commentMode} chapterApi.addChapter(input).then(chapter => { this.emit("add", chapter) @@ -70,11 +71,12 @@ module.exports = class { title: "", source: "", fictionalDate: "", + commentMode: "Disabled", } }).catch(errs => { console.warn("Failed to edit:", errs) - this.state.error = "Failed to edit: " + errs[0].message + this.state.error = "Failed to edit: " + (errs[0]||errs||{}).message || errs }).then(() => { this.state.loading = false }) diff --git a/marko/page/story-content/components/create-chapter-modal/index.marko b/marko/page/story-content/components/create-chapter-modal/index.marko index 212d402..df40492 100644 --- a/marko/page/story-content/components/create-chapter-modal/index.marko +++ b/marko/page/story-content/components/create-chapter-modal/index.marko @@ -12,5 +12,13 @@