chore: update selector style

This commit is contained in:
Steven 2022-08-25 21:05:31 +08:00
parent e9d303326f
commit 9f3f730723
6 changed files with 43 additions and 17 deletions

View File

@ -243,9 +243,19 @@ const MemoEditor: React.FC<Props> = () => {
<div className="action-btn tag-action"> <div className="action-btn tag-action">
<Icon.Hash className="icon-img" /> <Icon.Hash className="icon-img" />
<div ref={tagSeletorRef} className="tag-list" onClick={handleTagSeletorClick}> <div ref={tagSeletorRef} className="tag-list" onClick={handleTagSeletorClick}>
{tags.map((t) => { {tags.length > 0 ? (
return <span key={t}>{t}</span>; tags.map((tag) => {
})} return (
<span className="item-container" key={tag}>
{tag}
</span>
);
})
) : (
<p className="tip-text" onClick={(e) => e.stopPropagation()}>
{t("common.null")}
</p>
)}
</div> </div>
</div> </div>
<button className="action-btn"> <button className="action-btn">

View File

@ -1,4 +1,5 @@
import { memo, useEffect, useRef } from "react"; import { memo, useEffect, useRef } from "react";
import useI18n from "../../hooks/useI18n";
import useToggle from "../../hooks/useToggle"; import useToggle from "../../hooks/useToggle";
import Icon from "../Icon"; import Icon from "../Icon";
import "../../less/common/selector.less"; import "../../less/common/selector.less";
@ -22,6 +23,7 @@ const nullItem = {
const Selector: React.FC<Props> = (props: Props) => { const Selector: React.FC<Props> = (props: Props) => {
const { className, dataSource, handleValueChanged, value } = props; const { className, dataSource, handleValueChanged, value } = props;
const { t } = useI18n();
const [showSelector, toggleSelectorStatus] = useToggle(false); const [showSelector, toggleSelectorStatus] = useToggle(false);
const seletorElRef = useRef<HTMLDivElement>(null); const seletorElRef = useRef<HTMLDivElement>(null);
@ -70,7 +72,8 @@ const Selector: React.FC<Props> = (props: Props) => {
</div> </div>
<div className={`items-wrapper ${showSelector ? "" : "!hidden"}`}> <div className={`items-wrapper ${showSelector ? "" : "!hidden"}`}>
{dataSource.map((d) => { {dataSource.length > 0 ? (
dataSource.map((d) => {
return ( return (
<div <div
className={`item-container ${d.value === value ? "selected" : ""}`} className={`item-container ${d.value === value ? "selected" : ""}`}
@ -82,7 +85,10 @@ const Selector: React.FC<Props> = (props: Props) => {
{d.text} {d.text}
</div> </div>
); );
})} })
) : (
<p className="tip-text">{t("common.null")}</p>
)}
</div> </div>
</div> </div>
); );

View File

@ -39,5 +39,9 @@
color: @text-green; color: @text-green;
} }
} }
> .tip-text {
@apply px-3 py-1 text-sm text-gray-600;
}
} }
} }

View File

@ -52,9 +52,13 @@
> .tag-list { > .tag-list {
@apply hidden flex-col justify-start items-start absolute top-6 left-0 mt-1 p-1 z-1 rounded w-32 max-h-52 overflow-auto bg-black; @apply hidden flex-col justify-start items-start absolute top-6 left-0 mt-1 p-1 z-1 rounded w-32 max-h-52 overflow-auto bg-black;
> span { > .item-container {
@apply w-full text-white cursor-pointer rounded text-sm leading-6 px-2 hover:bg-gray-700; @apply w-full text-white cursor-pointer rounded text-sm leading-6 px-2 hover:bg-gray-700;
} }
> .tip-text {
@apply w-full text-sm text-gray-200 leading-6 px-2 cursor-default;
}
} }
} }
} }

View File

@ -16,6 +16,7 @@
"edit": "Edit", "edit": "Edit",
"restore": "Restore", "restore": "Restore",
"delete": "Delete", "delete": "Delete",
"null": "Null",
"share": "Share", "share": "Share",
"mark": "Mark", "mark": "Mark",
"archive": "Archive", "archive": "Archive",

View File

@ -16,6 +16,7 @@
"edit": "编辑", "edit": "编辑",
"restore": "恢复", "restore": "恢复",
"delete": "删除", "delete": "删除",
"null": "空",
"share": "分享", "share": "分享",
"mark": "标注", "mark": "标注",
"archive": "归档", "archive": "归档",