-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resolved the issue where headerShown: false was not working afte…
…r the interface rendering & added the AnchorSizableText component & fixed the issue of the Loading indicator showing twice on the market detail page. (OK-32345) (#6395)
- Loading branch information
1 parent
c299053
commit 44126d6
Showing
14 changed files
with
149 additions
and
120 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
46 changes: 46 additions & 0 deletions
46
packages/components/src/content/AnchorSizableText/index.tsx
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,46 @@ | ||
import { Anchor, SizableText } from '../../primitives'; | ||
|
||
import type { IAnchorProps, ISizableTextProps } from '../../primitives'; | ||
|
||
export interface IAnchorSizableTextProps extends ISizableTextProps { | ||
anchorRegExp?: RegExp; | ||
hrefRegExp?: RegExp; | ||
anchorProps?: IAnchorProps; | ||
} | ||
|
||
export function AnchorSizableText({ | ||
anchorRegExp = /<url(?:\s+[^>]*?)?>(.*?)<\/url>/g, | ||
hrefRegExp = /href="(.*?)"/, | ||
children, | ||
anchorProps, | ||
...props | ||
}: IAnchorSizableTextProps) { | ||
const line = children as string; | ||
const isAnchor = anchorRegExp.test(line); | ||
if (isAnchor) { | ||
const parts = line.split(anchorRegExp); | ||
const hrefMatch = line.match(/href="(.*?)"/); | ||
return ( | ||
<SizableText {...props}> | ||
{parts.map((part, partIndex) => { | ||
if (partIndex === 1) { | ||
return ( | ||
<Anchor | ||
{...props} | ||
target="_blank" | ||
color="$textInfo" | ||
{...anchorProps} | ||
key={partIndex} | ||
href={hrefMatch?.[1]} | ||
> | ||
{part} | ||
</Anchor> | ||
); | ||
} | ||
return part; | ||
})} | ||
</SizableText> | ||
); | ||
} | ||
return <SizableText {...props}>{line}</SizableText>; | ||
} |
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
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
Oops, something went wrong.