Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(ui): improve mobile navigation and tag-based question creation #1257

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions ui/src/components/Header/components/NavItems/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { FC, memo } from 'react';
import { Nav, Dropdown } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { NavLink, useNavigate } from 'react-router-dom';
import { NavLink, useMatch, useNavigate } from 'react-router-dom';

import type * as Type from '@/common/interface';
import { Avatar, Icon } from '@/components';
Expand Down Expand Up @@ -48,13 +48,27 @@ const Index: FC<Props> = ({ redDot, userInfo, logOut }) => {
});
}
};
/**
* Automatically append `tag` information when creating a question
*/
const tagMatch = useMatch('/tags/:slugName');
let askUrl = '/questions/ask';
if (tagMatch && tagMatch.params.slugName) {
askUrl = `${askUrl}?tags=${encodeURIComponent(tagMatch.params.slugName)}`;
}
return (
<>
<Nav className="flex-row">
<NavLink
to={askUrl}
title={t('btns.add_question')}
className="d-flex lg-none icon-link nav-link d-flex align-items-center justify-content-center p-0 me-2 position-relative">
<Icon name="plus-circle-fill" className="fs-4" />
</NavLink>
<NavLink
to="/users/notifications/inbox"
title={t('inbox', { keyPrefix: 'notifications' })}
className="icon-link nav-link d-flex align-items-center justify-content-center p-0 me-3 position-relative">
className="icon-link nav-link d-flex align-items-center justify-content-center p-0 me-2 position-relative">
<Icon name="bell-fill" className="fs-4" />
{(redDot?.inbox || 0) > 0 && (
<div className="unread-dot bg-danger">
Expand All @@ -68,7 +82,7 @@ const Index: FC<Props> = ({ redDot, userInfo, logOut }) => {
<NavLink
to="/users/notifications/achievement"
title={t('achievement', { keyPrefix: 'notifications' })}
className="icon-link nav-link d-flex align-items-center justify-content-center p-0 me-3 position-relative">
className="icon-link nav-link d-flex align-items-center justify-content-center p-0 me-2 position-relative">
<Icon name="trophy-fill" className="fs-4" />
{(redDot?.achievement || 0) > 0 && (
<div className="unread-dot bg-danger">
Expand Down
7 changes: 0 additions & 7 deletions ui/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ const Header: FC = () => {
</Form>
</Col>

<Nav.Item className="lg-none mt-3 pb-1">
<Link
to={askUrl}
className="text-capitalize text-nowrap btn btn-light">
{t('btns.add_question')}
</Link>
</Nav.Item>
{/* pc nav */}
<Col
lg={4}
Expand Down