PluginProbe
Code Snippets / 3.10.2
Code Snippets v3.10.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / common / SnippetViewToggle.tsx

SnippetViewToggle.tsx in Code Snippets 3.10.2, at js/components/common/SnippetViewToggle.tsx

42 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react'
2 import classnames from 'classnames'
3 import { __ } from '@wordpress/i18n'
4 import { CardViewIcon } from './icons/CardViewIcon'
5 import { TableViewIcon } from './icons/TableViewIcon'
6 import type { SnippetView } from '../../types/SnippetView'
7
8 export interface SnippetViewToggleProps {
9 snippetView: SnippetView
10 setSnippetView: (view: SnippetView) => void
11 className?: string
12 }
13
14 export const SnippetViewToggle: React.FC<SnippetViewToggleProps> = ({ snippetView, setSnippetView, className }) =>
15 <div
16 className={classnames('snippet-view-toggle', className)}
17 role="group"
18 aria-label={__('Snippet view', 'code-snippets')}
19 >
20 <button
21 type="button"
22 className={classnames('snippet-view-toggle-option', { 'active-view': 'card' === snippetView })}
23 aria-pressed={'card' === snippetView}
24 title={__('Switch to card view', 'code-snippets')}
25 onClick={() => setSnippetView('card')}
26 >
27 <CardViewIcon aria-hidden="true" />
28 <span className="screen-reader-text">{__('Card view', 'code-snippets')}</span>
29 </button>
30
31 <button
32 type="button"
33 className={classnames('snippet-view-toggle-option', { 'active-view': 'table' === snippetView })}
34 aria-pressed={'table' === snippetView}
35 title={__('Switch to table view', 'code-snippets')}
36 onClick={() => setSnippetView('table')}
37 >
38 <TableViewIcon aria-hidden="true" />
39 <span className="screen-reader-text">{__('Table view', 'code-snippets')}</span>
40 </button>
41 </div>
42