Skip to content

Commit

Permalink
Fix ImageZoom
Browse files Browse the repository at this point in the history
Also fixes the image modal being off centre when having the plugin enabled

Co-Authored-By: sadan <117494111+sadan4@users.noreply.github.com>
  • Loading branch information
2 people authored and Autumnlight02 committed Nov 20, 2024
1 parent 621d375 commit a48b558
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
17 changes: 3 additions & 14 deletions src/plugins/imageZoom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,10 @@ export default definePlugin({

patches: [
{
find: "Messages.OPEN_IN_BROWSER",
find: ".contain,SCALE_DOWN:",
replacement: {
// there are 2 image thingies. one for carosuel and one for the single image.
// so thats why i added global flag.
// also idk if this patch is good, should it be more specific?
// https://regex101.com/r/xfvNvV/1
match: /return.{1,200}\.wrapper.{1,200}src:\i,/g,
replace: `$&id: '${ELEMENT_ID}',`
match: /\.slide,\i\),/g,
replace: `$&id:"${ELEMENT_ID}",`
}
},

Expand All @@ -185,13 +181,6 @@ export default definePlugin({
replace: "$&$self.unMountMagnifier();"
}
]
},
{
find: ".carouselModal",
replacement: {
match: /(?<=\.carouselModal.{0,100}onClick:)\i,/,
replace: "()=>{},"
}
}
],

Expand Down
9 changes: 0 additions & 9 deletions src/plugins/imageZoom/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,3 @@

/* https://googlechrome.github.io/samples/image-rendering-pixelated/index.html */
}

/* make the carousel take up less space so we can click the backdrop and exit out of it */
[class*="modalCarouselWrapper_"] {
top: 0 !important;
}

[class*="carouselModal_"] {
height: 0 !important;
}
2 changes: 2 additions & 0 deletions src/plugins/serverInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export default definePlugin({
name: "ServerInfo",
description: "Allows you to view info about a server",
authors: [Devs.Ven, Devs.Nuckyz],
dependencies: ["DynamicImageModalAPI"],
tags: ["guild", "info", "ServerProfile"],

contextMenus: {
"guild-context": Patch,
"guild-header-popout": Patch
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/spotifyControls/PlayerComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ function AlbumContextMenu({ track }: { track: Track; }) {
id="view-cover"
label="View Album Cover"
// trolley
action={() => openImageModal({
url: track.album.image.url,
height: 512,
width: 512
})}
action={() => openImageModal(track.album.image)}
icon={ImageIcon}
/>
<Menu.MenuControlItem
Expand Down
21 changes: 21 additions & 0 deletions src/utils/discord.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
.vc-position-inherit {
position: inherit;
}

/**
* copy pasted from discord css. not really webpack-findable since it's the only class in the module
**/

.vc-image-modal {
background: transparent!important;
box-shadow: none!important;
display: flex;
justify-content: center;
align-items: center;
border-radius: 0
}

@media(width <= 485px) {
.vc-image-modal {
display:relative;
overflow: visible;
overflow: initial
}
}
1 change: 1 addition & 0 deletions src/utils/discord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function openImageModal(props: Omit<ImageModalItem, "type">): string {
return openModal(modalProps => (
<ImageModal
{...modalProps}
className="vc-image-modal"
fit="vc-position-inherit"
items={[{
type: "IMAGE",
Expand Down

0 comments on commit a48b558

Please sign in to comment.