forked from noya-app/noya
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request noya-app#382 from noya-app/passthrough-block
Passthrough block
- Loading branch information
Showing
21 changed files
with
338 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { ArrowForwardIcon } from '@chakra-ui/icons'; | ||
import { Link } from '@chakra-ui/react'; | ||
import { BlockDefinition } from 'noya-state'; | ||
import React from 'react'; | ||
import { parseBlock } from '../parse'; | ||
import { linkSymbol } from './symbols'; | ||
import { | ||
getBlockClassName, | ||
hasClassGroup, | ||
tailwindTextClasses, | ||
} from './tailwind'; | ||
|
||
const placeholderText = 'Read More'; | ||
|
||
const parser = 'regular'; | ||
|
||
export const LinkBlock: BlockDefinition = { | ||
symbol: linkSymbol, | ||
parser, | ||
hashtags: [ | ||
'icon-arrow-forward', | ||
'left', | ||
'center', | ||
'right', | ||
...tailwindTextClasses, | ||
'flex-1', | ||
], | ||
placeholderText, | ||
infer: ({ frame, blockText }) => 0, | ||
render: (props) => { | ||
const { content, parameters } = parseBlock(props.blockText, parser, { | ||
placeholder: placeholderText, | ||
}); | ||
|
||
const hashtags = Object.keys(parameters); | ||
const hasColor = hasClassGroup('textColor', hashtags); | ||
|
||
return ( | ||
<Link | ||
{...(props.dataSet && { | ||
key: props.dataSet.id, | ||
'data-noya-id': props.dataSet.id, | ||
'data-noya-parent-id': props.dataSet.parentId, | ||
})} | ||
fontWeight="semibold" | ||
color={hasColor ? '' : 'dodgerblue'} | ||
className={getBlockClassName(hashtags)} | ||
> | ||
{content} | ||
{parameters['icon-arrow-forward'] && ( | ||
<> | ||
{' '} | ||
<ArrowForwardIcon | ||
style={{ | ||
verticalAlign: 'text-bottom', | ||
}} | ||
/> | ||
</> | ||
)} | ||
</Link> | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.