Files
gitbook/src/components/DocumentView/Blocks.tsx
T
Sebastian Graz aab7d0bd7a Design pass (#8)
* first stab at bullet points
* setup theming, custom opacities, use of brand UI colors
* color key change
* delete brand
* setup initial defaults
* Add opacity parameter to primary color
* style TOC
* styling pass header, footer, hints, toc, trademark
* table pass
* style pass, typo, quote, tabs, search, theme, toc
2023-11-21 18:29:36 +01:00

41 lines
1.1 KiB
TypeScript

import { DocumentBlock } from '@gitbook/api';
import { tcls, ClassValue } from '@/lib/tailwind';
import { Block } from './Block';
import { DocumentContextProps } from './DocumentView';
export function Blocks<T extends DocumentBlock, Tag extends React.ElementType = 'div'>(
props: DocumentContextProps & {
/** Blocks to render */
nodes: T[];
/** Ancestors of the blocks */
ancestorBlocks: DocumentBlock[];
/** HTML tag to use */
tag?: Tag;
/** Style passed to the wrapper */
style?: ClassValue;
/** Style passed to all blocks */
blockStyle?: ClassValue;
},
) {
const { nodes, tag: Tag = 'div', style, blockStyle, ...contextProps } = props;
return (
<Tag className={tcls(style)}>
{nodes.map((node, index) => (
<Block
key={node.key}
block={node}
style={['max-w-3xl', 'w-full', 'mx-auto', 'leading-relaxed', blockStyle]}
{...contextProps}
/>
))}
</Tag>
);
}