-
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.
Merge pull request #21821 from Yoast/323-fix-design-of-links-in-the-r…
…elated-keyphrase-suggestions-modal-semrush 323 fix design of links in the related keyphrase suggestions modal semrush
- Loading branch information
Showing
13 changed files
with
180 additions
and
44 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
13 changes: 13 additions & 0 deletions
13
packages/related-keyphrase-suggestions/src/components/Modal/YoastIcon.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/related-keyphrase-suggestions/src/components/Modal/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 modal component with icon, title and links. |
1 change: 1 addition & 0 deletions
1
packages/related-keyphrase-suggestions/src/components/Modal/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"; |
72 changes: 72 additions & 0 deletions
72
packages/related-keyphrase-suggestions/src/components/Modal/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,72 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { __, sprintf } from "@wordpress/i18n"; | ||
import { Link, Modal as BaseModal } from "@yoast/ui-library"; | ||
import { ExternalLinkIcon, ArrowNarrowRightIcon } from "@heroicons/react/outline"; | ||
import { YoastIcon } from "./YoastIcon"; | ||
|
||
/** | ||
* The modal component with header and footer links. | ||
* | ||
* @param {boolean} isOpen Whether the modal is open. | ||
* @param {Function} onClose The function to call when the modal is closed. | ||
* @param {string} insightsLink The links to the insights. | ||
* @param {string} learnMoreLink The link to the learn more page. | ||
* @param {JSX.node} children The content of the modal. | ||
* | ||
* @returns {JSX.Element} The modal component. | ||
*/ | ||
export const Modal = ( { isOpen, onClose, insightsLink, learnMoreLink, children } ) => { | ||
return ( | ||
<BaseModal | ||
onClose={ onClose } | ||
isOpen={ isOpen } | ||
> | ||
<BaseModal.Panel className="yst-p-0 yst-max-w-2xl"> | ||
<BaseModal.Container.Header className="yst-flex yst-gap-3 yst-p-6 yst-border-b-slate-200 yst-border-b yst-flex-row"> | ||
<YoastIcon /> | ||
<BaseModal.Title as="h3" className="yst-text-lg yst-font-medium"> | ||
{ __( "Related keyphrases", "wordpress-seo" ) } | ||
</BaseModal.Title> | ||
</BaseModal.Container.Header> | ||
<BaseModal.Container.Content | ||
className="yst-related-keyphrase-modal-content yst-m-0" | ||
> | ||
{ children } | ||
</BaseModal.Container.Content> | ||
<BaseModal.Container.Footer className="yst-p-6 yst-border-t yst-border-t-slate-200 yst-flex yst-justify-between"> | ||
<Link | ||
href={ insightsLink } | ||
className="yst-modal-footer-link" | ||
target="_blank" | ||
> | ||
{ sprintf( | ||
/* translators: %s expands to Semrush */ | ||
__( "Get more insights at %s", "wordpress-seo" ), | ||
"Semrush", | ||
) } | ||
<span className="yst-sr-only">{ __( "(Opens in a new browser tab)", "wordpress-seo" ) }</span> | ||
<ExternalLinkIcon className="yst-link-icon" /> | ||
</Link> | ||
<Link | ||
href={ learnMoreLink } | ||
className="yst-modal-footer-link yst-text-primary-500" | ||
target="_blank" | ||
> | ||
{ __( "Learn more about the metrics", "wordpress-seo" ) } | ||
<span className="yst-sr-only">{ __( "(Opens in a new browser tab)", "wordpress-seo" ) }</span> | ||
<ArrowNarrowRightIcon className="yst-link-icon" /> | ||
</Link> | ||
</BaseModal.Container.Footer> | ||
</BaseModal.Panel> | ||
</BaseModal> | ||
); | ||
}; | ||
|
||
Modal.propTypes = { | ||
isOpen: PropTypes.bool.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
insightsLink: PropTypes.string.isRequired, | ||
learnMoreLink: PropTypes.string.isRequired, | ||
children: PropTypes.node, | ||
}; |
39 changes: 39 additions & 0 deletions
39
packages/related-keyphrase-suggestions/src/components/Modal/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,39 @@ | ||
import React, { useEffect } from "react"; | ||
import { Button, useToggleState } from "@yoast/ui-library"; | ||
import { Modal } from "."; | ||
import { component } from "./docs"; | ||
import { noop } from "lodash"; | ||
|
||
export const Factory = { | ||
parameters: { | ||
controls: { disable: false }, | ||
}, | ||
args: { | ||
onClose: noop, | ||
isOpen: false, | ||
insightsLink: "https://insights.semrush.com/", | ||
learnMoreLink: "https://learnmore.semrush.com/", | ||
}, | ||
}; | ||
|
||
export default { | ||
title: "1) Components/Modal", | ||
component: Modal, | ||
parameters: { | ||
docs: { | ||
description: { component }, | ||
}, | ||
}, | ||
render: ( { isOpen } ) => { | ||
const [ open, toggleOpen, setOpen ] = useToggleState( isOpen ); | ||
|
||
useEffect( () => { | ||
setOpen( isOpen ); | ||
}, [ isOpen ] ); | ||
return ( <> | ||
<Button onClick={ toggleOpen }> | ||
Open Modal | ||
</Button> | ||
<Modal isOpen={ open } onClose={ toggleOpen }> Hello World! </Modal></> ); | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
packages/related-keyphrase-suggestions/src/components/Modal/style.css
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,17 @@ | ||
@layer components { | ||
.yst-root { | ||
.yst-modal-footer-link { | ||
@apply yst-flex yst-flex-row yst-gap-1 yst-items-center; | ||
|
||
.yst-link-icon { | ||
@apply yst-w-3 yst-h-3; | ||
} | ||
} | ||
|
||
.yst-related-keyphrase-modal-content { | ||
max-height: 60vh; | ||
min-height: 350px; | ||
@apply yst-p-6 yst-overflow-y-auto; | ||
} | ||
} | ||
} |
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