0.0.1 • Published 6 months ago

@capitol.ai/ui-components v0.0.1

Weekly downloads
-
License
Proprietary
Repository
-
Last release
6 months ago

Capitol AI - Summary

Local setup

First, install the package:

npm install @capitol.ai/summary

Then, import components you need and default styles (optional):

import { Summary } from '@capitol.ai/summary';
import '@capitol.ai/summary/dist/summary.css';

Components

Summary

The main component that displays AI-generated summaries in different layouts.

PropTypeDefaultDescription
summaryIdstring""Unique identifier for the summary
promptstring"prompt"The prompt text that generated the summary
titlestring"AI summary"Title of the summary
classNamestring""Additional CSS classes
summarystring""The summary content
layout"quoted" | "clean""quoted"Layout type for the summary. "quoted" shows prompt in quotes with decorative elements, "clean" provides a minimal design
format"basic" | "advanced""basic"Format type for the summary
outputSummaryOutputundefinedAdditional output data for advanced format
useMarkdownbooleanfalseWhether to render the summary content as markdown. When true, the content will be rendered using ReactMarkdown with proper styling

Prompt

A component for user input with customizable styling.

PropTypeDefaultDescription
placeholderTextstring"Enter prompt"Placeholder text for the input
minHeightnumberundefinedMinimum height of the input area
accentColorstringundefinedAccent color for the submit button
onSubmit(prompt: string) => void() => {}Callback when prompt is submitted
onChange(text: string) => void() => {}Callback when prompt text changes
disabledbooleanfalseWhether the input is disabled

PromptSuggestions

Displays a list of prompt suggestions that users can click on.

PropTypeDefaultDescription
promptsstring[][]Array of prompt suggestions
onClickHandler(prompt: string) => void() => {}Callback when a suggestion is clicked
titlestring"Suggestions"Title of the suggestions section

PromptWithOptions

Combines the Prompt component with suggestion options.

PropTypeDefaultDescription
placeholderstring"Ask a question"Placeholder text for the input
promptsstring[][]Array of prompt suggestions
onSubmit(prompt: string) => voidundefinedCallback when prompt is submitted
onChange(text: string) => voidundefinedCallback when prompt text changes

Sources

Displays a list of sources with optional masonry layout and pagination.

PropTypeDefaultDescription
sourcesSource[][]Array of source objects
isMasonryLayoutbooleanfalseWhether to use masonry layout
itemsPerPagenumber4Number of items to display per page

Pagination

A reusable pagination component for navigating through pages of content. Mainly used as pagination for Sources

PropTypeDefaultDescription
currentPagenumber1Current page number
totalPagesnumber1Total number of pages
onPageChange(page: number) => void() => {}Callback when page changes
maxVisiblePagesnumber5Maximum number of visible page buttons

Navigation

Displays a navigation menu with active state tracking.

PropTypeDefaultDescription
titlestring"Navigation"Title of the navigation section
navListNavItem[][]Array of navigation items
activeItemstring""Currently active navigation item

GenerationLog

Displays a list of generation steps with loading animations.

PropTypeDefaultDescription
titlestring"Generating..."Title of the generation log
logsstring[][]Array of log messages

Types

SummaryOutput

PropertyTypeDescription
headerstringHeader text for the summary
bodystringMain body content of the summary
imagestringOptional image URL for the summary

Source

PropertyTypeDescription
urlstringURL of the source
titlestringTitle of the source
imagestringImage URL for the source

NavItem

PropertyTypeDescription
refstringReference ID for the navigation item
namestringDisplay name of the navigation item

Example Usage

import { Summary, PromptWithOptions, Sources, Navigation, GenerationLog } from '@capitol.ai/summary';
import '@capitol.ai/summary/dist/summary.css';

const MyApp = () => {
  return (
    <div>
      <PromptWithOptions
        placeholder="Ask a question"
        prompts={["What is AI?", "How does it work?"]}
        onSubmit={(prompt) => console.log(prompt)}
      />
      <GenerationLog
        title="Generating Summary"
        logs={["Analyzing sources", "Generating content"]}
      />
      <Summary
        title="AI Summary"
        prompt="What is artificial intelligence?"
        summary="Artificial intelligence is..."
        layout="metric-media"
      />
      <Sources
        sources={[
          {
            url: "https://example.com",
            title: "Example Source",
            image: "https://example.com/image.jpg"
          }
        ]}
      />
      <Navigation
        title="Table of Contents"
        navList={[
          { ref: "section1", name: "Introduction" },
          { ref: "section2", name: "Main Content" }
        ]}
        activeItem="section1"
      />
    </div>
  );
}

Building new package

It's always a better idea to test before publish (e.g. using App.jsx).

Once you absolutely happy with what you've done:

npm run build
npm version patch
npm publish