Skip to content

Commit

Permalink
Merge pull request tangly1024#1787 from 1208nn/dev
Browse files Browse the repository at this point in the history
支持隐藏单独的评论标签页
  • Loading branch information
tangly1024 committed Jan 25, 2024
2 parents 17498e5 + dd9f07d commit d8d1145
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions components/Tabs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from 'react';
import { siteConfig } from '@/lib/config'

/**
* Tabs切换标签
Expand All @@ -16,15 +17,17 @@ const Tabs = ({ className, children }) => {

return (
<div className={`mb-5 duration-200 ${className}`}>
<ul className="flex justify-center space-x-5 pb-4 dark:text-gray-400 text-gray-600 overflow-auto">
{validChildren.map((item, index) => (
<li key={index}
className={`${currentTab === index ? 'font-black border-b-2 border-red-600 text-red-600 animate__animated animate__jello' : 'font-extralight cursor-pointer'} text-sm font-sans`}
onClick={() => setCurrentTab(index)}>
{item.key}
</li>
))}
</ul>
{!(validChildren.length === 1 && siteConfig('COMMENT_HIDE_SINGLE_TAB')) && (
<ul className="flex justify-center space-x-5 pb-4 dark:text-gray-400 text-gray-600 overflow-auto">
{validChildren.map((item, index) => (
<li key={index}
className={`${currentTab === index ? 'font-black border-b-2 border-red-600 text-red-600 animate__animated animate__jello' : 'font-extralight cursor-pointer'} text-sm font-sans`}
onClick={() => setCurrentTab(index)}>
{item.key}
</li>
))}
</ul>
)}
{/* 标签切换的时候不销毁 DOM 元素,使用 CSS 样式进行隐藏 */}
<div>
{validChildren.map((item, index) => (
Expand Down

0 comments on commit d8d1145

Please sign in to comment.