-
+
{/* RightBar content on mobile */}
@@ -373,7 +368,7 @@ export function LeftBar() {
}
export function RightBar() {
- const { setRightBarSize, rightBarVisible } = useBars();
+ const { setRightBarSize, rightBarSize, rightBarVisible } = useBars();
let ref: HTMLDivElement | undefined;
let actualWidth = 0;
@@ -415,7 +410,8 @@ export function RightBar() {
style={{
"transition-timing-function": rightBarVisible()
? "cubic-bezier(0.34, 1.56, 0.64, 1)"
- : "cubic-bezier(0.4, 0, 0.2, 1)"
+ : "cubic-bezier(0.4, 0, 0.2, 1)",
+ "min-width": rightBarSize() > 0 ? `${rightBarSize()}px` : undefined
}}
>
diff --git a/src/components/blog/PostBodyClient.tsx b/src/components/blog/PostBodyClient.tsx
index 633e31a..4aab076 100644
--- a/src/components/blog/PostBodyClient.tsx
+++ b/src/components/blog/PostBodyClient.tsx
@@ -118,7 +118,7 @@ export default function PostBodyClient(props: PostBodyClientProps) {
diff --git a/src/components/blog/SessionDependantLike.tsx b/src/components/blog/SessionDependantLike.tsx
index 11f08be..64ba865 100644
--- a/src/components/blog/SessionDependantLike.tsx
+++ b/src/components/blog/SessionDependantLike.tsx
@@ -36,37 +36,28 @@ export default function SessionDependantLike(props: SessionDependantLikeProps) {
if (initialHasLiked) {
const result = await api.database.removePostLike.mutate({
user_id: props.currentUserID,
- post_id: props.projectID.toString(),
+ post_id: props.projectID.toString()
});
setLikes(result.newLikes as PostLike[]);
} else {
const result = await api.database.addPostLike.mutate({
user_id: props.currentUserID,
- post_id: props.projectID.toString(),
+ post_id: props.projectID.toString()
});
setLikes(result.newLikes as PostLike[]);
}
setInstantOffset(0);
} catch (error) {
- console.error("There has been a problem with your like operation:", error);
+ console.error(
+ "There has been a problem with your like operation:",
+ error
+ );
setHasLiked(initialHasLiked);
setInstantOffset(0);
}
};
const likeCount = () => likes().length + instantOffset();
-
- const getLikeIconColor = () => {
- if (hasLiked()) {
- return "fill-orange-400";
- }
-
- if (hovering()) {
- return "fill-orange-400 dark:fill-orange-500";
- }
-
- return "fill-black dark:fill-white";
- };
return (
-
+
{likes().length} {likes().length === 1 ? "Like" : "Likes"}
Must be logged in
@@ -93,18 +84,18 @@ export default function SessionDependantLike(props: SessionDependantLikeProps) {
onMouseOver={() => setHovering(true)}
onMouseLeave={() => setHovering(false)}
>
-
-
+
+
{likeCount()} {likeCount() === 1 ? "Like" : "Likes"}
diff --git a/src/components/icons/CommentIcon.tsx b/src/components/icons/CommentIcon.tsx
index 4c09012..3a0f18a 100644
--- a/src/components/icons/CommentIcon.tsx
+++ b/src/components/icons/CommentIcon.tsx
@@ -9,7 +9,7 @@ export default function CommentIcon(props: {
fill="none"
viewBox="0 0 24 24"
strokeWidth={props.strokeWidth}
- class="fill-black dark:fill-white"
+ class="hover:fill-blue fill-text"
height={props.height}
width={props.width}
>
diff --git a/src/context/bars.tsx b/src/context/bars.tsx
index f598cd1..7146dcb 100644
--- a/src/context/bars.tsx
+++ b/src/context/bars.tsx
@@ -1,4 +1,4 @@
-import { Accessor, createContext, useContext } from "solid-js";
+import { Accessor, createContext, useContext, createMemo } from "solid-js";
import { createSignal } from "solid-js";
import { hapticFeedback } from "~/lib/client-utils";
@@ -38,37 +38,70 @@ export function useBars() {
}
export function BarsProvider(props: { children: any }) {
- const [leftBarSize, setLeftBarSize] = createSignal(0);
- const [rightBarSize, setRightBarSize] = createSignal(0);
+ const [_leftBarNaturalSize, _setLeftBarNaturalSize] = createSignal(0);
+ const [_rightBarNaturalSize, _setRightBarNaturalSize] = createSignal(0);
+ const [syncedBarSize, setSyncedBarSize] = createSignal(0);
const [centerWidth, setCenterWidth] = createSignal(0);
const [leftBarVisible, _setLeftBarVisible] = createSignal(true);
const [rightBarVisible, _setRightBarVisible] = createSignal(true);
const [barsInitialized, setBarsInitialized] = createSignal(false);
- // Track when both bars have been sized at least once
let leftBarSized = false;
let rightBarSized = false;
const wrappedSetLeftBarSize = (size: number) => {
- setLeftBarSize(size);
- if (!leftBarSized && size > 0) {
- leftBarSized = true;
- if (rightBarSized) {
- setBarsInitialized(true);
+ if (!barsInitialized()) {
+ // Before initialization, capture natural size
+ _setLeftBarNaturalSize(size);
+ if (!leftBarSized && size > 0) {
+ leftBarSized = true;
+ checkAndSync();
}
+ } else {
+ // After initialization, just update the natural size for visibility handling
+ _setLeftBarNaturalSize(size);
}
};
const wrappedSetRightBarSize = (size: number) => {
- setRightBarSize(size);
- if (!rightBarSized && size > 0) {
- rightBarSized = true;
- if (leftBarSized) {
- setBarsInitialized(true);
+ if (!barsInitialized()) {
+ // Before initialization, capture natural size
+ _setRightBarNaturalSize(size);
+ if (!rightBarSized && size > 0) {
+ rightBarSized = true;
+ checkAndSync();
}
+ } else {
+ // After initialization, just update the natural size for visibility handling
+ _setRightBarNaturalSize(size);
}
};
+ const checkAndSync = () => {
+ const isMobile = typeof window !== "undefined" && window.innerWidth < 768;
+ const bothBarsReady = leftBarSized && (isMobile || rightBarSized);
+
+ if (bothBarsReady) {
+ const maxWidth = Math.max(_leftBarNaturalSize(), _rightBarNaturalSize());
+ setSyncedBarSize(maxWidth);
+ setBarsInitialized(true);
+ }
+ };
+
+ const leftBarSize = createMemo(() => {
+ // Return 0 if hidden (natural size is 0), otherwise return synced size when initialized
+ const naturalSize = _leftBarNaturalSize();
+ if (naturalSize === 0) return 0; // Hidden
+ return barsInitialized() ? syncedBarSize() : naturalSize;
+ });
+
+ const rightBarSize = createMemo(() => {
+ // Return 0 if hidden (natural size is 0), otherwise return synced size when initialized
+ const naturalSize = _rightBarNaturalSize();
+ if (naturalSize === 0) return 0; // Hidden
+ return barsInitialized() ? syncedBarSize() : naturalSize;
+ });
+
// Wrap visibility setters with haptic feedback
const setLeftBarVisible = (visible: boolean) => {
hapticFeedback(50);
diff --git a/src/routes/blog/[title]/index.tsx b/src/routes/blog/[title]/index.tsx
index 17895ea..fc26362 100644
--- a/src/routes/blog/[title]/index.tsx
+++ b/src/routes/blog/[title]/index.tsx
@@ -179,7 +179,7 @@ export default function PostPage() {
/>