Skip to content

Commit

Permalink
initial docstrings for basic components
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle committed Apr 23, 2024
1 parent 73ecd45 commit b58b98c
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 18 deletions.
6 changes: 4 additions & 2 deletions docs/components.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
::: fastui.components
options:
show_root_heading: true
docstring_options:
ignore_init_summary: false
members: - Text - Paragraph - PageTitle - Div - Page - Heading - Markdown - Code - Json - Button - Link - LinkList - Navbar - Modal - ServerLoad - Image - Iframe - FireEvent - Error - Spinner - Toast - Custom - Table - Pagination - Display - Details - Form - FormField - ModelForm - Footer - AnyComponent - FormFieldBoolean - FormFieldFile - FormFieldInput - FormFieldSelect - FormFieldSelectSearch

<!-- merge_init_into_class: false -->
<!-- TODO: don't render attributes in TOC -->
69 changes: 66 additions & 3 deletions src/npm-fastui/src/models.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,60 +70,84 @@ export type DisplayMode =
| 'inline_code'
export type SelectOptions = SelectOption[] | SelectGroup[]

/**
* Text component that displays a string.
*/
export interface Text {
text: string
type: 'Text'
}
/**
* Paragraph component that displays a string as a paragraph.
*/
export interface Paragraph {
text: string
className?: ClassName
type: 'Paragraph'
}
/**
* This sets the title of the HTML page via the `document.title` property.
* Sets the title of the HTML page via the `document.title` property.
*/
export interface PageTitle {
text: string
type: 'PageTitle'
}
/**
* A generic container component.
*/
export interface Div {
components: FastProps[]
className?: ClassName
type: 'Div'
}
/**
* Similar to `container` in many UI frameworks, this should be a reasonable root component for most pages.
* Similar to `container` in many UI frameworks, this acts as a root component for most pages.
*/
export interface Page {
components: FastProps[]
className?: ClassName
type: 'Page'
}
/**
* Heading component.
*/
export interface Heading {
text: string
level: 1 | 2 | 3 | 4 | 5 | 6
htmlId?: string
className?: ClassName
type: 'Heading'
}
/**
* Markdown component that renders markdown text.
*/
export interface Markdown {
text: string
codeStyle?: string
className?: ClassName
type: 'Markdown'
}
/**
* Code component that renders code with syntax highlighting.
*/
export interface Code {
text: string
language?: string
codeStyle?: string
className?: ClassName
type: 'Code'
}
/**
* JSON component that renders JSON data.
*/
export interface Json {
value: JsonData
className?: ClassName
type: 'JSON'
}
/**
* Button component.
*/
export interface Button {
text: string
onClick?: AnyEvent
Expand Down Expand Up @@ -159,6 +183,9 @@ export interface AuthEvent {
url?: string
type: 'auth'
}
/**
* Link component.
*/
export interface Link {
components: FastProps[]
onClick?: PageEvent | GoToEvent | BackEvent | AuthEvent
Expand All @@ -168,12 +195,18 @@ export interface Link {
className?: ClassName
type: 'Link'
}
/**
* List of Link components.
*/
export interface LinkList {
links: Link[]
mode?: 'tabs' | 'vertical' | 'pagination'
className?: ClassName
type: 'LinkList'
}
/**
* Navbar component used for moving between pages.
*/
export interface Navbar {
title?: string
titleEvent?: PageEvent | GoToEvent | BackEvent | AuthEvent
Expand All @@ -182,12 +215,18 @@ export interface Navbar {
className?: ClassName
type: 'Navbar'
}
/**
* Footer component.
*/
export interface Footer {
links: Link[]
extraText?: string
className?: ClassName
type: 'Footer'
}
/**
* Modal component that displays a modal dialog.
*/
export interface Modal {
title: string
body: FastProps[]
Expand All @@ -209,6 +248,9 @@ export interface ServerLoad {
method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE'
type: 'ServerLoad'
}
/**
* Image container component.
*/
export interface Image {
src: string
alt?: string
Expand All @@ -228,6 +270,9 @@ export interface Image {
className?: ClassName
type: 'Image'
}
/**
* Iframe component that displays content from a URL.
*/
export interface Iframe {
src: string
title?: string
Expand All @@ -238,6 +283,9 @@ export interface Iframe {
sandbox?: string
type: 'Iframe'
}
/**
* Video component that displays a video or multiple videos.
*/
export interface Video {
sources: string[]
autoplay?: boolean
Expand All @@ -247,14 +295,20 @@ export interface Video {
poster?: string
width?: string | number
height?: string | number
type: 'Video'
className?: ClassName
type: 'Video'
}
/**
* Fire an event.
*/
export interface FireEvent {
event: AnyEvent
message?: string
type: 'FireEvent'
}
/**
* Utility component used to display an error.
*/
export interface Error {
title: string
description: string
Expand All @@ -263,11 +317,17 @@ export interface Error {
type: 'Error'
children?: ReactNode
}
/**
* Spinner component that displays a loading spinner.
*/
export interface Spinner {
text?: string
className?: ClassName
type: 'Spinner'
}
/**
* Custom component that allows for special data to be rendered.
*/
export interface Custom {
data: JsonData
subType: string
Expand Down Expand Up @@ -462,6 +522,9 @@ export interface ModelForm {
| FormFieldSelectSearch
)[]
}
/**
* Toast component that displays a toast message (small temporary message).
*/
export interface Toast {
title: string
body: FastProps[]
Expand Down
Loading

0 comments on commit b58b98c

Please sign in to comment.