From 22c8f71945c6d114bf4db89c87eb1b166775f2d6 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 7 Jun 2021 16:16:10 +0300 Subject: mention link --- src/components/mention_link/mention_link.js | 71 +++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/components/mention_link/mention_link.js (limited to 'src/components/mention_link/mention_link.js') diff --git a/src/components/mention_link/mention_link.js b/src/components/mention_link/mention_link.js new file mode 100644 index 00000000..ade598d8 --- /dev/null +++ b/src/components/mention_link/mention_link.js @@ -0,0 +1,71 @@ +import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' +import { getTextColor, rgb2hex } from 'src/services/color_convert/color_convert.js' +import { mapGetters, mapState } from 'vuex' +import { convert } from 'chromatism' + +const MentionLink = { + name: 'MentionLink', + props: { + url: { + required: true, + type: String + }, + content: { + required: true, + type: String + }, + origattrs: { + required: true, + type: Object + } + }, + methods: { + onClick () { + const link = generateProfileLink(this.user.id, this.user.screen_name) + this.$router.push(link) + } + }, + computed: { + user () { + return this.$store.getters.findUserByUrl(this.url) + }, + isYou () { + // FIXME why user !== currentUser??? + return this.user.screen_name === this.currentUser.screen_name + }, + userName () { + return this.userNameFullUi.split('@')[0] + }, + userNameFull () { + return this.user.screen_name + }, + userNameFullUi () { + return this.user.screen_name_ui + }, + highlight () { + return this.mergedConfig.highlight[this.user.screen_name] + }, + bg () { + if (this.highlight) return this.highlight.color + }, + text () { + if (this.bg) { + const linkColor = this.mergedConfig.customTheme.colors.link + const color = getTextColor(convert(this.bg).rgb, convert(linkColor).rgb) + return rgb2hex(color) + } + }, + style () { + return [ + this.bg && `--mention-bg: ${this.bg}`, + this.text && `--mention-text: ${this.text}` + ].filter(_ => _).join('; ') + }, + ...mapGetters(['mergedConfig']), + ...mapState({ + currentUser: state => state.users.currentUser + }) + } +} + +export default MentionLink -- cgit v1.2.3-70-g09d2 From 7d6fc044fbcf2c6f82f759605a0fd5c1aebae55a Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 7 Jun 2021 23:42:04 +0300 Subject: new mentions look --- src/components/mention_link/mention_link.js | 28 +++---- src/components/mention_link/mention_link.scss | 94 ++++++++++++++++++++--- src/components/mention_link/mention_link.vue | 12 +-- src/services/user_highlighter/user_highlighter.js | 14 +++- 4 files changed, 114 insertions(+), 34 deletions(-) (limited to 'src/components/mention_link/mention_link.js') diff --git a/src/components/mention_link/mention_link.js b/src/components/mention_link/mention_link.js index ade598d8..d26ae337 100644 --- a/src/components/mention_link/mention_link.js +++ b/src/components/mention_link/mention_link.js @@ -1,7 +1,6 @@ import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' -import { getTextColor, rgb2hex } from 'src/services/color_convert/color_convert.js' import { mapGetters, mapState } from 'vuex' -import { convert } from 'chromatism' +import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js' const MentionLink = { name: 'MentionLink', @@ -45,21 +44,22 @@ const MentionLink = { highlight () { return this.mergedConfig.highlight[this.user.screen_name] }, - bg () { - if (this.highlight) return this.highlight.color + highlightType () { + return this.highlight && ('-' + this.highlight.type) }, - text () { - if (this.bg) { - const linkColor = this.mergedConfig.customTheme.colors.link - const color = getTextColor(convert(this.bg).rgb, convert(linkColor).rgb) - return rgb2hex(color) - } + highlightClass () { + if (this.highlight) return highlightClass(this.user) }, style () { - return [ - this.bg && `--mention-bg: ${this.bg}`, - this.text && `--mention-text: ${this.text}` - ].filter(_ => _).join('; ') + if (this.highlight) { + const { + backgroundColor, + backgroundPosition, + backgroundImage, + ...rest + } = highlightStyle(this.highlight) + return rest + } }, ...mapGetters(['mergedConfig']), ...mapState({ diff --git a/src/components/mention_link/mention_link.scss b/src/components/mention_link/mention_link.scss index 237d9205..3a3e58d1 100644 --- a/src/components/mention_link/mention_link.scss +++ b/src/components/mention_link/mention_link.scss @@ -2,12 +2,10 @@ position: relative; white-space: normal; display: inline-block; + color: var(--link); & .new, - & .original, - & .full { - padding: 0 2px; - margin: 0 -2px; + & .original { display: inline-block; border-radius: 2px; } @@ -17,24 +15,95 @@ } .full { - pointer-events: none; position: absolute; + display: inline-block; + pointer-events: none; opacity: 0; - top: 0; - bottom: 0; + top: 100%; left: 0; + height: 100%; word-wrap: normal; white-space: nowrap; transition: opacity 0.2s ease; - background-color: var(--mention-bg, var(--popover)); - color: var(--mention-text, var(--link)); z-index: 1; + margin-top: 0.25em; + padding: 0.5em; } - .new { - background-color: var(--mention-bg); - color: var(--mention-text, var(--link)); + & .short, + & .full { + &::before { + content: '@'; + } + } + + & .new { + &, + &.-striped, + &.-solid, + &.-side { + .full { + } + .short { + &::before { + display: inline-block; + height: 50%; + font-size: 90%; + line-height: 1; + vertical-align: 6%; + } + } + + .you { + padding-right: 0.25em; + } + .short { + padding-left: 0.25em; + padding-right: 0; + padding-top: 0; + padding-bottom: 0; + } + + .userName { + color: var(--link); + margin-left: 0.25em; + padding-left: 0.25em; + padding-right: 0.25em; + padding-top: 0; + padding-bottom: 0; + } + } + + &.-striped { + & .userName, + & .full { + background-image: + repeating-linear-gradient( + 135deg, + var(--____highlight-tintColor), + var(--____highlight-tintColor) 5px, + var(--____highlight-tintColor2) 5px, + var(--____highlight-tintColor2) 10px + ); + } + } + &.-solid { + & .userName, + & .full { + background-image: linear-gradient(var(--____highlight-tintColor2), var(--____highlight-tintColor2)); + } + } + + &.-side { + & .userName, + & .userNameFull { + box-shadow: 0 -5px 3px -4px inset var(--____highlight-solidColor); + } + } + } + + .new { &.-you { & .shortName, & .full { @@ -45,5 +114,6 @@ &:hover .new .full { opacity: 1; + pointer-events: initial; } } diff --git a/src/components/mention_link/mention_link.vue b/src/components/mention_link/mention_link.vue index ea356315..5a8506eb 100644 --- a/src/components/mention_link/mention_link.vue +++ b/src/components/mention_link/mention_link.vue @@ -12,22 +12,24 @@ v-if="user" class="new" :style="style" - :class="{ '-you': isYou }" + :class="[{ '-you': isYou }, highlightType]" > - @ + diff --git a/src/services/user_highlighter/user_highlighter.js b/src/services/user_highlighter/user_highlighter.js index b91c0f78..3b07592e 100644 --- a/src/services/user_highlighter/user_highlighter.js +++ b/src/services/user_highlighter/user_highlighter.js @@ -8,6 +8,11 @@ const highlightStyle = (prefs) => { const solidColor = `rgb(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)})` const tintColor = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .1)` const tintColor2 = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .2)` + const customProps = { + '--____highlight-solidColor': solidColor, + '--____highlight-tintColor': tintColor, + '--____highlight-tintColor2': tintColor2 + } if (type === 'striped') { return { backgroundImage: [ @@ -17,11 +22,13 @@ const highlightStyle = (prefs) => { `${tintColor2} 20px,`, `${tintColor2} 40px` ].join(' '), - backgroundPosition: '0 0' + backgroundPosition: '0 0', + ...customProps } } else if (type === 'solid') { return { - backgroundColor: tintColor2 + backgroundColor: tintColor2, + ...customProps } } else if (type === 'side') { return { @@ -31,7 +38,8 @@ const highlightStyle = (prefs) => { `${solidColor} 2px,`, `transparent 6px` ].join(' '), - backgroundPosition: '0 0' + backgroundPosition: '0 0', + ...customProps } } } -- cgit v1.2.3-70-g09d2 From 3abd357694c29c84d213d7d2a7a954ab2a591da0 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 8 Jun 2021 11:38:44 +0300 Subject: moving mentions into separate row --- src/components/mention_link/mention_link.js | 20 +++++++++++-- src/components/mention_link/mention_link.scss | 5 ++++ src/components/mention_link/mention_link.vue | 2 +- src/components/rich_content/rich_content.jsx | 19 +++++++++--- src/components/status/status.js | 22 ++++++++++---- src/components/status/status.scss | 3 +- src/components/status/status.vue | 43 ++++++++++++++++++++++----- src/i18n/en.json | 1 + 8 files changed, 94 insertions(+), 21 deletions(-) (limited to 'src/components/mention_link/mention_link.js') diff --git a/src/components/mention_link/mention_link.js b/src/components/mention_link/mention_link.js index d26ae337..465c7d00 100644 --- a/src/components/mention_link/mention_link.js +++ b/src/components/mention_link/mention_link.js @@ -14,8 +14,14 @@ const MentionLink = { type: String }, origattrs: { - required: true, - type: Object + required: false, + type: Object, + default: {} + }, + firstMention: { + required: false, + type: Boolean, + default: false } }, methods: { @@ -61,6 +67,16 @@ const MentionLink = { return rest } }, + classnames () { + return [ + { + '-you': this.isYou, + '-highlighted': this.highlight, + '-firstMention': this.firstMention + }, + this.highlightType + ] + }, ...mapGetters(['mergedConfig']), ...mapState({ currentUser: state => state.users.currentUser diff --git a/src/components/mention_link/mention_link.scss b/src/components/mention_link/mention_link.scss index 78a9816c..dec11014 100644 --- a/src/components/mention_link/mention_link.scss +++ b/src/components/mention_link/mention_link.scss @@ -39,10 +39,15 @@ } .new { + &.-firstMention { + display: none; + } + &, &.-highlighted { .short { line-height: 1.5; + font-size: inherit; &::before { display: inline-block; diff --git a/src/components/mention_link/mention_link.vue b/src/components/mention_link/mention_link.vue index d8d45a1b..05f6fd91 100644 --- a/src/components/mention_link/mention_link.vue +++ b/src/components/mention_link/mention_link.vue @@ -12,7 +12,7 @@ v-if="user" class="new" :style="style" - :class="[{ '-you': isYou, '-highlighted': highlight }, highlightType]" + :class="classnames" >