Skip to content

Instantly share code, notes, and snippets.

View florianwalther-private's full-sized avatar

Florian Walther florianwalther-private

View GitHub Profile
@florianwalther-private
florianwalther-private / Comment.tsx
Created March 19, 2023 12:58
Comment.tsx - Private components inside same file
interface CommentProps {
comment: CommentModel,
onReplyCreated: (reply: CommentModel) => void,
onCommentUpdated: (updatedComment: CommentModel) => void,
onCommentDeleted: (comment: CommentModel) => void,
}
export default function Comment({ comment, onReplyCreated, onCommentUpdated, onCommentDeleted }: CommentProps) {
const { user } = useAuthenticatedUser();
interface AuthModalsContext {
showLoginModal: () => void,
showSignUpModal: () => void,
showResetPasswordModal: () => void,
}
export const AuthModalsContext = createContext<AuthModalsContext>({
showLoginModal: () => { throw new Error("AuthModalContext not implemented") },
showSignUpModal: () => { throw new Error("AuthModalContext not implemented") },
showResetPasswordModal: () => { throw new Error("AuthModalContext not implemented") },
@florianwalther-private
florianwalther-private / _app.tsx
Last active March 7, 2023 09:05
_app.tsx refactored
interface AppContext {
showLoginModal: () => void,
showTooManyRequestsMessage: () => void,
}
export const AppContext = createContext<AppContext>({
showLoginModal: () => { throw new ("Context not implemented") },
showTooManyRequestsMessage: () => { throw new ("Context not implemented") },
});
@florianwalther-private
florianwalther-private / _app.tsx
Last active March 7, 2023 08:54
AuthModals component
type AuthModalState = "none" | "login" | "signup" | "resetpassword";
interface AuthModalProps {
state: AuthModalState
setState: (state: AuthModalState) => void,
}
function AuthModals({ state, setState }: AuthModalProps) {
if (state === "signup") {
@florianwalther-private
florianwalther-private / _app.tsx
Last active March 7, 2023 02:33
_app.tsx structure
interface AppContext {
showLoginModal: () => void,
showTooManyRequestsMessage: () => void,
}
export const AppContext = createContext<AppContext>({
showLoginModal: () => { throw new Error("Context not implemented") },
showTooManyRequestsMessage: () => { throw new Error("Context not implemented") },
});
@florianwalther-private
florianwalther-private / Comment.tsx
Last active March 1, 2023 10:04
Updated Comment component
import UserProfileLink from "@/components/UserProfileLink";
import { formatRelativeDate } from "@/helpers/utils";
import { useAuthenticatedUser } from "@/hooks/useAuthenticatedUser";
import { Comment as CommentModel } from "@/models/comment";
import { NotFoundError } from "@/network/http-errors";
import { AppContext } from "@/pages/_app";
import { useContext, useState } from "react";
import { Button } from "react-bootstrap";
import CreateCommentBox from "./CreateCommentBox";
import EditCommentBox from "./EditCommentBox";
@florianwalther-private
florianwalther-private / PaginationBar.tsx
Created February 26, 2023 08:06
Pagination component structure question
interface PaginationBarProps {
pageCount: number,
currentPage: number,
onPageItemClicked: (page: number) => void,
}
const PaginationBar = ({ pageCount, currentPage, onPageItemClicked }: PaginationBarProps) => {
const paginationMinPage = Math.max(1, currentPage - 5);
const paginationMaxPage = Math.min(pageCount, Math.max(currentPage + 4, 10));
@florianwalther-private
florianwalther-private / Commen.tsx
Last active February 25, 2023 11:53
Improved file structure from feedback
import UserProfileLink from "@/components/UserProfileLink";
import { formatRelativeDate } from "@/helpers/utils";
import { useAuthenticatedUser } from "@/hooks/useAuthenticatedUser";
import { Comment as CommentModel } from "@/models/comment";
import { NotFoundError } from "@/network/http-errors";
import { AppContext } from "@/pages/_app";
import { useContext, useState } from "react";
import { Button } from "react-bootstrap";
import CreateCommentBox from "./CreateCommentBox";
import EditCommentBox from "./EditCommentBox";
@florianwalther-private
florianwalther-private / Comment.tsx
Created February 25, 2023 09:44
Question about organizing code into JSX variables
import UserProfileLink from "@/components/UserProfileLink";
import { formatRelativeDate } from "@/helpers/utils";
import { useAuthenticatedUser } from "@/hooks/useAuthenticatedUser";
import { Comment as CommentModel } from "@/models/comment";
import { NotFoundError } from "@/network/http-errors";
import { AppContext } from "@/pages/_app";
import { useContext, useState } from "react";
import { Button } from "react-bootstrap";
import CreateCommentBox from "./CreateCommentBox";
import EditCommentBox from "./EditCommentBox";
package com.codinginflow.just10minutes.data
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize
@Entity(tableName = "task_table")
@Parcelize
data class Task(