1- import { FastUI , renderClassName } from 'fastui'
1+ import { CustomRender , FastUI , renderClassName } from 'fastui'
22import * as bootstrap from 'fastui-bootstrap'
33import { FC , ReactNode } from 'react'
44
@@ -8,7 +8,7 @@ export default function App() {
88 < FastUI
99 rootUrl = "/api"
1010 classNameGenerator = { bootstrap . classNameGenerator }
11- customRender = { bootstrap . customRender }
11+ customRender = { customRender }
1212 NotFound = { NotFound }
1313 Spinner = { Spinner }
1414 Transition = { Transition }
@@ -38,3 +38,31 @@ const Transition: FC<{ children: ReactNode; transitioning: boolean }> = ({ child
3838 { children }
3939 </ div >
4040)
41+
42+ const customRender : CustomRender = ( props ) => {
43+ const { type } = props
44+ if ( type === 'Custom' && props . library === undefined && props . subType === 'cowsay' ) {
45+ console . assert ( typeof props . data === 'string' , 'cowsay data must be a string' )
46+ const text = props . data as string
47+ return ( ) => < Cowsay text = { text } />
48+ } else {
49+ return bootstrap . customRender ( props )
50+ }
51+ }
52+
53+ const COWSAY = ` {above}
54+ < {text} >
55+ {below}
56+ \\ ^__^
57+ \\ (oo)\\_______
58+ (__)\\ )\\/\\
59+ ||----w |
60+ || ||`
61+
62+ const Cowsay : FC < { text : string } > = ( { text } ) => {
63+ const len = text . length
64+ const cowsay = COWSAY . replace ( '{text}' , text )
65+ . replace ( '{above}' , '_' . repeat ( len + 2 ) )
66+ . replace ( '{below}' , '-' . repeat ( len + 2 ) )
67+ return < pre > { cowsay } </ pre >
68+ }
0 commit comments