-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
[ui] Add a chip to indicate pro features #3358
Merged
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ae1248e
fix: Remove error states
bharatkashyap ffd2da4
fix: Add paid feature badge
bharatkashyap a40fef0
fix: Missed reversing test changes
bharatkashyap 1fe91e9
fix: Unnecessary
bharatkashyap 54d1ec7
Merge branch 'master' into feat/pro-badge
bharatkashyap 534f3e9
fix: Links and copy
bharatkashyap 4e7b91e
Merge branch 'feat/pro-badge' of github.com:bharatkashyap/mui-toolpad…
bharatkashyap 0080614
fix: Olivier review 1
bharatkashyap 7d55f78
Merge branch 'master' into feat/pro-badge
bharatkashyap 10f0ed5
Merge branch 'master' into feat/pro-badge
bharatkashyap 5310c84
fix: Use chip instead of badge
bharatkashyap 39b6c89
Merge branch 'feat/pro-badge' of github.com:bharatkashyap/mui-toolpad…
bharatkashyap a8238e4
Merge branch 'master' into feat/pro-badge
bharatkashyap b29a321
fix: Use a `<UpgradeNotification />` which scales better
bharatkashyap 4a82701
Merge branch 'master' into feat/pro-badge
bharatkashyap 354eda2
fix: Jan review
bharatkashyap 9840986
Merge branch 'master' into feat/pro-badge
bharatkashyap 4334145
fix reusability
Janpot 6f572fa
configurable url
Janpot 4588f46
fix: Better reusability patterns
bharatkashyap 216aa53
fix: This should be abstracted
bharatkashyap 7b1e08e
fix: Prefer `size` over `sx` for perf and readability
bharatkashyap 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 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
66 changes: 0 additions & 66 deletions
66
packages/toolpad-studio/src/toolpad/AppEditor/UpgradeAlert.tsx
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
packages/toolpad-studio/src/toolpad/AppEditor/UpgradeNotification.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,80 @@ | ||
import * as React from 'react'; | ||
import Alert, { AlertColor } from '@mui/material/Alert'; | ||
import Button from '@mui/material/Button'; | ||
import Chip from '@mui/material/Chip'; | ||
import Tooltip from '@mui/material/Tooltip'; | ||
import { SxProps, Theme } from '@mui/system'; | ||
import OpenInNewIcon from '@mui/icons-material/OpenInNew'; | ||
import { UPGRADE_URL } from '../../constants'; | ||
|
||
export function UpgradeNotification({ | ||
type, | ||
feature, | ||
warning, | ||
variant, | ||
action, | ||
sx, | ||
}: { | ||
type?: AlertColor; | ||
feature?: string; | ||
warning?: string; | ||
variant?: 'alert' | 'chip'; | ||
action?: boolean; | ||
sx?: SxProps<Theme>; | ||
}) { | ||
let message = `This feature requires a paid plan.`; | ||
|
||
if (warning) { | ||
message = warning; | ||
} | ||
if (feature) { | ||
message = `${feature} requires a paid plan.`; | ||
} | ||
|
||
if (variant === 'alert') { | ||
return ( | ||
<Alert | ||
severity={type ?? 'info'} | ||
sx={{ '.MuiAlert-action': { pt: 0 }, ...sx }} | ||
action={ | ||
action ? ( | ||
<Button | ||
variant="text" | ||
sx={{ fontSize: 'inherit' }} | ||
href={UPGRADE_URL} | ||
target="_blank" | ||
rel="noopener" | ||
endIcon={<OpenInNewIcon fontSize="small" />} | ||
> | ||
Upgrade | ||
</Button> | ||
) : null | ||
} | ||
> | ||
{message} | ||
</Alert> | ||
); | ||
} | ||
if (variant === 'chip') { | ||
return ( | ||
<Tooltip title={`${message} Click to learn more.`}> | ||
<Chip | ||
variant="outlined" | ||
color="primary" | ||
component="a" | ||
href={UPGRADE_URL} | ||
target="_blank" | ||
rel="noopener" | ||
clickable | ||
sx={{ | ||
height: '1.5rem', | ||
fontSize: 'inherit', | ||
verticalAlign: 'inherit', | ||
mx: '0.2rem', | ||
}} | ||
label="Pro" | ||
/> | ||
</Tooltip> | ||
); | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just export two components, an alert and a chip