Skip to content

Commit 6fee8e5

Browse files
pns-opswerksPaul Nathaniel Sango
andauthored
Wire nav search to SEARCH_CATALOG_URL and update search input styles. (#2)
Redirect header search to /search and restyle the search field. Co-authored-by: Paul Nathaniel Sango <paulnathanielsango@192.168.1.4>
1 parent a98e35a commit 6fee8e5

2 files changed

Lines changed: 78 additions & 24 deletions

File tree

src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
IconHome,
44
IconBook,
55
IconClockHour3,
6-
IconSearch,
76
IconHelpHexagon,
87
IconBell,
98
} from '@tabler/icons-react';
@@ -17,7 +16,26 @@ const ICON_MAP = {
1716
Home: IconHome,
1817
LibraryBooks: IconBook,
1918
ClockHour3: IconClockHour3,
20-
Search: IconSearch,
19+
Search: ({ size = 18, className, ...props }) => (
20+
<svg
21+
width={size}
22+
height={size}
23+
viewBox="0 0 20 20"
24+
fill="none"
25+
xmlns="http://www.w3.org/2000/svg"
26+
className={className}
27+
aria-hidden="true"
28+
{...props}
29+
>
30+
<path
31+
d="M18.665 18.665L12.665 12.665M0.665039 7.66504C0.665039 8.58429 0.846099 9.49454 1.19788 10.3438C1.54967 11.1931 2.06528 11.9648 2.71529 12.6148C3.3653 13.2648 4.13698 13.7804 4.98626 14.1322C5.83553 14.484 6.74579 14.665 7.66504 14.665C8.58429 14.665 9.49454 14.484 10.3438 14.1322C11.1931 13.7804 11.9648 13.2648 12.6148 12.6148C13.2648 11.9648 13.7804 11.1931 14.1322 10.3438C14.484 9.49454 14.665 8.58429 14.665 7.66504C14.665 6.74579 14.484 5.83553 14.1322 4.98626C13.7804 4.13698 13.2648 3.3653 12.6148 2.71529C11.9648 2.06528 11.1931 1.54967 10.3438 1.19788C9.49454 0.846099 8.58429 0.665039 7.66504 0.665039C6.74579 0.665039 5.83553 0.846099 4.98626 1.19788C4.13698 1.54967 3.3653 2.06528 2.71529 2.71529C2.06528 3.3653 1.54967 4.13698 1.19788 4.98626C0.846099 5.83553 0.665039 6.74579 0.665039 7.66504Z"
32+
stroke="currentColor"
33+
strokeWidth="1.33"
34+
strokeLinecap="round"
35+
strokeLinejoin="round"
36+
/>
37+
</svg>
38+
),
2139
HelpHexagon: IconHelpHexagon,
2240
};
2341

@@ -35,6 +53,7 @@ const getLearnerHeaderMenu = (
3553
exploreCoursesClick,
3654
) => {
3755
const BASE_URL = getConfig().LMS_BASE_URL;
56+
const searchCatalogUrl = getConfig().SEARCH_CATALOG_URL;
3857
const configNavLinks = getConfig().HEADER_NAV_LINKS;
3958
const isLinkActive = (link) => {
4059
if (link.url === '/dashboard' || link.url.endsWith('/dashboard')) {
@@ -81,13 +100,13 @@ const getLearnerHeaderMenu = (
81100
: []),
82101
];
83102

84-
const searchItem = courseSearchUrl ? [{
103+
const searchItem = searchCatalogUrl ? [{
85104
type: 'item',
86105
href: null,
87106
className: 'lw-search-item',
88107
content: (
89108
<div className="lw-search-wrapper">
90-
<IconSearch size={16} className="lw-search-icon" />
109+
<ICON_MAP.Search size={18} className="lw-search-icon" />
91110
<input
92111
className="lw-search-input"
93112
type="search"
@@ -96,7 +115,7 @@ const getLearnerHeaderMenu = (
96115
onKeyDown={(e) => {
97116
if (e.key === 'Enter') {
98117
const q = e.target.value.trim();
99-
window.location.href = urls.baseAppUrl(courseSearchUrl)
118+
window.location.href = urls.baseAppUrl(searchCatalogUrl)
100119
+ (q ? `?q=${encodeURIComponent(q)}` : '');
101120
}
102121
}}

src/containers/LearnerDashboardHeader/index.scss

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,40 +134,75 @@
134134
flex-shrink: 0;
135135
}
136136

137-
// Pill search input in the header secondary slot (before bell icon)
138-
.lw-search-wrapper {
139-
position: relative;
137+
// Search input in the header secondary slot (before bell icon)
138+
// Scoped to override shared frontend-component-header pill defaults.
139+
.site-header-desktop .lw-search-wrapper {
140+
box-sizing: border-box;
140141
display: inline-flex;
141142
align-items: center;
143+
gap: 8px;
144+
width: 233px;
145+
height: 40px;
146+
padding: 8px 12px;
142147
margin-right: 0.5rem;
148+
border-radius: 6px;
149+
border: 1px solid #E2E8F0;
150+
background: #F8FAFC;
151+
opacity: 1;
152+
transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
153+
154+
&:focus-within {
155+
border-color: #059669;
156+
background: #fff;
157+
box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.16);
158+
159+
.lw-search-icon {
160+
color: #059669;
161+
}
162+
}
143163

144164
.lw-search-icon {
145-
position: absolute;
146-
left: 0.625rem;
147-
width: 1rem;
148-
height: 1rem;
149-
color: #6b7280;
165+
position: static;
166+
flex-shrink: 0;
167+
width: 18px;
168+
height: 18px;
169+
color: #64748B;
150170
pointer-events: none;
151171
}
152172

173+
.lw-search-icon path {
174+
stroke-width: 1.7px;
175+
}
176+
153177
.lw-search-input {
154-
border-radius: 9999px;
155-
border: 1.5px solid #e5e7eb;
156-
padding: 0.375rem 1rem 0.375rem 2.125rem;
157-
font-size: 0.875rem;
158-
color: #374151;
159-
background: #f9fafb;
160-
width: 13rem;
178+
flex: 1;
179+
min-width: 0;
180+
width: auto;
181+
height: 21px;
182+
border: none;
183+
border-radius: 0;
184+
padding: 0;
185+
margin: 0;
186+
background: transparent;
161187
outline: none;
162-
transition: border-color 150ms ease, background 150ms ease;
188+
font-size: 14px;
189+
line-height: 21px;
190+
letter-spacing: 0;
191+
color: #64748B;
163192

164193
&:focus {
165-
border-color: #9ca3af;
166-
background: #fff;
194+
border: none;
195+
background: transparent;
167196
}
168197

169198
&::placeholder {
170-
color: #9ca3af;
199+
font-family: inherit;
200+
font-weight: 400;
201+
font-size: 14px;
202+
line-height: 21px;
203+
letter-spacing: 0;
204+
color: #64748B;
205+
opacity: 1;
171206
}
172207

173208
&::-webkit-search-decoration,

0 commit comments

Comments
 (0)