| 1 |
import { useRouter } from '@help-center/hooks/useRouter'; |
| 2 |
import { useKnowledgeBaseStore } from '@help-center/state/knowledge-base.js'; |
| 3 |
import { isRTL } from '@wordpress/i18n'; |
| 4 |
import { Icon, redo, undo } from '@wordpress/icons'; |
| 5 |
|
| 6 |
export const ArticlesList = ({ articles }) => { |
| 7 |
const { pushArticle } = useKnowledgeBaseStore(); |
| 8 |
const { navigateTo } = useRouter(); |
| 9 |
|
| 10 |
return ( |
| 11 |
<ul |
| 12 |
className="m-0 flex flex-col gap-1 py-2" |
| 13 |
data-test="help-center-kb-articles-list" |
| 14 |
> |
| 15 |
{articles.map(({ slug, title }) => ( |
| 16 |
<li key={slug} className="m-0 py-1 pl-2 pr-3"> |
| 17 |
<button |
| 18 |
type="button" |
| 19 |
className="flex gap-2 bg-transparent text-sm text-gray-800 hover:underline hover:underline-offset-4" |
| 20 |
onClick={() => { |
| 21 |
pushArticle({ slug, title }); |
| 22 |
navigateTo('knowledge-base-article'); |
| 23 |
}} |
| 24 |
> |
| 25 |
<Icon |
| 26 |
size={20} |
| 27 |
icon={isRTL() ? redo : undo} |
| 28 |
className="rotate-180 transform fill-gray-700" |
| 29 |
/> |
| 30 |
{title} |
| 31 |
</button> |
| 32 |
</li> |
| 33 |
))} |
| 34 |
</ul> |
| 35 |
); |
| 36 |
}; |
| 37 |
|