Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add avatars below cursors #530

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/editor-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path')
const {Range, Emitter, Disposable, CompositeDisposable, TextBuffer} = require('atom')
const {getEditorURI} = require('./uri-helpers')
const {FollowState} = require('@atom/teletype-client')
const getAvatarURL = require('./get-avatar-url')

module.exports =
class EditorBinding {
Expand Down Expand Up @@ -148,6 +149,15 @@ class EditorBinding {
markerLayer = this.editor.addMarkerLayer()
this.editor.decorateMarkerLayer(markerLayer, {type: 'cursor', class: cursorClassForSiteId(siteId, {blink: false})})
this.editor.decorateMarkerLayer(markerLayer, {type: 'highlight', class: 'selection'})

const {login} = this.portal.getSiteIdentity(siteId)
const overlayElement = document.createElement('div')
overlayElement.className = `avatar-below-cursor-site color--site-${siteId}`
const overlayImageElement = document.createElement('img')
overlayImageElement.src = getAvatarURL(login, 40)
overlayElement.appendChild(overlayImageElement)
this.editor.decorateMarkerLayer(markerLayer, {type: 'overlay', class: 'avatar-below-cursor', item: overlayElement})

this.markerLayersBySiteId.set(siteId, markerLayer)
}

Expand Down
19 changes: 18 additions & 1 deletion styles/teletype.less
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,26 @@
}
}

.avatar-below-cursor {
pointer-events: none;

img {
height: 44px;
border: 2px solid transparent;
border-radius: 50%
}

.avatar-below-cursor-site {
border: solid 2px transparent;
border-radius: 50%;
position: relative;
left: -50%;
}
}
// Site colors
.cursor.ParticipantCursor, // cursor
.SitePositionsComponent-site.color { // avatar
.SitePositionsComponent-site.color, // avatar
.avatar-below-cursor-site.color {
&--site-1 { border-color: @ui-site-color-1; }
&--site-2 { border-color: @ui-site-color-2; }
&--site-3 { border-color: @ui-site-color-3; }
Expand Down