Skip to content

Commit

Permalink
Merge pull request #24 from saadiqbal-dev/main
Browse files Browse the repository at this point in the history
dropdown touchClick fixed
  • Loading branch information
elliotBraem authored Apr 17, 2024
2 parents 812fbc3 + bd68368 commit f783744
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 87 deletions.
169 changes: 99 additions & 70 deletions src/components/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { StopPretending } from "./icons/StopPretending";
import { User } from "./icons/User";
import PretendModal from "./navigation/PretendModal";
import Draggable from "react-draggable";
import context from "react-bootstrap/esm/AccordionContext";

const CoreBackdrop = styled.div`
position: fixed;
Expand Down Expand Up @@ -192,6 +193,7 @@ const Core = (props) => {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);

const handleTouchStart = () => {
event.stopPropagation();
if (window.innerWidth <= 1900) {
setIsDropdownOpen(!isDropdownOpen);
}
Expand Down Expand Up @@ -257,93 +259,120 @@ const Core = (props) => {
/>
</Button>
) : (
<Button onClick={props.requestSignIn} style={{ padding: 0 }}>
<Button
onClick={props.requestSignIn}
onTouchStart={props.requestSignIn}
style={{ padding: 0 }}
>
<i className="bi bi-key-fill" />
</Button>
)}

{/* {isDropdownOpen && ( */}
<StyledDropdown
className={`dropdown ${
isDropdownOpen ? "show" : ""
} ${dropdownPosition}`}
>
<ul
className="dropdown-menu"
aria-labelledby="dropdownMenu2222"
style={{ minWidth: "fit-content" }}
{account.accountId && (
<StyledDropdown
className={`dropdown ${
isDropdownOpen ? "show" : ""
} ${dropdownPosition}`}
>
<li>
<a
className="dropdown-item"
style={{ maxWidth: "300px" }}
type="button"
href={`https://${account.accountId}.social`}
>
<Widget
src={"mob.near/widget/Profile.InlineBlock"}
props={{
accountId: account.accountId,
<ul
className="dropdown-menu"
aria-labelledby="dropdownMenu2222"
style={{ minWidth: "fit-content" }}
>
<li>
<a
className="dropdown-item"
style={{ maxWidth: "300px" }}
href={`https://${account.accountId}.social`}
onTouchStart={(e) => {
e.preventDefault();
window.location.href = `https://${account.accountId}.social`;
}}
/>
</a>
</li>
<li>
<NavLink
className="dropdown-item"
type="button"
to={`/${account.accountId}`}
>
<User />
my everything
</NavLink>
</li>
{account.pretendAccountId ? (
>
<Widget
src={"mob.near/widget/Profile.InlineBlock"}
props={{
accountId: account.accountId,
}}
/>
</a>
</li>
<li>
<button
<NavLink
className="dropdown-item"
disabled={!account.startPretending}
onClick={() => account.startPretending(undefined)}
type="button"
to={`/${account.accountId}`}
onTouchStart={(e) => {
e.preventDefault();
history.push(`/${account.accountId}`);
}}
>
<StopPretending />
Stop pretending
</button>
<User />
my everything
</NavLink>
</li>
) : (
{account.pretendAccountId ? (
<li>
<button
className="dropdown-item"
disabled={!account.startPretending}
onClick={() => account.startPretending(undefined)}
onTouchStart={() =>
account.startPretending(undefined)
}
>
<StopPretending />
Stop pretending
</button>
</li>
) : (
<li>
<button
className="dropdown-item"
onClick={() => setShowPretendModal(true)}
onTouchStart={() => setShowPretendModal(true)}
>
<Pretend />
Pretend to be another account
</button>
</li>
)}
<li>
<button
className="dropdown-item"
onClick={() => setShowPretendModal(true)}
onClick={() => props.logOut()}
onTouchStart={() => props.logOut()}
>
<Pretend />
Pretend to be another account
<LogOut />
Sign Out
</button>
</li>
)}
<li>
<button
className="dropdown-item"
onClick={() => props.logOut()}
>
<LogOut />
Sign Out
</button>
</li>
<li>
<ButtonRow>
<ArrowButton>
<i className="bi bi-arrow-left"></i>
</ArrowButton>
<NavLink type="button" to={"/"}>
<i className="bi bi-house"></i>
</NavLink>
<ArrowButton>
<i className="bi bi-arrow-right"></i>
</ArrowButton>
</ButtonRow>
</li>
</ul>
</StyledDropdown>
<li>
<ButtonRow>
<ArrowButton>
<i className="bi bi-arrow-left"></i>
</ArrowButton>

<NavLink
type="button"
to={"/"}
onTouchStart={(e) => {
e.preventDefault();
history.push("/");
}}
>
<i className="bi bi-house"></i>
</NavLink>

<ArrowButton>
<i className="bi bi-arrow-right"></i>
</ArrowButton>
</ButtonRow>
</li>
</ul>
</StyledDropdown>
)}
{/* )} */}
</div>

Expand Down
36 changes: 22 additions & 14 deletions src/components/custom/tldraw/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ const Test = () => {
const currentPage = useValue("currentPage", () => editor.getCurrentPage(), [
editor,
]);

const viewportPageBounds = useValue(
"viewportPageBounds",
() => editor.getViewportPageBounds(),
Expand All @@ -103,23 +102,32 @@ const Test = () => {

useEffect(() => {
const updatePage = setTimeout(() => {
const newLocation = {
pathname:
location.pathname === "/" ? `/${accountId}` : location.pathname,
search: `page=${currentPage.name
.toLowerCase()
.split(" ")
.join("-")}&v=${viewportPageBounds.x.toFixed(
2
)},${viewportPageBounds.y.toFixed(2)},${viewportPageBounds.w},${
viewportPageBounds.h
}`,
};
let newLocation;
if (accountId) {
newLocation = {
pathname:
location.pathname === "/everything.near"
? `/${accountId}`
: location.pathname,
search: `?page=${currentPage.name
.toLowerCase()
.split(" ")
.join("-")}&v=${viewportPageBounds.x.toFixed(
2
)},${viewportPageBounds.y.toFixed(2)},${viewportPageBounds.w},${
viewportPageBounds.h
}`,
};
} else {
newLocation = {
pathname: "/everything.near",
};
}
history.push(newLocation);
}, 1000);

return () => clearTimeout(updatePage);
}, [currentPage, viewportPageBounds]);
}, [accountId, location.pathname, currentPage, viewportPageBounds, history]);

return <></>;
};
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9457,9 +9457,9 @@ near-social-vm-types@^1.0.0:
resolved "https://registry.yarnpkg.com/near-social-vm-types/-/near-social-vm-types-1.0.0.tgz#721494a863d2c0d64da2a43d80224e4080b690db"
integrity sha512-K5CxfiiKc7evzFb/1BGBOD2x4QqnEBuVaHkgRsRTGv02ctLkxA/Xf892SornWSkD75Hf0s9j/jeM5PpMfXcM9A==

"near-social-vm@git+https://github.com/NearSocial/VM.git#d4176930eeae95879e0f836c11d64384faafaab1":
version "2.5.3"
resolved "git+https://github.com/NearSocial/VM.git#d4176930eeae95879e0f836c11d64384faafaab1"
"near-social-vm@git+https://github.com/NearSocial/VM.git#2.6.0":
version "2.6.0"
resolved "git+https://github.com/NearSocial/VM.git#8dbb06526f15f10d562a118a38e4c0b6412beb88"
dependencies:
"@radix-ui/react-accordion" "^1.1.1"
"@radix-ui/react-alert-dialog" "^1.0.3"
Expand Down

0 comments on commit f783744

Please sign in to comment.