From e5c8f9d7c625763bd2e296f8707fd58d8eaeb414 Mon Sep 17 00:00:00 2001 From: Antoine Clausse Date: Wed, 18 Dec 2024 11:32:07 +0100 Subject: [PATCH] Update `SurveyNotification` style for DS Nav (#22585) * Hide the "DS nav" survey for users on the default variant * Create and use `SurveyWidgetDsNav` * Add link to SurveyWidgetDsNav button * Revert SurveyNotification changes in the DS Nav mobile view * Hide DS nav survey via JS rather than CSS * Remove survey card in DS nav project dashboard mobile view in the short term * Change sr-only to visually-hidden * Fix typo --------- Co-authored-by: Tim Down <158919+timdown@users.noreply.github.com> GitOrigin-RevId: 6ff91637bcc8ad29c383627c7218f644a7b19d75 --- .../components/project-list-ds-nav.tsx | 3 +- .../components/sidebar/sidebar-ds-nav.tsx | 4 +- .../components/survey-widget-ds-nav.tsx | 54 +++++++++++++++++++ .../project-list/components/survey-widget.tsx | 14 ++--- .../pages/project-list-ds-nav.scss | 15 +++++- 5 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 services/web/frontend/js/features/project-list/components/survey-widget-ds-nav.tsx diff --git a/services/web/frontend/js/features/project-list/components/project-list-ds-nav.tsx b/services/web/frontend/js/features/project-list/components/project-list-ds-nav.tsx index 9787a7a371..e2a9f87fd7 100644 --- a/services/web/frontend/js/features/project-list/components/project-list-ds-nav.tsx +++ b/services/web/frontend/js/features/project-list/components/project-list-ds-nav.tsx @@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next' import CurrentPlanWidget from './current-plan-widget/current-plan-widget' import NewProjectButton from './new-project-button' import ProjectListTable from './table/project-list-table' -import SurveyWidget from './survey-widget' import UserNotifications from './notifications/user-notifications' import SearchForm from './search-form' import ProjectsDropdown from './dropdown/projects-dropdown' @@ -96,7 +95,7 @@ export function ProjectListDsNav() {
- + {/* Omit the survey card in mobile view for now */}
- +
{helpItem && ( diff --git a/services/web/frontend/js/features/project-list/components/survey-widget-ds-nav.tsx b/services/web/frontend/js/features/project-list/components/survey-widget-ds-nav.tsx new file mode 100644 index 0000000000..cac5e10bc8 --- /dev/null +++ b/services/web/frontend/js/features/project-list/components/survey-widget-ds-nav.tsx @@ -0,0 +1,54 @@ +import usePersistedState from '../../../shared/hooks/use-persisted-state' +import getMeta from '../../../utils/meta' +import { useCallback } from 'react' +import classnames from 'classnames' +import OLButton from '@/features/ui/components/ol/ol-button' +import { useTranslation } from 'react-i18next' +import { X } from '@phosphor-icons/react' + +export function SurveyWidgetDsNav() { + const { t } = useTranslation() + const survey = getMeta('ol-survey') + const [dismissedSurvey, setDismissedSurvey] = usePersistedState( + `dismissed-${survey?.name}`, + false + ) + + const dismissSurvey = useCallback(() => { + setDismissedSurvey(true) + }, [setDismissedSurvey]) + + if (!survey?.name || dismissedSurvey) { + return null + } + + return ( +
+
+
+
+

{survey.preText}

+

{survey.linkText}

+ + {t('take_survey')} + +
+ dismissSurvey()} + > + dismissSurvey()} /> + {t('close')} + +
+
+
+ ) +} diff --git a/services/web/frontend/js/features/project-list/components/survey-widget.tsx b/services/web/frontend/js/features/project-list/components/survey-widget.tsx index c7fa529133..a5604d6b01 100644 --- a/services/web/frontend/js/features/project-list/components/survey-widget.tsx +++ b/services/web/frontend/js/features/project-list/components/survey-widget.tsx @@ -3,11 +3,7 @@ import getMeta from '../../../utils/meta' import { useCallback } from 'react' import Close from '@/shared/components/close' -export default function SurveyWidget({ - variant = 'dark', -}: { - variant?: 'light' | 'dark' -}) { +export default function SurveyWidget() { const survey = getMeta('ol-survey') const [dismissedSurvey, setDismissedSurvey] = usePersistedState( `dismissed-${survey?.name}`, @@ -22,6 +18,12 @@ export default function SurveyWidget({ return null } + // Short-term hard-coded special case: hide the "DS nav" survey for users on + // the default variant + if (survey?.name === 'ds-nav') { + return null + } + return (
@@ -38,7 +40,7 @@ export default function SurveyWidget({
- dismissSurvey()} /> + dismissSurvey()} />
diff --git a/services/web/frontend/stylesheets/bootstrap-5/pages/project-list-ds-nav.scss b/services/web/frontend/stylesheets/bootstrap-5/pages/project-list-ds-nav.scss index 421ef6394a..c9402e8bbe 100644 --- a/services/web/frontend/stylesheets/bootstrap-5/pages/project-list-ds-nav.scss +++ b/services/web/frontend/stylesheets/bootstrap-5/pages/project-list-ds-nav.scss @@ -138,10 +138,21 @@ background-color: var(--bg-light-secondary); color: var(--content-secondary); box-shadow: none; + border-radius: var(--border-radius-large); + position: relative; - button.close { - color: var(--content-secondary) !important; + .user-notification-close { + border: none; padding: 0; + background: none; + position: absolute; + top: var(--spacing-07); + right: var(--spacing-07); + color: inherit; + } + + p { + margin-bottom: var(--spacing-03); } }