Feat/use searchparams as state (#2554)

Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
Rozstone
2024-02-26 12:52:59 +08:00
committed by GitHub
parent ca69af7b97
commit d93288f711
7 changed files with 58 additions and 9 deletions

View File

@@ -42,6 +42,7 @@ const HeaderOptions: FC<Props> = ({
const { locale } = useContext(I18n)
const { CSVDownloader, Type } = useCSVDownloader()
const [list, setList] = useState<AnnotationItemBasic[]>([])
const annotationUnavailable = list.length === 0
const listTransformer = (list: AnnotationItemBasic[]) => list.map(
(item: AnnotationItemBasic) => {
@@ -116,11 +117,11 @@ const HeaderOptions: FC<Props> = ({
...list.map(item => [item.question, item.answer]),
]}
>
<button className={s.actionItem}>
<button disabled={annotationUnavailable} className={s.actionItem}>
<span className={s.actionName}>CSV</span>
</button>
</CSVDownloader>
<button className={cn(s.actionItem, '!border-0')} onClick={JSONLOutput}>
<button disabled={annotationUnavailable} className={cn(s.actionItem, '!border-0')} onClick={JSONLOutput}>
<span className={s.actionName}>JSONL</span>
</button>
</Menu.Items>

View File

@@ -19,7 +19,7 @@
}
.actionItem {
@apply h-9 py-2 px-3 mx-1 flex items-center space-x-2 hover:bg-gray-100 rounded-lg cursor-pointer;
@apply h-9 py-2 px-3 mx-1 flex items-center space-x-2 hover:bg-gray-100 rounded-lg cursor-pointer disabled:opacity-50;
width: calc(100% - 0.5rem);
}
@@ -35,4 +35,4 @@
left: 4px;
transform: translateX(-100%);
box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
}
}