Skip to content

Commit

Permalink
Merge pull request #69 from N1ck/nickl-fix-updated-gh-styles
Browse files Browse the repository at this point in the history
GitHub, pls stop breaking my extension 😭
  • Loading branch information
N1ck authored Jan 6, 2024
2 parents 009c81d + ef04ba0 commit 0ee2edb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/giphy-toolbar-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import React from 'dom-chef'

export default (
<details class="details-reset details-overlay toolbar-item select-menu select-menu-modal-right ghg-trigger btn-octicon">
<details class=" details-reset details-overlay toolbar-item select-menu select-menu-modal-right ghg-trigger">
<summary
class="menu-target p-2 p-md-1 mx-1"
class="menu-target Button Button--iconOnly Button--invisible Button--medium"
aria-label="Insert a GIF"
aria-haspopup="menu"
>
Expand Down
17 changes: 14 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ function addToolbarButton() {
)) {
const form = toolbar.closest('form')

const reviewChangesModal = toolbar.closest(
'#review-changes-modal .SelectMenu-modal'
)
const reviewChangesModal = toolbar.closest('#review-changes-modal')
const reviewChangesList = toolbar.closest(
'#review-changes-modal .SelectMenu-list'
)
Expand All @@ -90,6 +88,19 @@ function addToolbarButton() {
// Otherwise the GIF selection popover will not be visible.
if (reviewChangesModal !== null) {
reviewChangesModal.classList.add('ghg-in-review-changes-modal')

// The Review changes modal sets an inline width of min(640px, 100vw - 2rem);
// our button takes up another 32px so we need to adjust the inline style to account for that, otherwise it's hidden.
const currentWidth = reviewChangesModal.style.width
if (currentWidth.includes('px')) {
// Extracts the value from the string (e.g., 640 from "min(640px, 100vw - 2rem)")
const widthValue = Number.parseInt(currentWidth.match(/\d+/)[0], 10)
const modifiedWidth = currentWidth.replace(
widthValue + 'px',
`${widthValue + 32}px`
)
reviewChangesModal.style.width = modifiedWidth
}
}

if (reviewChangesList !== null) {
Expand Down
2 changes: 0 additions & 2 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
}

.ghg-in-review-changes-modal {
/* Fixes the GIF button dropping to a new line in the review modal */
width: 678px !important;
/* Fixes the GIF dropdown being hidden by the review modal's overflow */
overflow: unset !important;
}
Expand Down

0 comments on commit 0ee2edb

Please sign in to comment.