Skip to content

Commit

Permalink
simplify name vs id in variables and props
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1008 authored and ciampo committed Dec 22, 2023
1 parent 9af21d1 commit 4da77d1
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ const { Tabs } = unlock( componentsPrivateApis );

const DEFAULT_TABS = [
{
name: 'installed-fonts',
id: 'installed-fonts',
title: __( 'Library' ),
},
{
name: 'upload-fonts',
id: 'upload-fonts',
title: __( 'Upload' ),
},
];

const tabsFromCollections = ( collections ) =>
collections.map( ( { id, name } ) => ( {
name: id,
id,
title:
collections.length === 1 && id === 'default-font-collection'
? __( 'Install Fonts' )
Expand All @@ -41,7 +41,7 @@ const tabsFromCollections = ( collections ) =>

function FontLibraryModal( {
onRequestClose,
initialTabName = 'installed-fonts',
initialTabId = 'installed-fonts',
} ) {
const { collections } = useContext( FontLibraryContext );

Expand All @@ -58,30 +58,30 @@ function FontLibraryModal( {
className="font-library-modal"
>
<div className="font-library-modal__tabs">
<Tabs initialTabId={ initialTabName }>
<Tabs initialTabId={ initialTabId }>
<Tabs.TabList>
{ tabs.map( ( { name, title } ) => (
<Tabs.Tab key={ name } tabId={ name }>
{ tabs.map( ( { id, title } ) => (
<Tabs.Tab key={ id } tabId={ id }>
{ title }
</Tabs.Tab>
) ) }
</Tabs.TabList>
{ tabs.map( ( { name } ) => {
{ tabs.map( ( { id } ) => {
let contents;
switch ( name ) {
switch ( id ) {
case 'upload-fonts':
contents = <UploadFonts />;
break;
case 'installed-fonts':
contents = <InstalledFonts />;
break;
default:
contents = <FontCollection id={ name } />;
contents = <FontCollection id={ id } />;
}
return (
<Tabs.TabPanel
key={ name }
tabId={ name }
key={ id }
tabId={ id }
focusable="false"
>
{ contents }
Expand Down

0 comments on commit 4da77d1

Please sign in to comment.