feat: update courseware search button (#1382)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||||
import { Button, Icon } from '@openedx/paragon';
|
import { Button } from '@openedx/paragon';
|
||||||
import { Search } from '@openedx/paragon/icons';
|
import { ManageSearch } from '@openedx/paragon/icons';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import messages from './messages';
|
import messages from './messages';
|
||||||
import { useCoursewareSearchFeatureFlag, useCoursewareSearchParams } from './hooks';
|
import { useCoursewareSearchFeatureFlag, useCoursewareSearchParams } from './hooks';
|
||||||
@@ -25,16 +25,17 @@ const CoursewareSearchToggle = ({
|
|||||||
if (!enabled) { return null; }
|
if (!enabled) { return null; }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="courseware-searc-toggle">
|
<div className="courseware-search-toggle">
|
||||||
<Button
|
<Button
|
||||||
variant="tertiary"
|
variant="outline-primary"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="p-1 mt-2 mr-2 rounded-lg"
|
className="p-1 mt-2 mr-2 rounded-lg"
|
||||||
aria-label={intl.formatMessage(messages.searchOpenAction)}
|
aria-label={intl.formatMessage(messages.searchOpenAction)}
|
||||||
onClick={handleSearchOpenClick}
|
onClick={handleSearchOpenClick}
|
||||||
data-testid="courseware-search-open-button"
|
data-testid="courseware-search-open-button"
|
||||||
|
iconAfter={ManageSearch}
|
||||||
>
|
>
|
||||||
<Icon src={Search} />
|
{intl.formatMessage(messages.contentSearchButton)}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,79 +2,84 @@ import { defineMessages } from '@edx/frontend-platform/i18n';
|
|||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
searchOpenAction: {
|
searchOpenAction: {
|
||||||
id: 'learn.coursewareSerch.openAction',
|
id: 'learn.coursewareSearch.openAction',
|
||||||
defaultMessage: 'Search within this course',
|
defaultMessage: 'Search within this course',
|
||||||
description: 'Aria-label for a button that will pop up Courseware Search.',
|
description: 'Aria-label for a button that will pop up Courseware Search.',
|
||||||
},
|
},
|
||||||
|
contentSearchButton: {
|
||||||
|
id: 'learn.coursewareSearch.contentSearchButton',
|
||||||
|
defaultMessage: 'Content search',
|
||||||
|
description: 'Text for a button that will pop up Courseware Search.',
|
||||||
|
},
|
||||||
searchSubmitLabel: {
|
searchSubmitLabel: {
|
||||||
id: 'learn.coursewareSerch.submitLabel',
|
id: 'learn.coursewareSearch.submitLabel',
|
||||||
defaultMessage: 'Search',
|
defaultMessage: 'Search',
|
||||||
description: 'Button label that will submit Courseware Search.',
|
description: 'Button label that will submit Courseware Search.',
|
||||||
},
|
},
|
||||||
searchClearAction: {
|
searchClearAction: {
|
||||||
id: 'learn.coursewareSerch.clearAction',
|
id: 'learn.coursewareSearch.clearAction',
|
||||||
defaultMessage: 'Clear search',
|
defaultMessage: 'Clear search',
|
||||||
description: 'Button label that will the current Courseware Search input.',
|
description: 'Button label that will the current Courseware Search input.',
|
||||||
},
|
},
|
||||||
searchCloseAction: {
|
searchCloseAction: {
|
||||||
id: 'learn.coursewareSerch.closeAction',
|
id: 'learn.coursewareSearch.closeAction',
|
||||||
defaultMessage: 'Close the search form',
|
defaultMessage: 'Close the search form',
|
||||||
description: 'Aria-label for a button that will close Courseware Search.',
|
description: 'Aria-label for a button that will close Courseware Search.',
|
||||||
},
|
},
|
||||||
searchModuleTitle: {
|
searchModuleTitle: {
|
||||||
id: 'learn.coursewareSerch.searchModuleTitle',
|
id: 'learn.coursewareSearch.searchModuleTitle',
|
||||||
defaultMessage: 'Search this course',
|
defaultMessage: 'Search this course',
|
||||||
description: 'Title for the Courseware Search module.',
|
description: 'Title for the Courseware Search module.',
|
||||||
},
|
},
|
||||||
searchBarPlaceholderText: {
|
searchBarPlaceholderText: {
|
||||||
id: 'learn.coursewareSerch.searchBarPlaceholderText',
|
id: 'learn.coursewareSearch.searchBarPlaceholderText',
|
||||||
defaultMessage: 'Search',
|
defaultMessage: 'Search',
|
||||||
description: 'Placeholder text for the Courseware Search input control',
|
description: 'Placeholder text for the Courseware Search input control',
|
||||||
},
|
},
|
||||||
loading: {
|
loading: {
|
||||||
id: 'learn.coursewareSerch.loading',
|
id: 'learn.coursewareSearch.loading',
|
||||||
defaultMessage: 'Searching...',
|
defaultMessage: 'Searching...',
|
||||||
description: 'Screen reader text to use on the spinner while the search is performing.',
|
description: 'Screen reader text to use on the spinner while the search is performing.',
|
||||||
},
|
},
|
||||||
searchResultsNone: {
|
searchResultsNone: {
|
||||||
id: 'learn.coursewareSerch.searchResultsNone',
|
id: 'learn.coursewareSearch.searchResultsNone',
|
||||||
defaultMessage: 'No results found.',
|
defaultMessage: 'No results found.',
|
||||||
description: 'Text to show when the Courseware Search found no results matching the criteria.',
|
description: 'Text to show when the Courseware Search found no results matching the criteria.',
|
||||||
},
|
},
|
||||||
searchResultsLabel: {
|
searchResultsLabel: {
|
||||||
id: 'learn.coursewareSerch.searchResultsLabel',
|
id: 'learn.coursewareSearch.searchResultsLabel',
|
||||||
defaultMessage: 'Results for "{keyword}":',
|
defaultMessage: 'Results for "{keyword}":',
|
||||||
description: 'Text to show above the search results response list.',
|
description: 'Text to show above the search results response list.',
|
||||||
},
|
},
|
||||||
searchResultsError: {
|
searchResultsError: {
|
||||||
id: 'learn.coursewareSerch.searchResultsError',
|
id: 'learn.coursewareSearch.searchResultsError',
|
||||||
defaultMessage: 'There was an error on the search process. Please try again in a few minutes. If the problem persists, please contact the support team.',
|
defaultMessage: 'There was an error on the search process. Please try again in a few minutes. If the problem persists, please contact the support team.',
|
||||||
description: 'Error message to show to the users when there\'s an error with the endpoint or the returned payload format.',
|
description: 'Error message to show to the users when there\'s an error with the endpoint or the returned payload format.',
|
||||||
},
|
},
|
||||||
|
|
||||||
// These are translations for labeling the filters
|
// These are translations for labeling the filters
|
||||||
'filter:all': {
|
'filter:all': {
|
||||||
id: 'learn.coursewareSerch.filter:all',
|
id: 'learn.coursewareSearch.filter:all',
|
||||||
defaultMessage: 'All content',
|
defaultMessage: 'All content',
|
||||||
description: 'Label for the search results filter that shows all content (no filter).',
|
description: 'Label for the search results filter that shows all content (no filter).',
|
||||||
},
|
},
|
||||||
'filter:text': {
|
'filter:text': {
|
||||||
id: 'learn.coursewareSerch.filter:text',
|
id: 'learn.coursewareSearch.filter:text',
|
||||||
defaultMessage: 'Text',
|
defaultMessage: 'Text',
|
||||||
description: 'Label for the search results filter that shows results with text content.',
|
description: 'Label for the search results filter that shows results with text content.',
|
||||||
},
|
},
|
||||||
'filter:video': {
|
'filter:video': {
|
||||||
id: 'learn.coursewareSerch.filter:video',
|
id: 'learn.coursewareSearch.filter:video',
|
||||||
defaultMessage: 'Video',
|
defaultMessage: 'Video',
|
||||||
description: 'Label for the search results filter that shows results with video content.',
|
description: 'Label for the search results filter that shows results with video content.',
|
||||||
},
|
},
|
||||||
'filter:sequence': {
|
'filter:sequence': {
|
||||||
id: 'learn.coursewareSerch.filter:sequence',
|
id: 'learn.coursewareSearch.filter:sequence',
|
||||||
defaultMessage: 'Section',
|
defaultMessage: 'Section',
|
||||||
description: 'Label for the search results filter that shows results with section content.',
|
description: 'Label for the search results filter that shows results with section content.',
|
||||||
},
|
},
|
||||||
'filter:other': {
|
'filter:other': {
|
||||||
id: 'learn.coursewareSerch.filter:other',
|
id: 'learn.coursewareSearch.filter:other',
|
||||||
defaultMessage: 'Other',
|
defaultMessage: 'Other',
|
||||||
description: 'Label for the search results filter that shows results with other content.',
|
description: 'Label for the search results filter that shows results with other content.',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,23 +16,27 @@ const CourseTabsNavigation = ({
|
|||||||
return (
|
return (
|
||||||
<div id="courseTabsNavigation" className={classNames('course-tabs-navigation', className)}>
|
<div id="courseTabsNavigation" className={classNames('course-tabs-navigation', className)}>
|
||||||
<div className="container-xl">
|
<div className="container-xl">
|
||||||
<Tabs
|
<div className="nav-bar">
|
||||||
className="nav-underline-tabs"
|
<div className="nav-menu">
|
||||||
aria-label={intl.formatMessage(messages.courseMaterial)}
|
<Tabs
|
||||||
>
|
className="nav-underline-tabs"
|
||||||
{tabs.map(({ url, title, slug }) => (
|
aria-label={intl.formatMessage(messages.courseMaterial)}
|
||||||
<a
|
|
||||||
key={slug}
|
|
||||||
className={classNames('nav-item flex-shrink-0 nav-link', { active: slug === activeTabSlug })}
|
|
||||||
href={url}
|
|
||||||
>
|
>
|
||||||
{title}
|
{tabs.map(({ url, title, slug }) => (
|
||||||
</a>
|
<a
|
||||||
))}
|
key={slug}
|
||||||
</Tabs>
|
className={classNames('nav-item flex-shrink-0 nav-link', { active: slug === activeTabSlug })}
|
||||||
</div>
|
href={url}
|
||||||
<div className="course-tabs-navigation__search-toggle">
|
>
|
||||||
<CoursewareSearchToggle />
|
{title}
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
<div className="search-toggle">
|
||||||
|
<CoursewareSearchToggle />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{show && <CoursewareSearch />}
|
{show && <CoursewareSearch />}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,9 +16,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__search-toggle {
|
.nav-bar {
|
||||||
position: absolute;
|
display: flex;
|
||||||
top: .05rem;
|
justify-content: space-between;
|
||||||
right: 0;
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav-menu {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-toggle {
|
||||||
|
flex-grow: 0;
|
||||||
|
text-align: right;
|
||||||
|
white-space: nowrap;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user