Skip to content

Commit

Permalink
Merge pull request #8200 from weseek/imprv/responsive-layout
Browse files Browse the repository at this point in the history
imprv: Responsive layout
  • Loading branch information
yuki-takei authored Oct 30, 2023
2 parents 2cc2715 + 363a3f2 commit 719f6b3
Show file tree
Hide file tree
Showing 44 changed files with 419 additions and 249 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@use '@growi/ui/src/styles/molecules/page_list';
@use '@growi/ui/scss/molecules/page_list';

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@use '@growi/core/scss/bootstrap/init' as bs;

@use '@growi/ui/scss/atoms/btn-muted';

@use '~/styles/variables' as var;


.grw-drawer-toggler :global {
.btn {
--bs-btn-color: rgba(var(--bs-tertiary-color-rgb), 0.5);
--bs-btn-bg: transparent;

--bs-btn-hover-color: rgba(var(--bs-tertiary-color-rgb), 0.7);

width: var.$grw-sidebar-nav-width;
height: var.$grw-sidebar-nav-width;
}
}
36 changes: 36 additions & 0 deletions apps/app/src/components/Common/DrawerToggler/DrawerToggler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { type ReactNode } from 'react';

import { useDrawerOpened } from '~/stores/ui';


import styles from './DrawerToggler.module.scss';

const moduleClass = styles['grw-drawer-toggler'];


type Props = {
className?: string,
children?: ReactNode,
}

export const DrawerToggler = (props: Props): JSX.Element => {

const { className, children } = props;

const { data: isOpened, mutate } = useDrawerOpened();

return (
<div className={`${moduleClass} ${className ?? ''}`}>
<button
className="btn d-flex align-items-center border-0"
type="button"
aria-expanded="false"
aria-label="Toggle navigation"
onClick={() => mutate(!isOpened)}
>
{children}
</button>
</div>
);

};
1 change: 1 addition & 0 deletions apps/app/src/components/Common/DrawerToggler/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './DrawerToggler';
7 changes: 1 addition & 6 deletions apps/app/src/components/IdenticalPathPage.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
@use '@growi/ui/src/styles/molecules/page_list';
@use '~/styles/molecules/page-accessories-control';

.grw-page-accessories-control :global {
@extend %grw-page-accessories-control;
}
@use '@growi/ui/scss/molecules/page_list';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC, useImperativeHandle } from 'react';

import type { HasObjectId } from '@growi/core';
import { PagePathLabel } from '@growi/ui/dist/components/PagePath';
import { PagePathLabel } from '@growi/ui/dist/components';

import type { IInAppNotificationOpenable } from '~/client/interfaces/in-app-notification-openable';
import type { IInAppNotification } from '~/interfaces/in-app-notification';
Expand Down
34 changes: 34 additions & 0 deletions apps/app/src/components/Layout/PageViewLayout.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
@use '@growi/core/scss/bootstrap/init' as bs;

@use '~/styles/variables' as var;


.page-view-layout :global {
min-height: calc(100vh - 48px - 250px); // 100vh - subnavigation height - page-comments-row minimum height

.grw-side-contents-container {
margin-bottom: 1rem;

@include bs.media-breakpoint-up(lg) {
width: 250px;
min-width: 250px;
margin-left: 30px;
}
}
}

// md/lg layout padding
.page-view-layout :global {
@include bs.media-breakpoint-between(md, xl) {
padding-left: var.$grw-sidebar-nav-width;
}
}

// sticky side contents
.page-view-layout :global {
.grw-side-contents-sticky-container {
position: sticky;

$subnavigation-height: 50px;
$page-view-layout-margin-top: 32px;
$page-path-nav-height: 99px;
top: calc($subnavigation-height + $page-view-layout-margin-top + $page-path-nav-height + 4px);
}
}
6 changes: 3 additions & 3 deletions apps/app/src/components/Layout/PageViewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ export const PageViewLayout = (props: Props): JSX.Element => {

return (
<>
<div id="main" className={`main page-view-layout ${styles['page-view-layout']}`}>
<div id="main" className={`main ${styles['page-view-layout']}`}>
<div id="content-main" className="content-main container-lg grw-container-convertible">
{ headerContents != null && headerContents }
{ sideContents != null
? (
<div className="d-flex flex-column flex-column-reverse flex-lg-row">
<div className="d-flex gap-3">
<div className="flex-grow-1 flex-basis-0 mw-0">
{children}
</div>
<div className="grw-side-contents-container d-edit-none" data-vrt-blackout-side-contents>
<div className="grw-side-contents-container col-lg-3 d-edit-none" data-vrt-blackout-side-contents>
<div className="grw-side-contents-sticky-container">
{sideContents}
</div>
Expand Down
31 changes: 0 additions & 31 deletions apps/app/src/components/Navbar/DrawerToggler.tsx

This file was deleted.

35 changes: 17 additions & 18 deletions apps/app/src/components/Navbar/GrowiContextualSubNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,24 +335,23 @@ const GrowiContextualSubNavigation = (props: GrowiContextualSubNavigationProps):
`}
data-testid="grw-contextual-sub-nav"
>
<div className="h-50">
{pageId != null && (
<PageControls
pageId={pageId}
revisionId={revisionId}
shareLinkId={shareLinkId}
path={path ?? currentPathname} // If the page is empty, "path" is undefined
expandContentWidth={currentPage?.expandContentWidth ?? isContainerFluid}
disableSeenUserInfoPopover={isSharedUser}
showPageControlDropdown={isAbleToShowPageManagement}
additionalMenuItemRenderer={additionalMenuItemsRenderer}
onClickDuplicateMenuItem={duplicateItemClickedHandler}
onClickRenameMenuItem={renameItemClickedHandler}
onClickDeleteMenuItem={deleteItemClickedHandler}
onClickSwitchContentWidth={switchContentWidthHandler}
/>
)}
</div>
{pageId != null && (
<PageControls
pageId={pageId}
revisionId={revisionId}
shareLinkId={shareLinkId}
path={path ?? currentPathname} // If the page is empty, "path" is undefined
expandContentWidth={currentPage?.expandContentWidth ?? isContainerFluid}
disableSeenUserInfoPopover={isSharedUser}
showPageControlDropdown={isAbleToShowPageManagement}
additionalMenuItemRenderer={additionalMenuItemsRenderer}
onClickDuplicateMenuItem={duplicateItemClickedHandler}
onClickRenameMenuItem={renameItemClickedHandler}
onClickDeleteMenuItem={deleteItemClickedHandler}
onClickSwitchContentWidth={switchContentWidthHandler}
/>
)}

{isAbleToChangeEditorMode && (
<PageEditorModeManager
editorMode={editorMode}
Expand Down
15 changes: 15 additions & 0 deletions apps/app/src/components/Navbar/GrowiNavbarBottom.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@
bottom: #{-1 * var.$grw-navbar-bottom-height};
}
}


// centering icons
.grw-navbar-bottom :global {
.nav-link {
display: flex;
align-items: center;
}
}

// == Colors
.grw-navbar-bottom {
background-color: rgba(var(--bs-body-bg-rgb), 0.7);
backdrop-filter: blur(35px);
}
37 changes: 25 additions & 12 deletions apps/app/src/components/Navbar/GrowiNavbarBottom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { useIsSearchPage } from '~/stores/context';
import { usePageCreateModal } from '~/stores/modal';
import { useCurrentPagePath } from '~/stores/page';
import { useIsDeviceSmallerThanMd, useDrawerOpened } from '~/stores/ui';
import { useIsDeviceLargerThanMd, useDrawerOpened } from '~/stores/ui';

import { GlobalSearch } from './GlobalSearch';

Expand All @@ -13,39 +13,50 @@ import styles from './GrowiNavbarBottom.module.scss';
export const GrowiNavbarBottom = (): JSX.Element => {

const { data: isDrawerOpened, mutate: mutateDrawerOpened } = useDrawerOpened();
const { data: isDeviceSmallerThanMd } = useIsDeviceSmallerThanMd();
const { data: isDeviceLargerThanMd } = useIsDeviceLargerThanMd();
const { open: openCreateModal } = usePageCreateModal();
const { data: currentPagePath } = useCurrentPagePath();
const { data: isSearchPage } = useIsSearchPage();

const additionalClasses = ['grw-navbar-bottom', styles['grw-navbar-bottom']];
const additionalClasses = [styles['grw-navbar-bottom']];
if (isDrawerOpened) {
additionalClasses.push('grw-navbar-bottom-drawer-opened');
}

return (
<div className="d-md-none d-edit-none fixed-bottom">

{ isDeviceSmallerThanMd && !isSearchPage && (
{ !isDeviceLargerThanMd && !isSearchPage && (
<div id="grw-global-search-collapse" className="grw-global-search collapse bg-dark">
<div className="p-3">
<GlobalSearch dropup />
</div>
</div>
) }

<div className={`navbar navbar-expand navbar-dark bg-primary px-0 ${additionalClasses.join(' ')}`}>
<div className={`navbar navbar-expand px-4 px-sm-5 ${additionalClasses.join(' ')}`}>

<ul className="navbar-nav w-100">
<li className="nav-item me-auto">
<ul className="navbar-nav flex-grow-1 d-flex align-items-center justify-content-between">
<li className="nav-item">
<a
role="button"
className="nav-link btn-lg"
onClick={() => mutateDrawerOpened(true)}
>
<i className="icon-menu"></i>
<span className="material-symbols-outlined fs-2">reorder</span>
</a>
</li>

<li className="nav-item">
<a
role="button"
className="nav-link btn-lg"
onClick={() => openCreateModal(currentPagePath || '')}
>
<span className="material-symbols-outlined fs-2">edit</span>
</a>
</li>

{
!isSearchPage && (
<li className="nav-item">
Expand All @@ -55,20 +66,22 @@ export const GrowiNavbarBottom = (): JSX.Element => {
data-bs-target="#grw-global-search-collapse"
data-bs-toggle="collapse"
>
<i className="icon-magnifier"></i>
<span className="material-symbols-outlined fs-2">search</span>
</a>
</li>
)
}
<li className="nav-item ms-auto">

<li className="nav-item">
<a
role="button"
className="nav-link btn-lg"
onClick={() => openCreateModal(currentPagePath || '')}
onClick={() => {}}
>
<i className="icon-pencil"></i>
<span className="material-symbols-outlined fs-2">notifications</span>
</a>
</li>

</ul>
</div>

Expand Down
21 changes: 11 additions & 10 deletions apps/app/src/components/Navbar/PageEditorModeManager.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
--bs-btn-font-size: 13px;
--bs-btn-border-width: 2px;

width: 70px;
height: 30px;
@include bs.media-breakpoint-down(sm) {
width: 90px;
height: 38px;
width: 90px;
height: 38px;

@include bs.media-breakpoint-up(md) {
width: 70px;
height: 30px;
}

@include mixins.border-vertical('before', 70%, 1, true);
}
}

.grw-page-editor-mode-manager-skeleton :global {
width: 179px;
height: 30px;
@include bs.media-breakpoint-down(sm) {
width: 90px;
height: 38px;
width: 90px;
height: 38px;
@include bs.media-breakpoint-up(md) {
width: 179px;
height: 30px;
}
}

Expand Down
8 changes: 4 additions & 4 deletions apps/app/src/components/Navbar/PageEditorModeManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { type ReactNode, useCallback, useState } from 'react';

import { useTranslation } from 'next-i18next';

import { EditorMode, useIsDeviceSmallerThanMd } from '~/stores/ui';
import { EditorMode, useIsDeviceLargerThanMd } from '~/stores/ui';

import { useOnPageEditorModeButtonClicked } from './hooks';

Expand Down Expand Up @@ -61,7 +61,7 @@ export const PageEditorModeManager = (props: Props): JSX.Element => {
const { t } = useTranslation();
const [isCreating, setIsCreating] = useState(false);

const { data: isDeviceSmallerThanMd } = useIsDeviceSmallerThanMd();
const { data: isDeviceLargerThanMd } = useIsDeviceLargerThanMd();

const onPageEditorModeButtonClicked = useOnPageEditorModeButtonClicked(setIsCreating, path, grant, grantUserGroupId);
const _isBtnDisabled = isCreating || isBtnDisabled;
Expand All @@ -82,7 +82,7 @@ export const PageEditorModeManager = (props: Props): JSX.Element => {
aria-label="page-editor-mode-manager"
id="grw-page-editor-mode-manager"
>
{(!isDeviceSmallerThanMd || editorMode !== EditorMode.View) && (
{(isDeviceLargerThanMd || editorMode !== EditorMode.View) && (
<PageEditorModeButton
currentEditorMode={editorMode}
editorMode={EditorMode.View}
Expand All @@ -92,7 +92,7 @@ export const PageEditorModeManager = (props: Props): JSX.Element => {
<span className="material-symbols-outlined fs-4">play_arrow</span>{t('View')}
</PageEditorModeButton>
)}
{(!isDeviceSmallerThanMd || editorMode === EditorMode.View) && (
{(isDeviceLargerThanMd || editorMode === EditorMode.View) && (
<PageEditorModeButton
currentEditorMode={editorMode}
editorMode={EditorMode.Editor}
Expand Down
Loading

0 comments on commit 719f6b3

Please sign in to comment.