1
0
Prechádzať zdrojové kódy

cleanup, improve web doc comments

Aneurin Barker Snook 1 rok pred
rodič
commit
8ded586b3f

+ 2 - 0
web/src/api/lib.ts

@@ -62,6 +62,7 @@ export class RequestError extends Error {
   }
 }
 
+/** Search and pagination parameters. */
 export interface SearchParams {
   limit?: number
   page?: number
@@ -69,6 +70,7 @@ export interface SearchParams {
   sort?: string[]
 }
 
+/** Standard response structure for search APIs. */
 export interface SearchResponse<T> {
   results: T[]
   metadata: {

+ 1 - 1
web/src/components/Row.tsx

@@ -5,7 +5,7 @@ export interface RowProps {
   className?: string
 }
 
-export default function Row({ children, className }: PropsWithChildren<RowProps>) {
+export default function Row({ children, className = '' }: PropsWithChildren<RowProps>) {
   return (
     <div className={`row ${className}`}>
       {children}

+ 0 - 27
web/src/components/form/GrowingTextInput.scss

@@ -1,27 +0,0 @@
-@import '@/vars.scss';
-@import './mixins.scss';
-
-/**
- * Auto-growing textarea.
- * Based on https://css-tricks.com/the-cleanest-trick-for-autogrowing-textareas/
- */
-.growing-text-input {
-  display: grid;
-
-  &::after {
-    @include input;
-    content: attr(data-replicated-value) " ";
-    visibility: hidden;
-    white-space: pre-wrap;
-  }
-
-  textarea {
-    resize: none;
-    overflow: hidden;
-  }
-
-  textarea,
-  &::after {
-    grid-area: 1 / 1 / 2 / 2;
-  }
-}

+ 0 - 25
web/src/components/form/GrowingTextInput.tsx

@@ -1,25 +0,0 @@
-import './GrowingTextInput.scss'
-import { forwardRef } from 'react'
-import type { DetailedHTMLProps, KeyboardEvent, TextareaHTMLAttributes } from 'react'
-
-export interface GrowingTextInputProps extends DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> {}
-
-const GrowingTextInput = forwardRef<HTMLTextAreaElement, GrowingTextInputProps>((props, ref) => {
-  const { className, onInput, ...restProps } = props
-
-  function replicateValue(e: KeyboardEvent<HTMLTextAreaElement>) {
-    if (e.currentTarget.parentElement) {
-      e.currentTarget.parentElement.dataset.replicatedValue = e.currentTarget.value
-    }
-
-    onInput?.(e)
-  }
-
-  return (
-    <div className={`growing-text-input ${className}`}>
-      <textarea {...restProps} onInput={replicateValue} ref={ref} />
-    </div>
-  )
-})
-
-export default GrowingTextInput

+ 11 - 0
web/src/hooks/index.ts

@@ -5,14 +5,25 @@ import { useContext } from 'react'
 
 export { useRouteSearch } from './routeSearch'
 
+/**
+ * Get the connection to the Herda server.
+ * This provides access to request options such as base URL, authentication etc.
+ */
 export function useConnection() {
   return useContext(ConnectionContext)
 }
 
+/**
+ * Get functions to modify the document, including setting the page title.
+ */
 export function useDocument() {
   return useContext(DocumentContext)
 }
 
+/**
+ * Get the user session, using the connection authentication.
+ * This also provides functions to verify and manage the session.
+ */
 export function useSession() {
   return useContext(SessionContext)
 }