Collapsible links & link GeyserOptionalPack download; Closes #17 (#19)

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
Co-authored-by: n15421 <124282010+xzfg-n15421@users.noreply.github.com>
This commit is contained in:
Kas-tleandn15421 authored and GitHub committed 2024-07-27 14:12:45 -07:00
1 parent 352260a7dc
commit 66f7ba18ce
4 files changed
+58 -7

No files matched your search

+44 -6
View File
@@ -1,4 +1,9 @@
import React, { useEffect, useRef, useState } from 'react';
import { useLocation, useHistory } from 'react-router-dom';
const useQuery = () => {
return new URLSearchParams(useLocation().search);
};
export const Collapsibles = ({ children }) => {
return (
@@ -13,19 +18,47 @@ interface CollapsibleProps {
subtitle?: React.ReactNode;
tags?: string[];
inner: React.ReactNode;
id: string;
}
export const Collapsible: React.FC<CollapsibleProps> = ({ title, subtitle, inner, tags = [] }) => {
const [isInnerVisible, setIsInnerVisible] = useState(false);
const innerRef = useRef(null);
export const Collapsible: React.FC<CollapsibleProps> = ({ title, subtitle, inner, tags = [], id }) => {
const query = useQuery();
const history = useHistory();
const initialExpandedState = query.get(id) === 'expanded';
const [isInnerVisible, setIsInnerVisible] = useState(initialExpandedState);
const innerRef = useRef<HTMLDivElement>(null);
const [innerHeight, setInnerHeight] = useState(0);
useEffect(() => {
const updateHeight = () => {
if (innerRef.current) {
setInnerHeight(isInnerVisible ? innerRef.current.scrollHeight : 0);
}
};
updateHeight();
const observer = new MutationObserver(updateHeight);
if (innerRef.current) {
setInnerHeight(isInnerVisible ? innerRef.current.scrollHeight : 0);
observer.observe(innerRef.current, { childList: true, subtree: true });
}
return () => {
observer.disconnect();
};
}, [isInnerVisible]);
useEffect(() => {
const params = new URLSearchParams(window.location.search);
if (isInnerVisible) {
params.set(id, 'expanded');
} else {
params.delete(id);
}
history.replace({ search: params.toString() });
}, [isInnerVisible, id, history]);
const toggleVisibility = () => {
setIsInnerVisible(!isInnerVisible);
};
@@ -34,8 +67,13 @@ export const Collapsible: React.FC<CollapsibleProps> = ({ title, subtitle, inner
<div className="collapsible">
<div className="collapsible-header" onClick={toggleVisibility}>
<p>
<span className="collapsible-title">{title}{tags.map((tag) => (<span className='badge badge--primary' style={{marginLeft:"0.25rem"}}>{tag}</span>))}</span>
{subtitle && <span className="collapsible-subtitle"><br/>{subtitle}</span>}
<span className="collapsible-title">
{title}
{tags.map((tag, index) => (
<span key={index} className='badge badge--primary' style={{ marginLeft: "0.25rem" }}>{tag}</span>
))}
</span>
{subtitle && <span className="collapsible-subtitle"><br />{subtitle}</span>}
</p>
<span className={isInnerVisible ? 'collapsible-arrow expanded' : 'collapsible-arrow'}></span>
</div>
+4
View File
@@ -60,6 +60,7 @@ const DownloadPage: React.FC = () => (
<Collapsible
title='GeyserConnect'
subtitle={<Translate id='pages.download.description.geyserconnect'>A plugin to allow for Geyser players to connect to your server without needing to use a proxy.</Translate>}
id='geyserconnect'
inner={
<ProjectDownload
projectId="geyserconnect"
@@ -74,6 +75,7 @@ const DownloadPage: React.FC = () => (
<Collapsible
title='GeyserOptionalPack'
subtitle={<Translate id='pages.download.description.geyseroptionalpack'>An optional Bedrock resource pack to extend Geyser functionality.</Translate>}
id='geyseroptionalpack'
inner={
<ProjectDownload
projectId="geyseroptionalpack"
@@ -88,6 +90,7 @@ const DownloadPage: React.FC = () => (
<Collapsible
title='ThirdPartyCosmetics'
subtitle={<Translate id='pages.download.description.thirdpartycosmetics'>An extension that adds support for loading ears and other third party cosmetics on java players</Translate>}
id='thirdpartycosmetics'
inner={
<ProjectDownload
projectId="thirdpartycosmetics"
@@ -102,6 +105,7 @@ const DownloadPage: React.FC = () => (
<Collapsible
title='Hydraulic'
subtitle={<Translate id='pages.download.description.hydraulic'>A companion mod to Geyser which allows for Bedrock players to join modded Minecraft: Java Edition servers.</Translate>}
id='hydraulic'
tags={['Beta']}
inner={
<ProjectDownload
+9
View File
@@ -0,0 +1,9 @@
declare module '*.module.scss' {
const classes: {readonly [key: string]: string};
export default classes;
}
declare module '*.scss' {
const src: string;
export default src;
}
+1 -1
View File
@@ -3,7 +3,7 @@ title: GeyserOptionalPack
description: GeyserOptionalPack is a Bedrock resource pack that fixes parity issues with Geyser to bring Bedrock Edition in line with Java Edition.
---
## [Download here](https://ci.opencollab.dev/job/GeyserMC/job/GeyserOptionalPack/job/master/lastSuccessfulBuild/artifact/GeyserOptionalPack.mcpack) {#download-here}
## [Download here](/download?project=other-projects&geyseroptionalpack=expanded) {#download-here}
GeyserOptionalPack is a Bedrock resource pack that adds more features to Geyser to bring Bedrock Edition in line with Java Edition. A resource pack allows various features and bug fixes to be implemented in Bedrock, including: