PluginProbe
Code Snippets / 3.10.0-beta.1
Code Snippets v3.10.0-beta.1
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.0-beta.1, at js/components/common/SnippetViewToggle.tsx

41 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, TableViewIcon } from './icons/ViewIcons'
5 import type { SnippetView } from '../../types/SnippetView'
6
7 export interface SnippetViewToggleProps {
8 snippetView: SnippetView
9 setSnippetView: (view: SnippetView) => void
10 className?: string
11 }
12
13 export const SnippetViewToggle: React.FC<SnippetViewToggleProps> = ({ snippetView, setSnippetView, className }) =>
14 <div
15 className={classnames('snippet-view-toggle', className)}
16 role="group"
17 aria-label={__('Snippet view', 'code-snippets')}
18 >
19 <button
20 type="button"
21 className={classnames('snippet-view-toggle-option', { 'active-view': 'card' === snippetView })}
22 aria-pressed={'card' === snippetView}
23 title={__('Switch to card view', 'code-snippets')}
24 onClick={() => setSnippetView('card')}
25 >
26 <CardViewIcon aria-hidden="true" />
27 <span className="screen-reader-text">{__('Card view', 'code-snippets')}</span>
28 </button>
29
30 <button
31 type="button"
32 className={classnames('snippet-view-toggle-option', { 'active-view': 'table' === snippetView })}
33 aria-pressed={'table' === snippetView}
34 title={__('Switch to table view', 'code-snippets')}
35 onClick={() => setSnippetView('table')}
36 >
37 <TableViewIcon aria-hidden="true" />
38 <span className="screen-reader-text">{__('Table view', 'code-snippets')}</span>
39 </button>
40 </div>
41