Skip to content

Commit

Permalink
0.8.5 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Sep 8, 2024
1 parent 16c5a5a commit 10dbac6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
33 changes: 27 additions & 6 deletions apps/app-frontend/src/pages/project/Gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
</span>
</Card>
</div>
<div v-if="expandedGalleryItem" class="expanded-image-modal" @click="expandedGalleryItem = null">
<div v-if="expandedGalleryItem" class="expanded-image-modal" @click="hideImage">
<div class="content">
<img
class="image"
:class="{ 'zoomed-in': zoomedIn }"
:src="
expandedGalleryItem.url
? expandedGalleryItem.url
expandedGalleryItem.raw_url
? expandedGalleryItem.raw_url
: 'https://cdn.modrinth.com/placeholder-banner.svg'
"
:alt="expandedGalleryItem.title ? expandedGalleryItem.title : 'gallery-image'"
Expand All @@ -45,15 +45,15 @@
</div>
<div class="controls">
<div class="buttons">
<Button class="close" icon-only @click="expandedGalleryItem = null">
<Button class="close" icon-only @click="hideImage">
<XIcon aria-hidden="true" />
</Button>
<a
class="open btn icon-only"
target="_blank"
:href="
expandedGalleryItem.url
? expandedGalleryItem.url
expandedGalleryItem.raw_url
? expandedGalleryItem.raw_url
: 'https://cdn.modrinth.com/placeholder-banner.svg'
"
>
Expand Down Expand Up @@ -94,6 +94,7 @@ import {
import { Button, Card } from '@modrinth/ui'
import { ref } from 'vue'
import { trackEvent } from '@/helpers/analytics'
import { show_ads_window, hide_ads_window } from '@/helpers/ads.js'
const props = defineProps({
project: {
Expand All @@ -106,6 +107,11 @@ let expandedGalleryItem = ref(null)
let expandedGalleryIndex = ref(0)
let zoomedIn = ref(false)
const hideImage = () => {
expandedGalleryItem.value = null
show_ads_window()
}
const nextImage = () => {
expandedGalleryIndex.value++
if (expandedGalleryIndex.value >= props.project.gallery.length) {
Expand All @@ -131,6 +137,7 @@ const previousImage = () => {
}
const expandImage = (item, index) => {
hide_ads_window()
expandedGalleryItem.value = item
expandedGalleryIndex.value = index
zoomedIn.value = false
Expand All @@ -140,6 +147,20 @@ const expandImage = (item, index) => {
url: item.url,
})
}
function keyListener(e) {
if (expandedGalleryItem.value) {
e.preventDefault()
if (e.key === 'Escape') {
hideImage()
} else if (e.key === 'ArrowLeft') {
previousImage()
} else if (e.key === 'ArrowRight') {
nextImage()
}
}
}
document.addEventListener('keypress', keyListener)
</script>

<style scoped lang="scss">
Expand Down
8 changes: 4 additions & 4 deletions apps/frontend/src/pages/[type]/[id]/gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
class="image"
:class="{ 'zoomed-in': zoomedIn }"
:src="
expandedGalleryItem.url
? expandedGalleryItem.url
expandedGalleryItem.raw_url
? expandedGalleryItem.raw_url
: 'https://cdn.modrinth.com/placeholder-banner.svg'
"
:alt="expandedGalleryItem.title ? expandedGalleryItem.title : 'gallery-image'"
Expand All @@ -165,8 +165,8 @@
class="open circle-button"
target="_blank"
:href="
expandedGalleryItem.url
? expandedGalleryItem.url
expandedGalleryItem.raw_url
? expandedGalleryItem.raw_url
: 'https://cdn.modrinth.com/placeholder-banner.svg'
"
>
Expand Down
27 changes: 20 additions & 7 deletions packages/app-lib/src/util/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ pub trait OsExt {

/// Gets the OS + Arch of the current system
fn native_arch(java_arch: &str) -> Self;

/// Gets the OS from an OS + Arch
fn get_os(&self) -> Self;
}

impl OsExt for Os {
fn native() -> Self {
match std::env::consts::OS {
"windows" => Self::Windows,
"macos" => Self::Osx,
"linux" => Self::Linux,
_ => Self::Unknown,
}
}

fn native_arch(java_arch: &str) -> Self {
if std::env::consts::OS == "windows" {
if java_arch == "aarch64" {
Expand All @@ -38,12 +50,13 @@ impl OsExt for Os {
}
}

fn native() -> Self {
match std::env::consts::OS {
"windows" => Self::Windows,
"macos" => Self::Osx,
"linux" => Self::Linux,
_ => Self::Unknown,
fn get_os(&self) -> Self {
match self {
Os::OsxArm64 => Os::Osx,
Os::LinuxArm32 => Os::Linux,
Os::LinuxArm64 => Os::Linux,
Os::WindowsArm64 => Os::Windows,
_ => self.clone(),
}
}
}
Expand Down Expand Up @@ -73,7 +86,7 @@ pub fn os_rule(
&& (name != &Os::LinuxArm64 || name != &Os::LinuxArm32)
{
rule_match &=
&Os::native() == name || &Os::native_arch(java_arch) == name;
&Os::native() == &name.get_os() || &Os::native_arch(java_arch) == name;
} else {
rule_match &= &Os::native_arch(java_arch) == name;
}
Expand Down

0 comments on commit 10dbac6

Please sign in to comment.