-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI Assistant: Add disclaimer to image generation input (#40397)
* refactor from first proposal * change guideline links to jetpack redirect * add disclaimer to image modals * add AiModalFooter component * use AiModalFooter component on images modal * use AiModalFooter component on logo generator modal * changelog * remove arrow icon and use character instead
- Loading branch information
Showing
16 changed files
with
188 additions
and
77 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/js-packages/ai-client/changelog/update-jetpack-ai-image-generator-input-disclaimer
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 @@ | ||
Significance: patch | ||
Type: changed | ||
|
||
AI Assistant: Add disclaimer to image generation modals |
71 changes: 71 additions & 0 deletions
71
projects/js-packages/ai-client/src/components/ai-modal-footer/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,71 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
import { useCallback } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { Icon, info } from '@wordpress/icons'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
/** | ||
* Types | ||
*/ | ||
import type React from 'react'; | ||
|
||
type AiModalFooterProps = { | ||
onGuidelinesClick?: () => void; | ||
onFeedbackClick?: () => void; | ||
}; | ||
|
||
/** | ||
* AiModalFooter component. | ||
* | ||
* @param {AiModalFooterProps} props - component props. | ||
* @return {React.ReactElement} - rendered component. | ||
*/ | ||
export default function AiModalFooter( { | ||
onGuidelinesClick, | ||
onFeedbackClick, | ||
}: AiModalFooterProps ): React.ReactElement { | ||
const handleGuidelinesClick = useCallback( () => { | ||
onGuidelinesClick?.(); | ||
}, [ onGuidelinesClick ] ); | ||
|
||
const handleFeedbackClick = useCallback( () => { | ||
onFeedbackClick?.(); | ||
}, [ onFeedbackClick ] ); | ||
|
||
return ( | ||
<> | ||
<div className="ai-image-modal__footer-disclaimer"> | ||
<Icon icon={ info } /> | ||
<span> | ||
{ __( | ||
'Generated images could be inaccurate, biased or include text.', | ||
'jetpack-ai-client' | ||
) } | ||
</span> | ||
<Button | ||
variant="link" | ||
className="ai-image-modal__guidelines-button" | ||
href="https://jetpack.com/redirect/?source=ai-guidelines" | ||
target="_blank" | ||
onClick={ handleGuidelinesClick } | ||
> | ||
<span>{ __( 'Guidelines', 'jetpack-ai-client' ) } ↗</span> | ||
</Button> | ||
</div> | ||
<Button | ||
variant="link" | ||
className="ai-image-modal__feedback-button" | ||
href="https://jetpack.com/redirect/?source=jetpack-ai-feedback" | ||
target="_blank" | ||
onClick={ handleFeedbackClick } | ||
> | ||
<span>{ __( 'Give feedback', 'jetpack-ai-client' ) } ↗</span> | ||
</Button> | ||
</> | ||
); | ||
} |
32 changes: 32 additions & 0 deletions
32
projects/js-packages/ai-client/src/components/ai-modal-footer/stories/index.stories.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,32 @@ | ||
/* | ||
* External Dependencies | ||
*/ | ||
import { action } from '@storybook/addon-actions'; | ||
import React from 'react'; | ||
/* | ||
* Internal Dependencies | ||
*/ | ||
import AiModalFooter from '../index.js'; | ||
|
||
export default { | ||
title: 'JS Packages/AI Client/AiModalFooter', | ||
component: AiModalFooter, | ||
decorators: [ | ||
Story => ( | ||
<div style={ { display: 'flex', justifyContent: 'space-between' } }> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
}; | ||
|
||
const DefaultTemplate = () => { | ||
return ( | ||
<AiModalFooter | ||
onGuidelinesClick={ action( 'onGuidelinesClick' ) } | ||
onFeedbackClick={ action( 'onFeedbackClick' ) } | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = DefaultTemplate.bind( {} ); |
15 changes: 15 additions & 0 deletions
15
projects/js-packages/ai-client/src/components/ai-modal-footer/style.scss
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,15 @@ | ||
.ai-image-modal__footer-disclaimer { | ||
display: flex; | ||
align-items: center; | ||
gap: 4px; | ||
color: var( --jp-gray-50 ); | ||
fill: var( --jp-gray-50 ); | ||
|
||
.components-button.is-link { | ||
color: var( --jp-gray-50 ); | ||
} | ||
} | ||
|
||
.ai-image-modal__feedback-button.components-button.is-link { | ||
text-decoration: none; | ||
} |
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
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/update-jetpack-ai-image-generator-input-disclaimer
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 @@ | ||
Significance: patch | ||
Type: other | ||
|
||
AI Assistant: Add disclaimer to image generation modals |
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.