From dba3b01cce565cc05a0e3f2c7ba46050d2d942b6 Mon Sep 17 00:00:00 2001 From: KennethTsang9286 Date: Mon, 16 Nov 2020 11:18:42 +1100 Subject: Avoid duplicate upload button in 'rgh-minimize-upload-bar' (#3724) Co-authored-by: Federico --- readme.md | 2 +- source/features/minimize-upload-bar.css | 8 ++++++++ source/features/minimize-upload-bar.tsx | 25 +------------------------ 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/readme.md b/readme.md index 82ca6dbf..08f7c2d0 100644 --- a/readme.md +++ b/readme.md @@ -135,7 +135,7 @@ Thanks for contributing! πŸ¦‹πŸ™Œ - [](# "edit-comments-faster") [Lets you edit any comment with one click instead of having to open a dropdown.](https://user-images.githubusercontent.com/1402241/54864831-92372a00-4d97-11e9-8c29-efba2dde1baa.png) - [](# "comment-fields-keyboard-shortcuts") [Adds a shortcut to edit your last comment: ↑.](https://github.com/sindresorhus/refined-github/pull/961) (Only works in the following comment field, if it’s empty.) - [](# "one-key-formatting") [Wraps selected text when pressing one of Markdown symbols instead of replacing it:](https://user-images.githubusercontent.com/1402241/65020298-1f2dfb00-d957-11e9-9a2a-1c0ceab8d9e0.gif) `[` `` ` `` `'` `"` `*` `~` `_` -- [](# "minimize-upload-bar") [Reduces the upload bar to a small button.](https://user-images.githubusercontent.com/55841/59802383-3d994180-92e9-11e9-835d-60de67611c30.png) +- [](# "minimize-upload-bar") [Reduces the upload bar to a small button.](https://user-images.githubusercontent.com/17612510/99140148-205dd380-2693-11eb-9a61-9c228f8f9e36.png) - [](# "clean-rich-text-editor") [Hides unnecessary comment field tooltips and toolbar items](https://user-images.githubusercontent.com/1402241/53629083-a4fe8900-3c47-11e9-8211-bfe2d254ffcb.png) (each one has a keyboard shortcut.) - [](# "monospace-textareas") Uses a monospace font for all textareas. - [](# "quick-mention") [Adds a button to `@mention` a user in conversations.](https://user-images.githubusercontent.com/1402241/70406615-f445d580-1a73-11ea-9ab1-bf6bd9aa70a3.gif) diff --git a/source/features/minimize-upload-bar.css b/source/features/minimize-upload-bar.css index d320347a..e046dbbd 100644 --- a/source/features/minimize-upload-bar.css +++ b/source/features/minimize-upload-bar.css @@ -7,3 +7,11 @@ border-bottom-style: solid; border-radius: 6px; } + +/* Show upload image button in PR minimized upload bar for desktop */ +@media (min-width: 768px) { + .rgh-minimize-upload-bar .js-previewable-comment-form label[aria-label='Attach an image'] { + display: block !important; + padding: 4px !important; + } +} diff --git a/source/features/minimize-upload-bar.tsx b/source/features/minimize-upload-bar.tsx index a8d51bd3..73dc8cd9 100644 --- a/source/features/minimize-upload-bar.tsx +++ b/source/features/minimize-upload-bar.tsx @@ -1,33 +1,10 @@ import './minimize-upload-bar.css'; -import React from 'dom-chef'; -import select from 'select-dom'; -import delegate from 'delegate-it'; -import UploadIcon from 'octicon/upload.svg'; import * as pageDetect from 'github-url-detection'; import features from '.'; -function addButton(): void { - for (const toolbarButton of select.all('md-ref')) { - toolbarButton.after( - - ); - toolbarButton.closest('form')!.classList.add('rgh-minimize-upload-bar'); - } -} - -function triggerUpload(event: delegate.Event): void { - event.delegateTarget - .form! - .querySelector('[type="file"]')! - .click(); // Open UI -} - function init(): void { - addButton(); - delegate(document, '.rgh-upload-btn', 'click', triggerUpload); + document.body.classList.add('rgh-minimize-upload-bar'); } void features.add(__filebasename, { -- cgit v1.2.3