Skip to content

Commit

Permalink
progress: simplify types and blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
getnashty committed Dec 3, 2024
1 parent 5a3fcf3 commit 30e5254
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { BaseBlock, BlockType } from '../types';
import { BaseBlock, BlockType } from '..';
import { match } from 'ts-pattern';

// Chart series configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { BaseBlock, BlockType } from '../types';
import { BaseBlock, BlockType } from '..';

// Image block types
export interface ImageBlock extends BaseBlock {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
import { BaseBlock, BlockType, CitableContent, ContentBlock } from '../types';
import { BaseBlock, BlockType, CitableContent, ContentBlock } from '..';
import { Block } from '..';
import { Citation } from '../../Citation';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { BaseBlock, BlockType } from '../types';
import { BaseBlock, BlockType } from '..';

// Quote block
export interface QuoteBlock extends BaseBlock {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
import { BaseBlock, BlockType, CitableContent } from '../types';
import { BaseBlock, BlockType, CitableContent } from '..';
import { Citation } from '../../Citation';

// Table cell metadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { BaseBlock, BlockType, CitableContent } from '../types';
import { Citation } from '../../Citation';
import { match } from 'ts-pattern';
import { BaseBlock, BlockType, CitableContent } from '..';

// Text block types
export interface TextBlock extends BaseBlock {
Expand Down
44 changes: 37 additions & 7 deletions src/modules/AieraChat/Messages/MessageFactory/Block/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
import React from 'react';
import { match } from 'ts-pattern';
import { List } from './List';
import { Quote } from './Quote';
import { Table } from './Table';
import { Text } from './Text';
import { BlockType, ContentBlock } from './types';
import { Image } from './Image';
import { Chart } from './Chart';
import { ChartBlock, Chart } from './Chart';
import { ImageBlock, Image } from './Image';
import { ListBlock, List } from './List';
import { QuoteBlock, Quote } from './Quote';
import { TableBlock, Table } from './Table';
import { TextBlock, Text } from './Text';

// Citation type for referencing sources
type Citation = {
id: string;
text: string;
source: string;
url?: string;
date?: string;
author?: string;
};

// Type for content that can include citations
export type CitableContent = (string | Citation)[];

export enum BlockType {
text = 'text',
table = 'table',
list = 'list',
image = 'image',
quote = 'quote',
chart = 'chart',
}

// Base type for all content blocks
export interface BaseBlock {
id: string;
type: BlockType;
}

// Union type for all content blocks
export type ContentBlock = TextBlock | TableBlock | ListBlock | ImageBlock | QuoteBlock | ChartBlock;

export function Block(props: ContentBlock) {
return match(props)
Expand Down
37 changes: 0 additions & 37 deletions src/modules/AieraChat/Messages/MessageFactory/Block/types.ts

This file was deleted.

0 comments on commit 30e5254

Please sign in to comment.