diff --git a/client/my-sites/stats/feedback/index.tsx b/client/my-sites/stats/feedback/index.tsx index a1445b0f7833d..6c7ca1b9847ec 100644 --- a/client/my-sites/stats/feedback/index.tsx +++ b/client/my-sites/stats/feedback/index.tsx @@ -1,42 +1,108 @@ import { Button } from '@wordpress/components'; +import { close } from '@wordpress/icons'; import { useTranslate } from 'i18n-calypso'; import { useState } from 'react'; import FeedbackModal from './modal'; import './style.scss'; -function StatsFeedbackCard() { +const FEEDBACK_ACTION_LEAVE_REVIEW = 'feedback-action-leave-review'; +const FEEDBACK_ACTION_SEND_FEEDBACK = 'feedback-action-send-feedback'; +const FEEDBACK_ACTION_DISMISS_FLOATING_PANEL = 'feedback-action-dismiss-floating-panel'; + +interface FeedbackProps { + clickHandler: ( action: string ) => void; +} + +interface FeedbackPanelProps { + clickHandler: ( action: string ) => void; + isOpen: boolean; +} + +function FeedbackContent( { clickHandler }: FeedbackProps ) { const translate = useTranslate(); - const [ isOpen, setIsOpen ] = useState( false ); const ctaText = translate( 'How do you rate your overall experience with Jetpack Stats?' ); const primaryButtonText = translate( 'Love it? Leave a review' ); const secondaryButtonText = translate( 'Not a fan? Help us improve' ); - const handleClickWriteReview = () => {}; + const handleLeaveReview = () => { + clickHandler( FEEDBACK_ACTION_LEAVE_REVIEW ); + }; - const handleClickSendFeedback = () => { - setIsOpen( true ); + const handleSendFeedback = () => { + clickHandler( FEEDBACK_ACTION_SEND_FEEDBACK ); }; return ( -
-
-
{ ctaText }
-
- - -
- setIsOpen( false ) } /> +
+
{ ctaText }
+
+ +
); } -export default StatsFeedbackCard; +function FeedbackPanel( { isOpen, clickHandler }: FeedbackPanelProps ) { + const translate = useTranslate(); + + const handleCloseButtonClicked = () => { + clickHandler( FEEDBACK_ACTION_DISMISS_FLOATING_PANEL ); + }; + + if ( ! isOpen ) { + return null; + } + + return ( +
+
+ ); +} + +function FeedbackCard( { clickHandler }: FeedbackProps ) { + return ( +
+ +
+ ); +} + +function StatsFeedbackController() { + const [ isOpen, setIsOpen ] = useState( false ); + const [ isFloatingPanelOpen, setIsFloatingPanelOpen ] = useState( true ); + + const handleButtonClick = ( action: string ) => { + if ( action === FEEDBACK_ACTION_SEND_FEEDBACK ) { + setIsOpen( true ); + } + if ( action === FEEDBACK_ACTION_DISMISS_FLOATING_PANEL ) { + setIsFloatingPanelOpen( false ); + } + }; + + return ( +
+ + + setIsOpen( false ) } /> +
+ ); +} + +export default StatsFeedbackController; diff --git a/client/my-sites/stats/feedback/style.scss b/client/my-sites/stats/feedback/style.scss index f2c8933f50ee2..fac49de6d06bc 100644 --- a/client/my-sites/stats/feedback/style.scss +++ b/client/my-sites/stats/feedback/style.scss @@ -1,6 +1,37 @@ @import "@automattic/components/src/styles/typography"; @import "@wordpress/base-styles/breakpoints"; +.stats-feedback-content { + font-family: $font-sf-pro-text; + font-size: $font-body-small; + font-weight: 400; + line-height: 21px; + letter-spacing: -0.24px; + color: var(--studio-gray-100); +} + +.stats-feedback-content__actions { + display: flex; + flex-direction: column; + + .components-button { + margin-bottom: 6px; + width: fit-content; + font-weight: 500; + font-size: $font-body-small; + border-radius: 4px; + } +} + +.stats-feedback-content__cta { + margin: 0 16px 16px 0; +} + +.stats-feedback-content__emoji { + font-size: larger; + margin-right: 6px; +} + .stats-feedback-card { background: var(--studio-white); border: 1px solid var(--studio-gray-5); @@ -15,47 +46,59 @@ border-right: none; } - display: flex; - flex-direction: column; + .stats-feedback-content { + display: flex; + flex-direction: column; - @media (min-width: $break-wide) { - flex-direction: row; - justify-content: space-between; - align-items: center; + @media (min-width: $break-wide) { + flex-direction: row; + justify-content: space-between; + align-items: center; + } } - font-family: $font-sf-pro-text; - font-size: $font-body-small; - font-weight: 400; - line-height: 21px; - letter-spacing: -0.24px; -} - -.stats-feedback-card__cta { - @media (max-width: $break-wide) { - margin-bottom: 12px; + .stats-feedback-content__cta { + @media (min-width: $break-wide) { + margin-right: 12px; + margin-bottom: 0; + } } -} -.stats-feedback-card__actions { - display: flex; - flex-direction: column; + .stats-feedback-content__actions { + @media (min-width: $break-wide) { + flex-direction: row; - .components-button { - margin: 6px 0; - width: fit-content; + .components-button { + margin-left: 6px; + margin-bottom: 0; + } + } } +} - @media (min-width: $break-wide) { - flex-direction: row; +.stats-feedback-panel { + position: fixed; + bottom: 24px; + right: 24px; + z-index: 10; - .components-button { - margin: 0 6px; - } - } + border: 1px solid var(--studio-gray-5); + border-radius: 8px; // stylelint-disable-line scales/radii + padding: 24px; + width: 300px; + box-sizing: border-box; + box-shadow: 0 10px 20px 0 #00000014; + + background-color: var(--studio-white); } -.stats-feedback-card__emoji { - font-size: larger; - margin-right: 6px; +.stats-feedback-panel__close-button { + position: absolute; + top: 10px; + right: 10px; + + svg { + width: 14px; + height: 14px; + } } diff --git a/client/my-sites/stats/site.jsx b/client/my-sites/stats/site.jsx index 140ef34009499..3d6d52a76b647 100644 --- a/client/my-sites/stats/site.jsx +++ b/client/my-sites/stats/site.jsx @@ -58,7 +58,7 @@ import StatsModuleSearch from './features/modules/stats-search'; import StatsModuleTopPosts from './features/modules/stats-top-posts'; import StatsModuleUTM, { StatsModuleUTMOverlay } from './features/modules/stats-utm'; import StatsModuleVideos from './features/modules/stats-videos'; -import StatsFeedbackCard from './feedback'; +import StatsFeedbackController from './feedback'; import HighlightsSection from './highlights-section'; import { shouldGateStats } from './hooks/use-should-gate-stats'; import MiniCarousel from './mini-carousel'; @@ -242,7 +242,7 @@ class StatsSite extends Component { shouldForceDefaultDateRange, } = this.props; const isNewStateEnabled = config.isEnabled( 'stats/empty-module-traffic' ); - const isFeedbackCardEnabled = config.isEnabled( 'stats/user-feedback' ); + const isUserFeedbackEnabled = config.isEnabled( 'stats/user-feedback' ); let defaultPeriod = PAST_SEVEN_DAYS; const shouldShowUpsells = isOdysseyStats && ! isAtomic; @@ -810,7 +810,7 @@ class StatsSite extends Component { ) } - { isFeedbackCardEnabled && } + { isUserFeedbackEnabled && } { this.props.upsellModalView && }