Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imprv: display page tree in page select modal with scrollbar #8514

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion apps/app/src/components/ItemsTree/ItemsTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const ItemsTree = (props: ItemsTreeProps): JSX.Element => {

if (initialItemNode != null) {
return (
<ul className={`grw-pagetree ${styles['grw-pagetree']} list-group py-4`} ref={rootElemRef}>
<ul className={`grw-pagetree ${styles['grw-pagetree']} list-group`} ref={rootElemRef}>
<CustomTreeItem
key={initialItemNode.page.path}
targetPathOrId={targetPathOrId}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.grw-page-select-modal-wrapper {
height: 50vh;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これどこで使っているの?

Copy link
Contributor Author

@WNomunomu WNomunomu Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PageSelectModalのPageSelectModalWrapperコンポーネントのheightを設定するために使っています。
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scoped css にしてください

48 changes: 37 additions & 11 deletions apps/app/src/components/PageSelectModal/PageSelectModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { FC } from 'react';
import { Suspense, useState, useCallback } from 'react';
import {
Suspense, useState, useCallback, memo,
} from 'react';

import nodePath from 'path';

Expand All @@ -16,9 +18,29 @@ import { useCurrentPagePath, useCurrentPageId, useSWRxCurrentPage } from '~/stor
import { ItemsTree } from '../ItemsTree';
import ItemsTreeContentSkeleton from '../ItemsTree/ItemsTreeContentSkeleton';
import { usePagePathRenameHandler } from '../PageEditor/page-path-rename-utils';
import { StickyStretchableScroller } from '../StickyStretchableScroller';

import { TreeItemForModal } from './TreeItemForModal';

import 'simplebar';
import 'simplebar/dist/simplebar.css';

const TreeForModalWrapper = memo((props: { children: JSX.Element }) => {

const { children } = props;

const calcViewHeight = useCallback(() => {
return window.innerHeight / 2;
}, []);

return (
<div className="grw-page-select-modal-wrapper">
<div data-simplebar>
{ children }
</div>
</div>
);
});

export const PageSelectModal: FC = () => {
const {
Expand Down Expand Up @@ -83,17 +105,21 @@ export const PageSelectModal: FC = () => {
size="sm"
>
<ModalHeader toggle={closeModal}>{t('page_select_modal.select_page_location')}</ModalHeader>
<ModalBody>
<ModalBody className="p-0">
<Suspense fallback={<ItemsTreeContentSkeleton />}>
<ItemsTree
CustomTreeItem={TreeItemForModal}
isEnableActions={!isGuestUser}
isReadOnlyUser={!!isReadOnlyUser}
targetPath={path}
targetPathOrId={targetPathOrId}
targetAndAncestorsData={targetAndAncestorsData}
onClickTreeItem={onClickTreeItem}
/>
<TreeForModalWrapper>
<div className="p-3">
<ItemsTree
CustomTreeItem={TreeItemForModal}
isEnableActions={!isGuestUser}
isReadOnlyUser={!!isReadOnlyUser}
targetPath={path}
targetPathOrId={targetPathOrId}
targetAndAncestorsData={targetAndAncestorsData}
onClickTreeItem={onClickTreeItem}
/>
</div>
</TreeForModalWrapper>
</Suspense>
</ModalBody>
<ModalFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const PageTreeContent = memo(({ isWipPageShown }: PageTreeContentProps) =
const path = currentPath || '/';

return (
<>
<div className="py-3">
<ItemsTree
isEnableActions={!isGuestUser}
isReadOnlyUser={!!isReadOnlyUser}
Expand All @@ -116,15 +116,14 @@ export const PageTreeContent = memo(({ isWipPageShown }: PageTreeContentProps) =
targetAndAncestorsData={targetAndAncestorsData}
CustomTreeItem={PageTreeItem}
/>

{!isGuestUser && !isReadOnlyUser && migrationStatus?.migratablePagesCount != null && migrationStatus.migratablePagesCount !== 0 && (
<div className="grw-pagetree-footer border-top py-3 w-100">
<div className="private-legacy-pages-link px-3 py-2">
<PrivateLegacyPagesLink />
</div>
</div>
)}
</>
</div>
);
});

Expand Down
Loading