-
Notifications
You must be signed in to change notification settings - Fork 62
Guru npm-grunt.yml #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Guru npm-grunt.yml #791
Conversation
const renderDecorator: RenderDecoratorFunction = (props) => { if (props.value === 'strong') { return <strong>{props.children}</strong> } if (props.value === 'em') { return <em>{props.children}</em> } if (props.value === 'underline') { return <u>{props.children}</u> } return <>{props.children}</> } // Annotations const renderAnnotation: RenderAnnotationFunction = (props) => { if (props.schemaType.name === 'link') { return <span style={{textDecoration: 'underline'}}>{props.children}</span> } return <>{props.children}</> } // Block objects const renderBlock: RenderBlockFunction = (props) => { if (props.schemaType.name === 'image' && isImage(props.value)) { return ( <div style={{ border: '1px dotted grey', padding: '0.25em', marginBlockEnd: '0.25em', }} > IMG: {props.value.src} </div> ) } return <div style={{marginBlockEnd: '0.25em'}}>{props.children}</div> } // Check the shape of an image and confirm it has a src. function isImage( props: PortableTextBlock, ): props is PortableTextBlock & {src: string} { return 'src' in props } // Styles const renderStyle: RenderStyleFunction = (props) => { if (props.schemaType.value === 'h1') { return <h1>{props.children}</h1> } if (props.schemaType.value === 'h2') { return <h2>{props.children}</h2> } if (props.schemaType.value === 'h3') { return <h3>{props.children}</h3> } if (props.schemaType.value === 'blockquote') { return <blockquote>{props.children}</blockquote> } return <>{props.children}</> } // Inline objects const renderChild: RenderChildFunction = (props) => { if (props.schemaType.name === 'stock-ticker' && isStockTicker(props.value)) { return ( <span style={{ border: '1px dotted grey', padding: '0.15em', }} > {props.value.symbol} </span> ) } return <>{props.children}</> } // Check the shape of the object by confirming it has a symbol. function isStockTicker( props: PortableTextChild, ): props is PortableTextChild & {symbol: string} { return 'symbol' in props }
@assbay18 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
const renderDecorator: RenderDecoratorFunction = (props) => {
if (props.value === 'strong') {
return {props.children}
}
if (props.value === 'em') {
return {props.children}
}
if (props.value === 'underline') {
return {props.children}
}
return <>{props.children}</>
}
// Annotations
const renderAnnotation: RenderAnnotationFunction = (props) => {
if (props.schemaType.name === 'link') {
return <span style={{textDecoration: 'underline'}}>{props.children}
}
return <>{props.children}</>
}
// Block objects
const renderBlock: RenderBlockFunction = (props) => {
if (props.schemaType.name === 'image' && isImage(props.value)) {
return (
<div
style={{
border: '1px dotted grey',
padding: '0.25em',
marginBlockEnd: '0.25em',
}}
>
IMG: {props.value.src}
)
}
return <div style={{marginBlockEnd: '0.25em'}}>{props.children}
}
// Check the shape of an image and confirm it has a src. function isImage(
props: PortableTextBlock,
): props is PortableTextBlock & {src: string} {
return 'src' in props
}
// Styles
const renderStyle: RenderStyleFunction = (props) => {
if (props.schemaType.value === 'h1') {
return
{props.children}
}
if (props.schemaType.value === 'h2') {
return
{props.children}
}
if (props.schemaType.value === 'h3') {
return
{props.children}
}
if (props.schemaType.value === 'blockquote') {
return
}
return <>{props.children}</>
}
// Inline objects
const renderChild: RenderChildFunction = (props) => {
if (props.schemaType.name === 'stock-ticker' && isStockTicker(props.value)) {
return (
<span
style={{
border: '1px dotted grey',
padding: '0.15em',
}}
>
{props.value.symbol}
)
}
return <>{props.children}</>
}
// Check the shape of the object by confirming it has a symbol. function isStockTicker(
props: PortableTextChild,
): props is PortableTextChild & {symbol: string} {
return 'symbol' in props
}