Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
ui/cards: refactor
Adorian Doran489a88b8da96
diff --git a/apps/client/src/widgets/react/Card.css b/apps/client/src/widgets/react/Card.cssindex 1472dc135a..cabc4a0889 100644--- a/apps/client/src/widgets/react/Card.css+++ b/apps/client/src/widgets/react/Card.css@@ -43,6 +43,5 @@background-color: var(--card-background-hover-color);transition: background-color .2s ease-out;}-}}\ No newline at end of filediff --git a/apps/client/src/widgets/react/Card.tsx b/apps/client/src/widgets/react/Card.tsxindex 6f41a2e6f3..01b40ee306 100644--- a/apps/client/src/widgets/react/Card.tsx+++ b/apps/client/src/widgets/react/Card.tsx@@ -4,7 +4,9 @@ import { JSX } from "preact";import { useContext } from "preact/hooks";import clsx from "clsx";-interface CardProps {+// #region Card++export interface CardProps {className?: string;heading?: string;}@@ -18,7 +20,11 @@ export function Card(props: {children: ComponentChildren} & CardProps) {</div>;}-interface CardSectionProps {+// #endregion++// #region Card Section++export interface CardSectionProps {className?: string;subSections?: JSX.Element | JSX.Element[];subSectionsVisible?: boolean;@@ -26,6 +32,12 @@ interface CardSectionProps {onAction?: () => void;}+interface CardSectionContextType {+ nestingLevel: number;+}++const CardSectionContext = createContext<CardSectionContextType | undefined>(undefined);+export function CardSection(props: {children: ComponentChildren} & CardSectionProps) {const parentContext = useContext(CardSectionContext);const nestingLevel = (parentContext && parentContext.nestingLevel + 1) ?? 0;@@ -40,7 +52,7 @@ export function CardSection(props: {children: ComponentChildren} & CardSectionPr{props.children}</section>- {props.subSectionsVisible &&+ {props.subSectionsVisible && props.subSections &&<CardSectionContext.Provider value={{nestingLevel}}>{props.subSections}</CardSectionContext.Provider>@@ -48,8 +60,4 @@ export function CardSection(props: {children: ComponentChildren} & CardSectionPr</>;}-interface CardSectionContextType {- nestingLevel: number;-}--export const CardSectionContext = createContext<CardSectionContextType | undefined>(undefined);\ No newline at end of file+// #endregion\ No newline at end of file