|
6 | 6 | import {
|
7 | 7 | Box,
|
8 | 8 | Button,
|
| 9 | + Container, |
9 | 10 | Fade,
|
10 | 11 | Flex,
|
11 | 12 | HStack,
|
@@ -178,124 +179,130 @@ const SideBarHeader = ({
|
178 | 179 | </ModalOverlay>
|
179 | 180 | </Modal>
|
180 | 181 | )}
|
181 |
| - <Flex |
182 |
| - ref={ref} |
183 |
| - backgroundColor="brand.500" |
184 |
| - boxShadow="0px 4px 16px #00000033" |
185 |
| - zIndex={zIndexSidebarHeader} |
186 |
| - height={ |
187 |
| - searchAvailable && searchModal.isOpen ? "4.95rem" : topBarHeight |
188 |
| - } |
189 |
| - alignItems="center" |
190 |
| - justifyContent="space-between" |
191 |
| - pr={4} |
192 |
| - transition="height .2s" |
193 |
| - position="relative" |
194 |
| - > |
195 |
| - <Link |
196 |
| - display="block" |
197 |
| - href="https://microbit.org/code/" |
198 |
| - target="_blank" |
199 |
| - rel="noopener noreferrer" |
200 |
| - aria-label={intl.formatMessage({ id: "visit-dot-org" })} |
201 |
| - mx="1rem" |
| 182 | + <Container variant="sidebar-header"> |
| 183 | + <Flex |
| 184 | + ref={ref} |
| 185 | + boxShadow="0px 4px 16px #00000033" |
| 186 | + zIndex={zIndexSidebarHeader} |
| 187 | + height={ |
| 188 | + searchAvailable && searchModal.isOpen ? "4.95rem" : topBarHeight |
| 189 | + } |
| 190 | + alignItems="center" |
| 191 | + justifyContent="space-between" |
| 192 | + pr={4} |
| 193 | + transition="height .2s" |
| 194 | + position="relative" |
202 | 195 | >
|
203 |
| - <HStack spacing="0.875rem"> |
204 |
| - <Box width="3.56875rem" color="white" role="img" ref={faceLogoRef}> |
205 |
| - {brand.squareLogo} |
206 |
| - </Box> |
207 |
| - {!query && sidebarShown && ( |
208 |
| - <Box width="9.098rem" role="img" color="white"> |
209 |
| - {brand.horizontalLogo} |
210 |
| - </Box> |
211 |
| - )} |
212 |
| - </HStack> |
213 |
| - </Link> |
214 |
| - {searchAvailable && !query && sidebarShown && ( |
215 |
| - <CollapsibleButton |
216 |
| - onClick={handleModalOpened} |
217 |
| - backgroundColor="#5c40a6" |
218 |
| - fontWeight="normal" |
219 |
| - color="#fffc" |
220 |
| - icon={<Box as={RiSearch2Line} fontSize="lg" color="fff" />} |
221 |
| - fontSize="sm" |
222 |
| - _hover={{}} |
223 |
| - _active={{}} |
224 |
| - border="unset" |
225 |
| - textAlign="left" |
226 |
| - p={3} |
227 |
| - pr={`min(${contentWidth / 50}%, var(--chakra-space-20))`} |
228 |
| - _collapsed={{ |
229 |
| - pr: 3, |
230 |
| - }} |
231 |
| - text={intl.formatMessage({ id: "search" })} |
232 |
| - mode={searchButtonMode} |
233 |
| - mr="2rem" |
234 |
| - /> |
235 |
| - )} |
236 |
| - {searchAvailable && query && sidebarShown && ( |
237 |
| - <Flex |
238 |
| - backgroundColor="white" |
239 |
| - borderRadius="3xl" |
240 |
| - width={`calc(100% - ${modalOffset}px - 28px)`} |
241 |
| - marginRight="28px" |
242 |
| - position="relative" |
| 196 | + <Link |
| 197 | + display="block" |
| 198 | + href="https://microbit.org/code/" |
| 199 | + target="_blank" |
| 200 | + rel="noopener noreferrer" |
| 201 | + aria-label={intl.formatMessage({ id: "visit-dot-org" })} |
| 202 | + mx="1rem" |
243 | 203 | >
|
244 |
| - <Button |
245 |
| - _active={{}} |
| 204 | + <HStack spacing="0.875rem"> |
| 205 | + <Box |
| 206 | + width="3.56875rem" |
| 207 | + color="white" |
| 208 | + role="img" |
| 209 | + ref={faceLogoRef} |
| 210 | + > |
| 211 | + {brand.squareLogo} |
| 212 | + </Box> |
| 213 | + {!query && sidebarShown && ( |
| 214 | + <Box width="9.098rem" role="img" color="white"> |
| 215 | + {brand.horizontalLogo} |
| 216 | + </Box> |
| 217 | + )} |
| 218 | + </HStack> |
| 219 | + </Link> |
| 220 | + {searchAvailable && !query && sidebarShown && ( |
| 221 | + <CollapsibleButton |
| 222 | + onClick={handleModalOpened} |
| 223 | + backgroundColor="brand.700" |
| 224 | + fontWeight="normal" |
| 225 | + color="#fffc" |
| 226 | + icon={<Box as={RiSearch2Line} fontSize="lg" color="fff" />} |
| 227 | + fontSize="sm" |
246 | 228 | _hover={{}}
|
| 229 | + _active={{}} |
247 | 230 | border="unset"
|
248 |
| - color="gray.800" |
249 |
| - flex={1} |
250 |
| - fontSize="md" |
251 |
| - fontWeight="normal" |
252 |
| - justifyContent="flex-start" |
253 |
| - leftIcon={ |
254 |
| - <Box as={RiSearch2Line} fontSize="lg" color="#838383" /> |
255 |
| - } |
256 |
| - onClick={handleModalOpened} |
257 |
| - overflow="hidden" |
258 |
| - > |
259 |
| - {query} |
260 |
| - </Button> |
261 |
| - <IconButton |
262 |
| - aria-label={intl.formatMessage({ id: "clear" })} |
263 |
| - backgroundColor="white" |
264 |
| - // Also used for Zoom, move to theme. |
265 |
| - color="#838383" |
266 |
| - fontSize="2xl" |
267 |
| - icon={<RiCloseLine />} |
268 |
| - isRound={false} |
269 |
| - onClick={handleClear} |
270 |
| - position="absolute" |
271 |
| - right="0" |
272 |
| - pr={3} |
273 |
| - pl={3} |
274 |
| - variant="ghost" |
| 231 | + textAlign="left" |
| 232 | + p={3} |
| 233 | + pr={`min(${contentWidth / 50}%, var(--chakra-space-20))`} |
| 234 | + _collapsed={{ |
| 235 | + pr: 3, |
| 236 | + }} |
| 237 | + text={intl.formatMessage({ id: "search" })} |
| 238 | + mode={searchButtonMode} |
| 239 | + mr="2rem" |
275 | 240 | />
|
| 241 | + )} |
| 242 | + {searchAvailable && query && sidebarShown && ( |
| 243 | + <Flex |
| 244 | + backgroundColor="white" |
| 245 | + borderRadius="3xl" |
| 246 | + width={`calc(100% - ${modalOffset}px - 28px)`} |
| 247 | + marginRight="28px" |
| 248 | + position="relative" |
| 249 | + > |
| 250 | + <Button |
| 251 | + _active={{}} |
| 252 | + _hover={{}} |
| 253 | + border="unset" |
| 254 | + color="gray.800" |
| 255 | + flex={1} |
| 256 | + fontSize="md" |
| 257 | + fontWeight="normal" |
| 258 | + justifyContent="flex-start" |
| 259 | + leftIcon={ |
| 260 | + <Box as={RiSearch2Line} fontSize="lg" color="#838383" /> |
| 261 | + } |
| 262 | + onClick={handleModalOpened} |
| 263 | + overflow="hidden" |
| 264 | + > |
| 265 | + {query} |
| 266 | + </Button> |
| 267 | + <IconButton |
| 268 | + aria-label={intl.formatMessage({ id: "clear" })} |
| 269 | + backgroundColor="white" |
| 270 | + // Also used for Zoom, move to theme. |
| 271 | + color="#838383" |
| 272 | + fontSize="2xl" |
| 273 | + icon={<RiCloseLine />} |
| 274 | + isRound={false} |
| 275 | + onClick={handleClear} |
| 276 | + position="absolute" |
| 277 | + right="0" |
| 278 | + pr={3} |
| 279 | + pl={3} |
| 280 | + variant="ghost" |
| 281 | + /> |
| 282 | + </Flex> |
| 283 | + )} |
| 284 | + <Flex |
| 285 | + height="100%" |
| 286 | + alignItems="center" |
| 287 | + position="absolute" |
| 288 | + width="28px" |
| 289 | + right={sidebarShown ? "-8px" : "-28px"} |
| 290 | + > |
| 291 | + <Fade in={collapseBtn.isOpen} initial={{ opacity: 1 }}> |
| 292 | + <HideSplitViewButton |
| 293 | + aria-label={ |
| 294 | + sidebarShown |
| 295 | + ? intl.formatMessage({ id: "sidebar-collapse" }) |
| 296 | + : intl.formatMessage({ id: "sidebar-expand" }) |
| 297 | + } |
| 298 | + onClick={handleCollapseBtnClick} |
| 299 | + splitViewShown={sidebarShown} |
| 300 | + direction="expandRight" |
| 301 | + /> |
| 302 | + </Fade> |
276 | 303 | </Flex>
|
277 |
| - )} |
278 |
| - <Flex |
279 |
| - height="100%" |
280 |
| - alignItems="center" |
281 |
| - position="absolute" |
282 |
| - width="28px" |
283 |
| - right={sidebarShown ? "-8px" : "-28px"} |
284 |
| - > |
285 |
| - <Fade in={collapseBtn.isOpen} initial={{ opacity: 1 }}> |
286 |
| - <HideSplitViewButton |
287 |
| - aria-label={ |
288 |
| - sidebarShown |
289 |
| - ? intl.formatMessage({ id: "sidebar-collapse" }) |
290 |
| - : intl.formatMessage({ id: "sidebar-expand" }) |
291 |
| - } |
292 |
| - onClick={handleCollapseBtnClick} |
293 |
| - splitViewShown={sidebarShown} |
294 |
| - direction="expandRight" |
295 |
| - /> |
296 |
| - </Fade> |
297 | 304 | </Flex>
|
298 |
| - </Flex> |
| 305 | + </Container> |
299 | 306 | </>
|
300 | 307 | );
|
301 | 308 | };
|
|
0 commit comments