-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hide country selector only when semrush limited reached fix order
- Loading branch information
Showing
11 changed files
with
262 additions
and
64 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
31 changes: 31 additions & 0 deletions
31
...related-keyphrase-suggestions/src/elements/UserMessage/components/MaxRelatedKeyphrases.js
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,31 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { __, sprintf } from "@wordpress/i18n"; | ||
import { Alert } from "@yoast/ui-library"; | ||
|
||
/** | ||
* Display the message when reaching max related keyphrases. | ||
* | ||
* @param {string} [className=""] The class name for the alert. | ||
* | ||
* @returns {React.Component} The alert for max related keyphrases. | ||
*/ | ||
export const MaxRelatedKeyphrases = ( { className = "" } ) => { | ||
return ( | ||
<Alert variant="warning" className={ className }> | ||
{ sprintf( | ||
/* translators: %s: Expands to "Yoast SEO". */ | ||
__( | ||
// eslint-disable-next-line max-len | ||
"You've reached the maximum amount of 4 related keyphrases. You can change or remove related keyphrases in the %s metabox or sidebar.", | ||
"wordpress-seo", | ||
), | ||
"Yoast SEO", | ||
) } | ||
</Alert> | ||
); | ||
}; | ||
|
||
MaxRelatedKeyphrases.propTypes = { | ||
className: PropTypes.string, | ||
}; |
23 changes: 23 additions & 0 deletions
23
packages/related-keyphrase-suggestions/src/elements/UserMessage/components/RequestEmpty.js
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,23 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { __ } from "@wordpress/i18n"; | ||
import { Alert } from "@yoast/ui-library"; | ||
|
||
/** | ||
* Display the message for a empty request. | ||
* | ||
* @param {string} [className=""] The class name for the alert. | ||
* | ||
* @returns {React.Component} The message for a empty request. | ||
*/ | ||
export const RequestEmpty = ( { className = "" } ) => { | ||
return ( | ||
<Alert variant="info" className={ className }> | ||
{ __( "Sorry, there's no data available for that keyphrase/country combination.", "wordpress-seo" ) } | ||
</Alert> | ||
); | ||
}; | ||
|
||
RequestEmpty.propTypes = { | ||
className: PropTypes.string, | ||
}; |
23 changes: 23 additions & 0 deletions
23
packages/related-keyphrase-suggestions/src/elements/UserMessage/components/RequestFailed.js
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,23 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { __ } from "@wordpress/i18n"; | ||
import { Alert } from "@yoast/ui-library"; | ||
|
||
/** | ||
* Display the message for a failed request. | ||
* | ||
* @param {string} [className=""] The class name for the alert. | ||
* | ||
* @returns {React.Component} The message for a failed request. | ||
*/ | ||
export const RequestFailed = ( { className = "" } ) => { | ||
return ( | ||
<Alert variant="error" className={ className }> | ||
{ __( "We've encountered a problem trying to get related keyphrases. Please try again later.", "wordpress-seo" ) } | ||
</Alert> | ||
); | ||
}; | ||
|
||
RequestFailed.propTypes = { | ||
className: PropTypes.string, | ||
}; |
50 changes: 50 additions & 0 deletions
50
.../related-keyphrase-suggestions/src/elements/UserMessage/components/RequestLimitReached.js
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,50 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { __, sprintf } from "@wordpress/i18n"; | ||
import { Alert, Button } from "@yoast/ui-library"; | ||
import { ArrowNarrowRightIcon } from "@heroicons/react/outline"; | ||
|
||
/** | ||
* Display the message for a request that has reached the limit. | ||
* | ||
* @param {String} [upsellLink] The upsell link. | ||
* @param {string} [className=""] The class name for the alert. | ||
* | ||
* @returns {React.Component} The message for limit reached. | ||
*/ | ||
export const RequestLimitReached = ( { upsellLink, className = "" } ) => { | ||
return ( | ||
<Alert variant="warning" className={ className }> | ||
<div className="yst-flex yst-flex-col yst-items-start"> | ||
{ sprintf( | ||
/* translators: %s : Expands to "Semrush". */ | ||
__( "You've reached your request limit for today. Check back tomorrow or upgrade your plan over at %s.", "wordpress-seo" ), | ||
"Semrush", | ||
) } | ||
|
||
{ upsellLink && <Button | ||
variant="upsell" | ||
className="yst-mt-3 yst-gap-1.5" | ||
as="a" | ||
href={ upsellLink } | ||
target="_blank" | ||
> | ||
{ | ||
sprintf( | ||
/* translators: %s : Expands to "Semrush". */ | ||
__( "Upgrade your %s plan", "wordpress-seo" ), | ||
"Semrush", | ||
) | ||
} | ||
<ArrowNarrowRightIcon className="yst-w-4 yst-h-4 yst-text-amber-900" /> | ||
|
||
</Button> } | ||
</div> | ||
</Alert> | ||
); | ||
}; | ||
|
||
RequestLimitReached.propTypes = { | ||
upsellLink: PropTypes.string, | ||
className: PropTypes.string, | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/related-keyphrase-suggestions/src/elements/UserMessage/components/index.js
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,4 @@ | ||
export { MaxRelatedKeyphrases } from "./MaxRelatedKeyphrases"; | ||
export { RequestFailed } from "./RequestFailed"; | ||
export { RequestEmpty } from "./RequestEmpty"; | ||
export { RequestLimitReached } from "./RequestLimitReached"; |
1 change: 1 addition & 0 deletions
1
packages/related-keyphrase-suggestions/src/elements/UserMessage/docs/component.md
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 @@ | ||
The alert to display to the user related to the related keyphrases suggestions request or action. |
1 change: 1 addition & 0 deletions
1
packages/related-keyphrase-suggestions/src/elements/UserMessage/docs/index.js
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 @@ | ||
export { default as component } from "./component.md"; |
33 changes: 33 additions & 0 deletions
33
packages/related-keyphrase-suggestions/src/elements/UserMessage/index.js
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,33 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { RequestFailed, RequestLimitReached, RequestEmpty, MaxRelatedKeyphrases } from "./components"; | ||
|
||
/** | ||
* Displays the user message following a request or action. | ||
* | ||
* @param {string} [variant] The type of message to display. | ||
* @param {string} [upsellLink=""] The link to the upsell page. | ||
* @param {string} [className=""] The class name for the button. | ||
* | ||
* @returns {React.Component} The user message. | ||
*/ | ||
export const UserMessage = ( { variant, upsellLink = "", className = "" } ) => { | ||
switch ( variant ) { | ||
case "requestLimitReached": | ||
return <RequestLimitReached upsellLink={ upsellLink } className={ className } />; | ||
case "requestFailed": | ||
return <RequestFailed className={ className } />; | ||
case "requestEmpty": | ||
return <RequestEmpty className={ className } />; | ||
case "maxRelatedKeyphrases": | ||
return <MaxRelatedKeyphrases className={ className } />; | ||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
UserMessage.propTypes = { | ||
variant: PropTypes.oneOf( [ "requestLimitReached", "requestFailed", "requestEmpty", "maxRelatedKeyphrases" ] ), | ||
upsellLink: PropTypes.string, | ||
className: PropTypes.string, | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/related-keyphrase-suggestions/src/elements/UserMessage/stories.js
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,24 @@ | ||
import React from "react"; | ||
import { UserMessage } from "."; | ||
import { component } from "./docs"; | ||
|
||
export const Factory = { | ||
parameters: { | ||
controls: { disable: false }, | ||
}, | ||
render: ( args ) => <UserMessage { ...args } />, | ||
}; | ||
|
||
export default { | ||
title: "2) Elements/UserMessage", | ||
component: UserMessage, | ||
args: { | ||
variant: "requestLimitReached", | ||
upsellLink: "https://www.semrush.com/analytics/keywordoverview/?q=example&db=us", | ||
}, | ||
parameters: { | ||
docs: { | ||
description: { component }, | ||
}, | ||
}, | ||
}; |
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