From 2f5e19bd44c58f22f6853e2cc38a86f5c3c49794 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 3 Mar 2018 15:44:43 -0800 Subject: [PATCH] start on content warnings --- routes/_actions/contentWarnings.js | 6 +++ routes/_components/compose/ComposeAuthor.html | 2 +- routes/_components/compose/ComposeBox.html | 26 ++++++---- .../compose/ComposeContentWarning.html | 49 +++++++++++++++++++ .../_components/compose/ComposeToolbar.html | 10 +++- tests/spec/13-compose-media.js | 1 + 6 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 routes/_actions/contentWarnings.js create mode 100644 routes/_components/compose/ComposeContentWarning.html diff --git a/routes/_actions/contentWarnings.js b/routes/_actions/contentWarnings.js new file mode 100644 index 0000000..e84fa15 --- /dev/null +++ b/routes/_actions/contentWarnings.js @@ -0,0 +1,6 @@ +import { store } from '../_store/store' + +export function toggleContentWarningShown (realm) { + let shown = store.getComposeData(realm, 'contentWarningShown') + store.setComposeData(realm, {contentWarningShown: !shown}) +} diff --git a/routes/_components/compose/ComposeAuthor.html b/routes/_components/compose/ComposeAuthor.html index 253a02b..2b71c79 100644 --- a/routes/_components/compose/ComposeAuthor.html +++ b/routes/_components/compose/ComposeAuthor.html @@ -12,7 +12,7 @@ } .compose-box-display-name { color: var(--deemphasized-text-color); - grid-area: display-name; + grid-area: name; min-width: 0; white-space: nowrap; overflow: hidden; diff --git a/routes/_components/compose/ComposeBox.html b/routes/_components/compose/ComposeBox.html index 3b6825c..18a1101 100644 --- a/routes/_components/compose/ComposeBox.html +++ b/routes/_components/compose/ComposeBox.html @@ -1,8 +1,11 @@
+ {{#if contentWarningShown}} + + {{/if}} - + @@ -14,12 +17,13 @@ display: grid; align-items: flex-start; grid-template-areas: - "avatar display-name handle handle" - "avatar input input input" - "avatar gauge gauge gauge" - "avatar toolbar toolbar length" - "avatar media media media" - "avatar button button button"; + "avatar name handle handle" + "avatar cw cw cw" + "avatar input input input" + "avatar gauge gauge gauge" + "avatar toolbar toolbar length" + "avatar media media media" + "avatar button button button"; grid-template-columns: min-content minmax(0, max-content) 1fr 1fr; border-bottom: 1px solid var(--main-border); width: 560px; @@ -42,6 +46,7 @@ import ComposeInput from './ComposeInput.html' import ComposeButton from './ComposeButton.html' import ComposeMedia from './ComposeMedia.html' + import ComposeContentWarning from './ComposeContentWarning.html' import { measureText } from '../../_utils/measureText' import { CHAR_LIMIT, POST_PRIVACY_OPTIONS } from '../../_static/statuses' import { store } from '../../_store/store' @@ -54,7 +59,8 @@ ComposeLengthIndicator, ComposeInput, ComposeButton, - ComposeMedia + ComposeMedia, + ComposeContentWarning }, store: () => store, computed: { @@ -65,7 +71,9 @@ defaultPostPrivacyKey: ($currentVerifyCredentials) => $currentVerifyCredentials.source.privacy, postPrivacyKey: (composeData, defaultPostPrivacyKey) => composeData.postPrivacy || defaultPostPrivacyKey, textLength: (text) => measureText(text), - textOverLimit: (textLength) => textLength > CHAR_LIMIT + textOverLimit: (textLength) => textLength > CHAR_LIMIT, + contentWarningShown: (composeData) => composeData.contentWarningShown, + contentWarning: (composeData) => composeData.contentWarning || '' } } diff --git a/routes/_components/compose/ComposeContentWarning.html b/routes/_components/compose/ComposeContentWarning.html new file mode 100644 index 0000000..c9642cd --- /dev/null +++ b/routes/_components/compose/ComposeContentWarning.html @@ -0,0 +1,49 @@ + + + \ No newline at end of file diff --git a/routes/_components/compose/ComposeToolbar.html b/routes/_components/compose/ComposeToolbar.html index 1e669a5..d8ef1f2 100644 --- a/routes/_components/compose/ComposeToolbar.html +++ b/routes/_components/compose/ComposeToolbar.html @@ -17,8 +17,11 @@ on:click="onPostPrivacyClick()" /> { test('removes media', async t => { await t.useRole(foobarRole) await (uploadKittenImage(1)()) + await t.expect(getNthMedia(1).getAttribute('alt')).eql('kitten1.jpg') await (uploadKittenImage(2)()) await t.expect(getNthMedia(1).getAttribute('alt')).eql('kitten1.jpg') .expect(getNthMedia(2).getAttribute('alt')).eql('kitten2.jpg')