Yuki Takei 3 лет назад
Родитель
Сommit
b53ee0fe9c

+ 56 - 0
packages/app/src/components/Navbar/GlobalSearch.scss

@@ -0,0 +1,56 @@
+@use '~/styles/bootstrap/init' as bs;
+
+// input styles
+.grw-global-search {
+  .dropdown-toggle {
+    min-width: 95px;
+    padding-left: 1.5rem;
+  }
+
+  .search-typeahead {
+    .rbt-menu {
+      right: 0;
+      left: auto;
+
+      @include bs.media-breakpoint-up(md) {
+        right: auto;
+        left: 0;
+      }
+
+      @include bs.media-breakpoint-down(sm) {
+        left: auto !important;
+        width: 90vw;
+      }
+    }
+  }
+
+  // using react-bootstrap-typeahead
+  // see: https://github.com/ericgio/react-bootstrap-typeahead
+  .rbt-input.form-control {
+    height: 30px;
+    .rbt-input-wrapper {
+      margin-left: 8px;
+    }
+  }
+
+  .form-group:not(.has-error) {
+    .rbt-input.form-control {
+      border: none;
+    }
+  }
+
+  .grw-shortcut-key-indicator {
+    position: absolute;
+    top: 0;
+    right: 4px;
+
+    display: flex;
+    align-items: center;
+    height: 30px;
+
+    code {
+      padding-right: 0.4rem;
+      padding-left: 0.4rem;
+    }
+  }
+}

+ 4 - 3
packages/app/src/components/Navbar/GlobalSearch.tsx

@@ -1,6 +1,4 @@
-import React, {
-  FC, useState, useCallback, useRef,
-} from 'react';
+import React, { useState, useCallback, useRef } from 'react';
 
 
 import assert from 'assert';
 import assert from 'assert';
 
 
@@ -17,6 +15,9 @@ import { useGlobalSearchFormRef } from '~/stores/ui';
 import SearchForm from '../SearchForm';
 import SearchForm from '../SearchForm';
 
 
 
 
+import './GlobalSearch.scss';
+
+
 type Props = {
 type Props = {
   dropup?: boolean,
   dropup?: boolean,
 }
 }

+ 36 - 0
packages/app/src/components/Navbar/GrowiNavbar.scss

@@ -88,6 +88,42 @@
   }
   }
 }
 }
 
 
+// layout for GlobalSearch
+.grw-global-search-top {
+  // centering on navbar
+  top: var.$grw-navbar-height / 2;
+  left: 50vw;
+  z-index: bs.$zindex-fixed + 1;
+  transform: translate(-50%, -50%);
+
+  .rbt-input.form-control {
+    width: 200px;
+    transition: 0.3s ease-out;
+
+    // focus
+    &.focus {
+      width: 300px;
+    }
+
+    @include bs.media-breakpoint-up(md) {
+      width: 300px;
+    }
+    @include bs.media-breakpoint-up(lg) {
+      // focus
+      &.focus {
+        width: 400px;
+      }
+    }
+    @include bs.media-breakpoint-up(xl) {
+      width: 350px;
+      // focus
+      &.focus {
+        width: 450px;
+      }
+    }
+  }
+}
+
 .grw-notification-badge {
 .grw-notification-badge {
   position: absolute;
   position: absolute;
   top: 6px;
   top: 6px;

+ 3 - 1
packages/app/src/components/Navbar/GrowiNavbar.tsx

@@ -129,6 +129,8 @@ Confidential.displayName = 'Confidential';
 
 
 export const GrowiNavbar = (): JSX.Element => {
 export const GrowiNavbar = (): JSX.Element => {
 
 
+  const GlobalSearch = dynamic(() => import('./GlobalSearch').then(mod => mod.GlobalSearch), { ssr: false });
+
   const { data: appTitle } = useAppTitle();
   const { data: appTitle } = useAppTitle();
   const { data: confidential } = useConfidential();
   const { data: confidential } = useConfidential();
   const { data: isSearchServiceConfigured } = useIsSearchServiceConfigured();
   const { data: isSearchServiceConfigured } = useIsSearchServiceConfigured();
@@ -157,7 +159,7 @@ export const GrowiNavbar = (): JSX.Element => {
 
 
       { isSearchServiceConfigured && !isDeviceSmallerThanMd && !isSearchPage && (
       { isSearchServiceConfigured && !isDeviceSmallerThanMd && !isSearchPage && (
         <div className="grw-global-search grw-global-search-top position-absolute">
         <div className="grw-global-search grw-global-search-top position-absolute">
-          {/* <GlobalSearch /> */}
+          <GlobalSearch />
         </div>
         </div>
       ) }
       ) }
     </nav>
     </nav>

+ 44 - 0
packages/app/src/components/SearchTypeahead.scss

@@ -0,0 +1,44 @@
+@use '~/styles/bootstrap/init' as bs;
+
+.search-typeahead {
+  position: relative;
+  width: 100%;
+  // corner radius
+  border-top-right-radius: bs.$border-radius;
+  border-bottom-right-radius: bs.$border-radius;
+  .rbt-input-main {
+    padding-right: 36px;
+  }
+  .search-clear {
+    position: absolute;
+    top: 4px;
+    right: 4px;
+    z-index: 3;
+    width: 24px;
+    height: 24px;
+    padding: 0;
+    line-height: 0;
+  }
+
+  .rbt-menu {
+    max-height: none !important;
+    margin-top: 3px;
+
+    li a span {
+      .page-path {
+        display: inline;
+        padding: 0 4px;
+        color: inherit;
+      }
+
+      .page-list-meta {
+        font-size: 0.9em;
+        color: bs.$gray-400;
+
+        > span {
+          margin-right: 0.3rem;
+        }
+      }
+    }
+  }
+}

+ 5 - 3
packages/app/src/components/SearchTypeahead.tsx

@@ -3,17 +3,19 @@ import React, {
   KeyboardEvent, useCallback, useRef, useState, MouseEvent, useEffect,
   KeyboardEvent, useCallback, useRef, useState, MouseEvent, useEffect,
 } from 'react';
 } from 'react';
 
 
-import { AsyncTypeahead, Menu, MenuItem } from 'react-bootstrap-typeahead';
-
 import { UserPicture, PageListMeta, PagePathLabel } from '@growi/ui';
 import { UserPicture, PageListMeta, PagePathLabel } from '@growi/ui';
+import { AsyncTypeahead, Menu, MenuItem } from 'react-bootstrap-typeahead';
 
 
 import { IFocusable } from '~/client/interfaces/focusable';
 import { IFocusable } from '~/client/interfaces/focusable';
 import { TypeaheadProps } from '~/client/interfaces/react-bootstrap-typeahead';
 import { TypeaheadProps } from '~/client/interfaces/react-bootstrap-typeahead';
-import { IPageSearchMeta } from '~/interfaces/search';
 import { IPageWithMeta } from '~/interfaces/page';
 import { IPageWithMeta } from '~/interfaces/page';
+import { IPageSearchMeta } from '~/interfaces/search';
 import { useSWRxSearch } from '~/stores/search';
 import { useSWRxSearch } from '~/stores/search';
 
 
 
 
+import './SearchTypeahead.scss';
+
+
 type ResetFormButtonProps = {
 type ResetFormButtonProps = {
   input?: string,
   input?: string,
   onReset: (e: MouseEvent<HTMLButtonElement>) => void,
   onReset: (e: MouseEvent<HTMLButtonElement>) => void,

+ 0 - 128
packages/app/src/styles/_search.scss

@@ -1,46 +1,3 @@
-.search-typeahead {
-  position: relative;
-  width: 100%;
-  // corner radius
-  border-top-right-radius: $border-radius;
-  border-bottom-right-radius: $border-radius;
-  .rbt-input-main {
-    padding-right: 36px;
-  }
-  .search-clear {
-    position: absolute;
-    top: 4px;
-    right: 4px;
-    z-index: 3;
-    width: 24px;
-    height: 24px;
-    padding: 0;
-    line-height: 0;
-  }
-
-  .rbt-menu {
-    max-height: none !important;
-    margin-top: 3px;
-
-    li a span {
-      .page-path {
-        display: inline;
-        padding: 0 4px;
-        color: inherit;
-      }
-
-      .page-list-meta {
-        font-size: 0.9em;
-        color: $gray-400;
-
-        > span {
-          margin-right: 0.3rem;
-        }
-      }
-    }
-  }
-}
-
 // styles for admin user search
 // styles for admin user search
 .admin-user-page {
 .admin-user-page {
   .search-typeahead {
   .search-typeahead {
@@ -51,91 +8,6 @@
   }
   }
 }
 }
 
 
-// input styles
-.grw-global-search {
-  .dropdown-toggle {
-    min-width: 95px;
-    padding-left: 1.5rem;
-  }
-
-  .search-typeahead {
-    .rbt-menu {
-      @extend .dropdown-menu-right;
-      @extend .dropdown-menu-md-left;
-      @include media-breakpoint-down(sm) {
-        left: auto !important;
-        width: 90vw;
-      }
-    }
-  }
-
-  // using react-bootstrap-typeahead
-  // see: https://github.com/ericgio/react-bootstrap-typeahead
-  .rbt-input.form-control {
-    height: 30px;
-    .rbt-input-wrapper {
-      margin-left: 8px;
-    }
-  }
-
-  .form-group:not(.has-error) {
-    .rbt-input.form-control {
-      border: none;
-    }
-  }
-
-  .grw-shortcut-key-indicator {
-    position: absolute;
-    top: 0;
-    right: 4px;
-
-    display: flex;
-    align-items: center;
-    height: 30px;
-
-    code {
-      padding-right: 0.4rem;
-      padding-left: 0.4rem;
-    }
-  }
-}
-
-// layout for GlobalSearch
-.grw-global-search-top {
-  // centering on navbar
-  top: $grw-navbar-height / 2;
-  left: 50vw;
-  z-index: $zindex-fixed + 1;
-  transform: translate(-50%, -50%);
-
-  .rbt-input.form-control {
-    width: 200px;
-    transition: 0.3s ease-out;
-
-    // focus
-    &.focus {
-      width: 300px;
-    }
-
-    @include media-breakpoint-up(md) {
-      width: 300px;
-    }
-    @include media-breakpoint-up(lg) {
-      // focus
-      &.focus {
-        width: 400px;
-      }
-    }
-    @include media-breakpoint-up(xl) {
-      width: 350px;
-      // focus
-      &.focus {
-        width: 450px;
-      }
-    }
-  }
-}
-
 // layout
 // layout
 .on-search {
 .on-search {
   .page-wrapper {
   .page-wrapper {