Repository navigation
feat(sdk): info popover for plan features #2055
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5e3f719
feat(sdk): feature info popover on plans table
Shreyag02 1f44a6e
fix(sdk): harden plans feature info popover
Shreyag02 bdb1268
Merge branch 'main' into feat/plans-feature-info
Shreyag02 c6076cd
refactor(sdk): simplify plans feature info per review
Shreyag02 b496565
fix(sdk): name feature info popover and require a host in info links
Shreyag02 0eceabc
chore(admin): align @raystack/proton pin with the sdk
Shreyag02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,62 @@ | ||
| 'use client'; | ||
|
|
||
| import { IconButton, Link, Popover } from '@raystack/apsara'; | ||
| import { InfoCircledIcon } from '@radix-ui/react-icons'; | ||
| import styles from './feature-table.module.css'; | ||
|
|
||
| /* | ||
| * Matches [label](url) for http, https and mailto urls only. | ||
| * - Label needs a non-space character, so [ ](url) stays text. | ||
| * - Label can't hold brackets, so [[a](url) links only "a". | ||
| * - http(s) needs // and a host, so https:x and https://#a stay text. | ||
| * - Url may hold balanced parentheses one level deep, e.g. .../Foo_(bar). | ||
| */ | ||
| const LINK_PATTERN = | ||
| /\[(\s*[^[\]\s][^[\]]*)\]\(((?:https?:\/\/(?=[^\s()/?#])|mailto:)(?:[^()\s]|\([^()\s]*\))+)\)/; | ||
|
|
||
| interface FeatureInfoProps { | ||
| title: string; | ||
| info: string; | ||
| } | ||
|
|
||
| export function FeatureInfo({ title, info }: FeatureInfoProps) { | ||
| return ( | ||
| <Popover> | ||
| <Popover.Trigger | ||
| openOnHover | ||
| render={ | ||
| <IconButton | ||
| size={2} | ||
| aria-label={`About ${title}`} | ||
| className={styles.infoTrigger} | ||
| data-test-id="frontier-sdk-plans-feature-info-btn" | ||
| /> | ||
| } | ||
| > | ||
| <InfoCircledIcon /> | ||
| </Popover.Trigger> | ||
| <Popover.Content | ||
| side="top" | ||
| render={<div aria-label={`About ${title}`} />} | ||
| > | ||
| {/* split() returns [text, label, url, text, label, url, ..., text] */} | ||
| {info.split(LINK_PATTERN).map((part, i, parts) => { | ||
| if (i % 3 === 0) return part; | ||
| if (i % 3 === 2) return null; | ||
| const url = parts[i + 1]; | ||
| return ( | ||
| <Link | ||
| key={i} | ||
| href={url} | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| external={url.startsWith('http')} | ||
| underline | ||
| data-test-id="frontier-sdk-plans-feature-info-link" | ||
| > | ||
| {part} | ||
| </Link> | ||
| ); | ||
| })} | ||
| </Popover.Content> | ||
| </Popover> | ||
| ); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.