fix: #1000, optimize tag list layout

This commit is contained in:
haitao(lj) 2022-10-11 16:18:47 +08:00 committed by mingcheng
parent e6ce5712a3
commit 0803631708
5 changed files with 14 additions and 15 deletions

View File

@ -1,2 +1,3 @@
$link-hover-decoration: none; $link-hover-decoration: none;
$enable-negative-margins: true;
$blue: #0033FF !default; $blue: #0033FF !default;

View File

@ -68,16 +68,13 @@ const Index: FC = () => {
{t('edit')} {t('edit')}
</Button> </Button>
</Card.Header> </Card.Header>
<Card.Body className="pb-2"> <Card.Body className="mx-n1">
{followingTags?.length ? ( {followingTags?.length ? (
<> <>
{followingTags.map((item) => { {followingTags.map((item) => {
const slugName = item?.slug_name; const slugName = item?.slug_name;
return ( return (
<Tag <Tag key={slugName} className="m-1" href={`/tags/${slugName}`}>
key={slugName}
className="me-2 mb-2"
href={`/tags/${slugName}`}>
{slugName} {slugName}
</Tag> </Tag>
); );

View File

@ -122,7 +122,9 @@ const QuestionList: FC<Props> = ({ source }) => {
<ListGroup variant="flush" className="border-top border-bottom-0"> <ListGroup variant="flush" className="border-top border-bottom-0">
{listData?.list?.map((li) => { {listData?.list?.map((li) => {
return ( return (
<ListGroup.Item key={li.id} className="border-bottom py-3 px-0"> <ListGroup.Item
key={li.id}
className="border-bottom pt-3 pb-2 px-0">
<h5 className="text-wrap text-break"> <h5 className="text-wrap text-break">
<NavLink to={`/questions/${li.id}`} className="link-dark"> <NavLink to={`/questions/${li.id}`} className="link-dark">
{li.title} {li.title}
@ -153,13 +155,13 @@ const QuestionList: FC<Props> = ({ source }) => {
<em className="fst-normal mx-1">{li.view_count}</em> <em className="fst-normal mx-1">{li.view_count}</em>
</span> </span>
</div> </div>
<div className="question-tags"> <div className="question-tags mx-n1">
{Array.isArray(li.tags) {Array.isArray(li.tags)
? li.tags.map((tag) => { ? li.tags.map((tag) => {
return ( return (
<Tag <Tag
key={tag.slug_name} key={tag.slug_name}
className="me-2 mt-2" className="m-1"
href={`/tags/${ href={`/tags/${
tag.main_tag_slug_name || tag.slug_name tag.main_tag_slug_name || tag.slug_name
}`}> }`}>

View File

@ -177,19 +177,18 @@ const TagSelector: FC<IProps> = ({
onFocus={onFocus} onFocus={onFocus}
onBlur={onBlur} onBlur={onBlur}
onKeyDown={handleKeyDown}> onKeyDown={handleKeyDown}>
<div className="d-flex flex-wrap"> <div className="d-flex flex-wrap mx-n1">
{initialValue?.map((item, index) => { {initialValue?.map((item, index) => {
return ( return (
<Button <Button
key={item.slug_name} key={item.slug_name}
className={classNames( className={classNames(
'me-2 mb-2 text-nowrap d-flex align-items-center', 'm-1 text-nowrap d-flex align-items-center',
index === repeatIndex && 'warning', index === repeatIndex && 'warning',
)} )}
variant="outline-secondary" variant="outline-secondary"
size="sm"> size="sm">
{item.slug_name} {item.slug_name}
<span className="ms-1" onMouseUp={() => handleRemove(item)}> <span className="ms-1" onMouseUp={() => handleRemove(item)}>
× ×
</span> </span>
@ -199,7 +198,7 @@ const TagSelector: FC<IProps> = ({
{initialValue?.length < 5 || alwaysShowAddBtn ? ( {initialValue?.length < 5 || alwaysShowAddBtn ? (
<Dropdown onSelect={handleSelect} onToggle={setVisibleMenu}> <Dropdown onSelect={handleSelect} onToggle={setVisibleMenu}>
<Dropdown.Toggle <Dropdown.Toggle
className={classNames(alwaysShowAddBtn ? 'mb-2' : null)} className={classNames('m-1')}
variant="outline-secondary" variant="outline-secondary"
size="sm"> size="sm">
<span className="me-1">+</span> <span className="me-1">+</span>

View File

@ -65,7 +65,7 @@ const Index: FC<Props> = ({ data, initPage, hasAnswer }) => {
: ''} : ''}
</Link> </Link>
</h1> </h1>
<div className="d-flex align-items-center fs-14 mb-3 text-secondary"> <div className="d-flex align-items-center fs-14 mb-2 text-secondary">
<FormatTime <FormatTime
time={data.create_time} time={data.create_time}
preFix={t('Asked')} preFix={t('Asked')}
@ -90,11 +90,11 @@ const Index: FC<Props> = ({ data, initPage, hasAnswer }) => {
{followed ? 'Following' : 'Follow'} {followed ? 'Following' : 'Follow'}
</Button> </Button>
</div> </div>
<div className="mb-3"> <div className="mb-2 mx-n1">
{data?.tags?.map((item: any) => { {data?.tags?.map((item: any) => {
return ( return (
<Tag <Tag
className="me-1" className="m-1"
href={`/tags/${item.main_tag_slug_name || item.slug_name}`} href={`/tags/${item.main_tag_slug_name || item.slug_name}`}
key={item.slug_name}> key={item.slug_name}>
{item.slug_name} {item.slug_name}