More catalog updates

This commit is contained in:
Bill 2021-09-23 03:22:43 -04:00
parent e94977f775
commit 7581d8cdf2
9 changed files with 50 additions and 27 deletions

View File

@ -3,16 +3,16 @@ import { NitroCardGridViewProps } from './NitroCardGridView.types';
export const NitroCardGridView: FC<NitroCardGridViewProps> = props => export const NitroCardGridView: FC<NitroCardGridViewProps> = props =>
{ {
const { columns = 5, className = '', style = null, children = null, ...rest } = props; const { columns = 5, gap = 2, className = '', style = null, children = null, ...rest } = props;
const getClassName = useMemo(() => const getClassName = useMemo(() =>
{ {
let newClassName = 'grid gap-2 overflow-auto'; let newClassName = `grid gap-${ gap } overflow-auto`;
if(className && className.length) newClassName += ' ' + className; if(className && className.length) newClassName += ' ' + className;
return newClassName; return newClassName;
}, [ className ]); }, [ className, gap ]);
const getStyle = useMemo(() => const getStyle = useMemo(() =>
{ {

View File

@ -3,4 +3,5 @@ import { DetailsHTMLAttributes } from 'react';
export interface NitroCardGridViewProps extends DetailsHTMLAttributes<HTMLDivElement> export interface NitroCardGridViewProps extends DetailsHTMLAttributes<HTMLDivElement>
{ {
columns?: number; columns?: number;
gap?: number;
} }

View File

@ -8,7 +8,7 @@ export const NitroCardGridItemView: FC<NitroCardGridItemViewProps> = props =>
const getClassName = useMemo(() => const getClassName = useMemo(() =>
{ {
let newClassName = 'grid-item cursor-pointer overflow-hidden'; let newClassName = 'grid-item gap-1 cursor-pointer overflow-hidden';
if(itemActive) newClassName += ' active'; if(itemActive) newClassName += ' active';

View File

@ -205,7 +205,7 @@ export const CatalogView: FC<CatalogViewProps> = props =>
<NitroCardContentView> <NitroCardContentView>
<div className="row h-100"> <div className="row h-100">
{ currentNavigationPage && !navigationHidden && { currentNavigationPage && !navigationHidden &&
<div className="col-3 d-flex flex-column h-100"> <div className="col-3 h-100">
<CatalogNavigationView page={ currentNavigationPage } pendingTree={ pendingTree } setPendingTree={ setPendingTree } /> <CatalogNavigationView page={ currentNavigationPage } pendingTree={ pendingTree } setPendingTree={ setPendingTree } />
</div> } </div> }
<div className="col h-100"> <div className="col h-100">

View File

@ -1,11 +1,31 @@
.nitro-catalog-navigation { .nitro-catalog-navigation-grid {
border-color: $grid-border-color !important; border-radius: 0.25rem;
background-color: $grid-bg-color !important; border-color: #B6BEC5 !important;
background-color: #CDD3D9;
border: 2px solid;
.navigation-container { .grid-item {
overflow-y: auto; font-size: $font-size-sm;
height: 23px !important;
border-color: unset !important;
background-color: #CDD3D9;
border: 0 !important;
padding: 1px 3px;
i.fas {
color: $black;
font-size: 10px;
padding: 1px;
} }
} }
// border-color: $grid-border-color !important;
// background-color: $grid-bg-color !important;
// .navigation-container {
// overflow-y: auto;
// }
}
@import './item/CatalogNavigationItemView'; @import './item/CatalogNavigationItemView';
@import './set/CatalogNavigationSetView'; @import './set/CatalogNavigationSetView';

View File

@ -1,5 +1,6 @@
import { INodeData } from '@nitrots/nitro-renderer'; import { INodeData } from '@nitrots/nitro-renderer';
import { FC, useEffect } from 'react'; import { FC, useEffect } from 'react';
import { NitroCardGridView } from '../../../../layout';
import { CatalogSearchView } from '../search/CatalogSearchView'; import { CatalogSearchView } from '../search/CatalogSearchView';
import { CatalogNavigationViewProps } from './CatalogNavigationView.types'; import { CatalogNavigationViewProps } from './CatalogNavigationView.types';
import { CatalogNavigationSetView } from './set/CatalogNavigationSetView'; import { CatalogNavigationSetView } from './set/CatalogNavigationSetView';
@ -23,13 +24,15 @@ export const CatalogNavigationView: FC<CatalogNavigationViewProps> = props =>
}, [ page ]); }, [ page ]);
return ( return (
<> <div className="row h-100">
<div className="d-flex flex-column col gap-2 h-100">
<CatalogSearchView /> <CatalogSearchView />
<div className="border border-2 rounded overflow-hidden nitro-catalog-navigation p-1 h-100"> <div className="d-flex flex-column overflow-hidden nitro-catalog-navigation-grid p-1 h-100">
<div className="navigation-container h-100"> <NitroCardGridView columns={ 1 } gap={ 1 }>
<CatalogNavigationSetView page={ page } isFirstSet={ true } pendingTree={ pendingTree } setPendingTree={ setPendingTree } /> <CatalogNavigationSetView page={ page } isFirstSet={ true } pendingTree={ pendingTree } setPendingTree={ setPendingTree } />
</NitroCardGridView>
</div>
</div> </div>
</div> </div>
</>
); );
} }

View File

@ -1,6 +1,7 @@
import { GetCatalogPageComposer, INodeData } from '@nitrots/nitro-renderer'; import { GetCatalogPageComposer, INodeData } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { SendMessageHook } from '../../../../../hooks/messages/message-event'; import { SendMessageHook } from '../../../../../hooks/messages/message-event';
import { NitroCardGridItemView } from '../../../../../layout';
import { CatalogMode } from '../../../CatalogView.types'; import { CatalogMode } from '../../../CatalogView.types';
import { CatalogIconView } from '../../catalog-icon/CatalogIconView'; import { CatalogIconView } from '../../catalog-icon/CatalogIconView';
import { ACTIVE_PAGES } from '../CatalogNavigationView'; import { ACTIVE_PAGES } from '../CatalogNavigationView';
@ -70,16 +71,14 @@ export const CatalogNavigationItemView: FC<CatalogNavigationItemViewProps> = pro
}, [ isActive, page ]); }, [ isActive, page ]);
return ( return (
<div className="col pb-1 catalog-navigation-item-container"> <>
<div className={ 'd-flex align-items-center cursor-pointer catalog-navigation-item ' + (isActive ? 'active ': '') } onClick={ event => select(page) }> <NitroCardGridItemView itemActive={ isActive } onClick={ event => select(page) }>
<CatalogIconView icon={ page.icon } /> <CatalogIconView icon={ page.icon } />
<div className="flex-grow-1 text-black text-truncate px-1">{ page.localization }</div> <div className="flex-grow-1 text-black text-truncate">{ page.localization }</div>
{ (page.children.length > 0) && <i className={ 'fas fa-caret-' + (isExpanded ? 'up' : 'down') } /> } { (page.children.length > 0) && <i className={ 'fas fa-caret-' + (isExpanded ? 'up' : 'down') } /> }
</div> </NitroCardGridItemView>
{ isActive && isExpanded && page.children && (page.children.length > 0) && { isActive && isExpanded && page.children && (page.children.length > 0) &&
<div className="d-flex flex-column mt-1"> <CatalogNavigationSetView page={ page } pendingTree={ pendingTree } setPendingTree={ setPendingTree } /> }
<CatalogNavigationSetView page={ page } pendingTree={ pendingTree } setPendingTree={ setPendingTree } /> </>
</div> }
</div>
); );
} }

View File

@ -26,13 +26,13 @@ export const CatalogNavigationSetView: FC<CatalogNavigationSetViewProps> = props
}, [ page, isFirstSet, activeChild, pendingTree ]); }, [ page, isFirstSet, activeChild, pendingTree ]);
return ( return (
<div className="row row-cols-1 g-0 catalog-navigation-set-container w-100"> <>
{ page && (page.children.length > 0) && page.children.map((page, index) => { page && (page.children.length > 0) && page.children.map((page, index) =>
{ {
if(!page.visible) return null; if(!page.visible) return null;
return <CatalogNavigationItemView key={ index } page={ page } isActive={ (activeChild === page) } pendingTree={ pendingTree } setPendingTree={ setPendingTree } setActiveChild={ setActiveChild } /> return <CatalogNavigationItemView key={ index } page={ page } isActive={ (activeChild === page) } pendingTree={ pendingTree } setPendingTree={ setPendingTree } setActiveChild={ setActiveChild } />
}) } }) }
</div> </>
); );
} }

View File

@ -110,7 +110,7 @@ export const CatalogSearchView: FC<CatalogSearchViewProps> = props =>
}, [ searchValue, processSearch ]); }, [ searchValue, processSearch ]);
return ( return (
<div className="d-flex mb-1"> <div className="d-flex">
<div className="d-flex flex-grow-1 me-1"> <div className="d-flex flex-grow-1 me-1">
<input type="text" className="form-control form-control-sm" placeholder={ LocalizeText('generic.search') } value={ searchValue } onChange={ event => setSearchValue(event.target.value) } /> <input type="text" className="form-control form-control-sm" placeholder={ LocalizeText('generic.search') } value={ searchValue } onChange={ event => setSearchValue(event.target.value) } />
</div> </div>