Skip to content

Commit

Permalink
feat: export demo render (#2245)
Browse files Browse the repository at this point in the history
* feat: demo-render

* build: release 2.4.17-rc.1

* chore: version
  • Loading branch information
Jinbao1001 authored Dec 19, 2024
1 parent df146c2 commit 5bb7cc2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/client/theme-api/DumiDemoGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { DumiDemo, useRouteMeta } from 'dumi';
import React, { useCallback, useEffect, useState, type FC } from 'react';
import React, {
ReactNode,
useCallback,
useEffect,
useState,
type FC,
} from 'react';
import type { IDumiDemoProps } from './DumiDemo';
import type { IRouteMeta } from './types';

export interface IDumiDemoGridProps {
items: IDumiDemoProps[];
demoRender?: (item: IDumiDemoProps) => ReactNode;
}

export const DumiDemoGrid: FC<IDumiDemoGridProps> = (props) => {
Expand Down Expand Up @@ -55,9 +62,12 @@ export const DumiDemoGrid: FC<IDumiDemoGridProps> = (props) => {
<div style={{ display: 'flex', margin: -8 }} data-dumi-demo-grid>
{cols.map((col, i) => (
<section style={{ flex: 1, padding: 8, width: 0 }} key={String(i)}>
{col.map((item) => (
<DumiDemo key={item.demo.id} {...item} />
))}
{col.map((item) => {
if (props.demoRender) {
return props.demoRender(item);
}
return <DumiDemo key={item.demo.id} {...item} />;
})}
</section>
))}
</div>
Expand Down

0 comments on commit 5bb7cc2

Please sign in to comment.