Welcome to mirror list, hosted at ThFree Co, Russian Federation.

badge_helper.js « helpers « image_diff « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ff00394e3bf7cfb1dc06237c75618a3fb90d05a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { spriteIcon } from '~/lib/utils/common_utils';

export function createImageBadge(noteId, { x, y }, classNames = []) {
  const buttonEl = document.createElement('button');
  const classList = classNames.concat(['js-image-badge']);
  classList.forEach((className) => buttonEl.classList.add(className));
  buttonEl.setAttribute('type', 'button');
  buttonEl.setAttribute('disabled', true);
  buttonEl.dataset.noteId = noteId;
  buttonEl.style.left = `${x}px`;
  buttonEl.style.top = `${y}px`;

  return buttonEl;
}

export function addImageBadge(containerEl, { coordinate, badgeText, noteId }) {
  const buttonEl = createImageBadge(noteId, coordinate, [
    'gl-display-flex',
    'gl-align-items-center',
    'gl-justify-content-center',
    'gl-font-sm',
    'design-note-pin',
    'on-image',
    'gl-absolute',
  ]);
  buttonEl.textContent = badgeText;

  containerEl.appendChild(buttonEl);
}

export function addImageCommentBadge(containerEl, { coordinate, noteId }) {
  const buttonEl = createImageBadge(noteId, coordinate, ['image-comment-badge']);
  buttonEl.innerHTML = spriteIcon('image-comment-dark');

  containerEl.appendChild(buttonEl);
}

export function addAvatarBadge(el, event) {
  const { noteId, badgeNumber } = event.detail;

  // Add design pin to new comment
  const avatarBadgeEl = el.querySelector(`#${noteId} .design-note-pin`);
  avatarBadgeEl.textContent = badgeNumber;
  avatarBadgeEl.classList.remove('hidden');
}