|
|
@@ -4,6 +4,7 @@ import Clamp from 'react-multiline-clamp';
|
|
|
|
|
|
import { UserPicture, PageListMeta, PagePathLabel } from '@growi/ui';
|
|
|
import { pagePathUtils } from '@growi/core';
|
|
|
+import { useIsDeviceSmallerThanMd } from '~/stores/ui';
|
|
|
|
|
|
import { IPageSearchResultData } from '../../interfaces/search';
|
|
|
import PageItemControl from '../Common/Dropdown/PageItemControl';
|
|
|
@@ -27,6 +28,8 @@ const SearchResultListItem: FC<Props> = memo((props:Props) => {
|
|
|
page: { pageData, pageMeta }, isSelected, onClickSearchResultItem, onClickCheckbox, isChecked, isEnableActions, shortBody,
|
|
|
} = props;
|
|
|
|
|
|
+ const { data: isDeviceSmallerThanMd } = useIsDeviceSmallerThanMd();
|
|
|
+
|
|
|
// Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
|
|
|
const pageId = `#${pageData._id}`;
|
|
|
|
|
|
@@ -46,18 +49,23 @@ const SearchResultListItem: FC<Props> = memo((props:Props) => {
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
+ const responsiveListStyleClass = `${isDeviceSmallerThanMd ? '' : `list-group-item-action ${isSelected ? 'active' : ''}`}`;
|
|
|
+
|
|
|
return (
|
|
|
- <li key={pageData._id} className={`page-list-li search-page-item w-100 list-group-item-action pl-2 ${isSelected ? 'active' : ''}`}>
|
|
|
+ <li
|
|
|
+ key={pageData._id}
|
|
|
+ className={`w-100 page-list-li search-result-item border-bottom ${responsiveListStyleClass}`}
|
|
|
+ >
|
|
|
<a
|
|
|
- className="d-block py-4 h-100"
|
|
|
+ className="d-block h-100"
|
|
|
href={pageId}
|
|
|
onClick={() => onClickSearchResultItem != null && onClickSearchResultItem(pageData._id)}
|
|
|
>
|
|
|
- <div className="d-flex">
|
|
|
+ <div className="d-flex h-100">
|
|
|
{/* checkbox */}
|
|
|
- <div className="form-check my-auto mr-3">
|
|
|
+ <div className="form-check d-flex align-items-center justify-content-center px-md-2 pl-3 pr-2 search-item-checkbox">
|
|
|
<input
|
|
|
- className="form-check-input my-auto"
|
|
|
+ className="form-check-input position-relative m-0"
|
|
|
type="checkbox"
|
|
|
id="flexCheckDefault"
|
|
|
onChange={() => {
|
|
|
@@ -68,24 +76,27 @@ const SearchResultListItem: FC<Props> = memo((props:Props) => {
|
|
|
checked={isChecked}
|
|
|
/>
|
|
|
</div>
|
|
|
- <div className="w-100">
|
|
|
+ <div className="search-item-text p-md-3 pl-2 py-3 pr-3 flex-grow-1">
|
|
|
{/* page path */}
|
|
|
- <small className="mb-1">
|
|
|
+ <h6 className="mb-1 py-1">
|
|
|
<i className="icon-fw icon-home"></i>
|
|
|
{pagePathElem}
|
|
|
- </small>
|
|
|
- <div className="d-flex my-1 align-items-center">
|
|
|
+ </h6>
|
|
|
+ <div className="d-flex align-items-center mb-2">
|
|
|
+ {/* Picture */}
|
|
|
+ <span className="mr-2 d-none d-md-block">
|
|
|
+ <UserPicture user={pageData.lastUpdateUser} size="sm" />
|
|
|
+ </span>
|
|
|
{/* page title */}
|
|
|
- <h3 className="mb-0">
|
|
|
- <UserPicture user={pageData.lastUpdateUser} />
|
|
|
- <span className="mx-2 search-result-page-title">{pageTitle}</span>
|
|
|
- </h3>
|
|
|
+ <span className="py-1 h5 mr-2 mb-0">
|
|
|
+ {pageTitle}
|
|
|
+ </span>
|
|
|
{/* page meta */}
|
|
|
- <div className="d-flex mx-2">
|
|
|
+ <div className="d-none d-md-flex item-meta py-0 px-1">
|
|
|
<PageListMeta page={pageData} bookmarkCount={pageMeta.bookmarkCount} />
|
|
|
</div>
|
|
|
{/* doropdown icon includes page control buttons */}
|
|
|
- <div className="ml-auto">
|
|
|
+ <div className="item-control ml-auto">
|
|
|
<PageItemControl
|
|
|
page={pageData}
|
|
|
onClickDeleteButton={props.onClickDeleteButton}
|
|
|
@@ -94,13 +105,13 @@ const SearchResultListItem: FC<Props> = memo((props:Props) => {
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div className="my-2 search-result-list-snippet">
|
|
|
+ <div className="search-result-list-snippet py-1">
|
|
|
<Clamp lines={2}>
|
|
|
{
|
|
|
pageMeta.elasticSearchResult != null && pageMeta.elasticSearchResult?.snippet.length !== 0 ? (
|
|
|
- <div className="mt-1" dangerouslySetInnerHTML={{ __html: pageMeta.elasticSearchResult.snippet }}></div>
|
|
|
+ <div dangerouslySetInnerHTML={{ __html: pageMeta.elasticSearchResult.snippet }}></div>
|
|
|
) : (
|
|
|
- <div className="mt-1">{ shortBody != null ? shortBody : 'Loading ...' }</div> // TODO: improve indicator
|
|
|
+ <div>{ shortBody != null ? shortBody : 'Loading ...' }</div> // TODO: improve indicator
|
|
|
)
|
|
|
}
|
|
|
</Clamp>
|