Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
595dbdb0
Unverified
Commit
595dbdb0
authored
Mar 06, 2023
by
boojack
Committed by
GitHub
Mar 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add root layout (#1294)
parent
003161ea
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
59 deletions
+69
-59
Root.tsx
web/src/layouts/Root.tsx
+21
-0
home-sidebar.less
web/src/less/home-sidebar.less
+1
-1
home.less
web/src/less/home.less
+0
-23
Home.tsx
web/src/pages/Home.tsx
+10
-19
index.tsx
web/src/router/index.tsx
+23
-16
yarn.lock
web/yarn.lock
+14
-0
No files found.
web/src/layouts/Root.tsx
0 → 100644
View file @
595dbdb0
import
{
Outlet
}
from
"react-router-dom"
;
import
Header
from
"../components/Header"
;
import
UpdateVersionBanner
from
"../components/UpdateVersionBanner"
;
function
Root
()
{
return
(
<
section
className=
"w-full h-full overflow-y-auto bg-zinc-100 dark:bg-zinc-800"
>
<
div
className=
"w-full flex flex-col justify-start items-center"
>
<
UpdateVersionBanner
/>
</
div
>
<
div
className=
"grid grid-cols-1 sm:grid-cols-[14rem_1fr] relative w-full max-w-6xl h-full mx-auto"
>
<
Header
/>
<
main
className=
"relative w-full h-auto flex flex-col justify-start items-start"
>
<
Outlet
/>
</
main
>
</
div
>
</
section
>
);
}
export
default
Root
;
web/src/less/home-sidebar.less
View file @
595dbdb0
.home-sidebar-wrapper {
.home-sidebar-wrapper {
@apply flex-shrink-0 fixed sm:sticky top-0 z-30 sm:z-0 translate-x-56 sm:translate-x-0 hidden md:flex flex-col justify-start items-start w-56
md:mr-2 h-full py-4
bg-white dark:bg-zinc-800 sm:bg-transparent overflow-x-hidden overflow-y-auto transition-transform duration-300 overscroll-contain hide-scrollbar;
@apply flex-shrink-0 fixed sm:sticky top-0 z-30 sm:z-0 translate-x-56 sm:translate-x-0 hidden md:flex flex-col justify-start items-start w-56
py-4 pr-2 md:mr-2 h-full
bg-white dark:bg-zinc-800 sm:bg-transparent overflow-x-hidden overflow-y-auto transition-transform duration-300 overscroll-contain hide-scrollbar;
&.show {
&.show {
@apply flex translate-x-0 right-0 shadow-2xl sm:shadow-none;
@apply flex translate-x-0 right-0 shadow-2xl sm:shadow-none;
...
...
web/src/less/home.less
deleted
100644 → 0
View file @
003161ea
.page-wrapper.home {
@apply w-full h-full overflow-y-auto bg-zinc-100 dark:bg-zinc-800;
> .banner-wrapper {
@apply w-full flex flex-col justify-start items-center;
}
> .page-container {
@apply relative w-full h-auto mx-auto flex flex-row justify-start sm:justify-center items-start;
> .header-wrapper {
@apply flex-shrink-0 h-full;
}
> .memos-wrapper {
@apply relative flex-grow max-w-2xl w-full h-auto flex flex-col justify-start items-start px-4 sm:px-2 sm:pt-4;
> .memos-editor-wrapper {
@apply w-full h-auto flex flex-col justify-start items-start bg-zinc-100 dark:bg-zinc-800 rounded-lg;
}
}
}
}
web/src/pages/Home.tsx
View file @
595dbdb0
...
@@ -3,14 +3,11 @@ import { useTranslation } from "react-i18next";
...
@@ -3,14 +3,11 @@ import { useTranslation } from "react-i18next";
import
{
useLocation
}
from
"react-router-dom"
;
import
{
useLocation
}
from
"react-router-dom"
;
import
{
useGlobalStore
,
useUserStore
}
from
"../store/module"
;
import
{
useGlobalStore
,
useUserStore
}
from
"../store/module"
;
import
toastHelper
from
"../components/Toast"
;
import
toastHelper
from
"../components/Toast"
;
import
Header
from
"../components/Header"
;
import
MemoEditor
from
"../components/MemoEditor"
;
import
MemoEditor
from
"../components/MemoEditor"
;
import
MemoFilter
from
"../components/MemoFilter"
;
import
MemoFilter
from
"../components/MemoFilter"
;
import
MemoList
from
"../components/MemoList"
;
import
MemoList
from
"../components/MemoList"
;
import
UpdateVersionBanner
from
"../components/UpdateVersionBanner"
;
import
MobileHeader
from
"../components/MobileHeader"
;
import
MobileHeader
from
"../components/MobileHeader"
;
import
HomeSidebar
from
"../components/HomeSidebar"
;
import
HomeSidebar
from
"../components/HomeSidebar"
;
import
"../less/home.less"
;
function
Home
()
{
function
Home
()
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
...
@@ -36,23 +33,17 @@ function Home() {
...
@@ -36,23 +33,17 @@ function Home() {
},
[
user
?.
setting
.
locale
]);
},
[
user
?.
setting
.
locale
]);
return
(
return
(
<
section
className=
"page-wrapper home"
>
<
div
className=
"relative w-full min-h-full flex flex-row justify-start items-start"
>
<
div
className=
"banner-wrapper"
>
<
div
className=
"flex-grow w-auto max-w-2xl px-4 sm:px-2 sm:pt-4"
>
<
UpdateVersionBanner
/>
<
MobileHeader
/>
<
div
className=
"w-full h-auto flex flex-col justify-start items-start bg-zinc-100 dark:bg-zinc-800 rounded-lg"
>
{
!
userStore
.
isVisitorMode
()
&&
<
MemoEditor
/>
}
<
MemoFilter
/>
</
div
>
<
MemoList
/>
</
div
>
</
div
>
<
div
className=
"page-container"
>
{
!
userStore
.
isVisitorMode
()
&&
<
HomeSidebar
/>
}
<
Header
/>
</
div
>
<
main
className=
"memos-wrapper"
>
<
MobileHeader
/>
<
div
className=
"memos-editor-wrapper"
>
{
!
userStore
.
isVisitorMode
()
&&
<
MemoEditor
/>
}
<
MemoFilter
/>
</
div
>
<
MemoList
/>
</
main
>
{
!
userStore
.
isVisitorMode
()
&&
<
HomeSidebar
/>
}
</
div
>
</
section
>
);
);
}
}
...
...
web/src/router/index.tsx
View file @
595dbdb0
...
@@ -4,6 +4,7 @@ import { isNullorUndefined } from "../helpers/utils";
...
@@ -4,6 +4,7 @@ import { isNullorUndefined } from "../helpers/utils";
import
store
from
"../store"
;
import
store
from
"../store"
;
import
{
initialGlobalState
,
initialUserState
}
from
"../store/module"
;
import
{
initialGlobalState
,
initialUserState
}
from
"../store/module"
;
const
Root
=
lazy
(()
=>
import
(
"../layouts/Root"
));
const
Auth
=
lazy
(()
=>
import
(
"../pages/Auth"
));
const
Auth
=
lazy
(()
=>
import
(
"../pages/Auth"
));
const
AuthCallback
=
lazy
(()
=>
import
(
"../pages/AuthCallback"
));
const
AuthCallback
=
lazy
(()
=>
import
(
"../pages/AuthCallback"
));
const
Explore
=
lazy
(()
=>
import
(
"../pages/Explore"
));
const
Explore
=
lazy
(()
=>
import
(
"../pages/Explore"
));
...
@@ -43,24 +44,30 @@ const router = createBrowserRouter([
...
@@ -43,24 +44,30 @@ const router = createBrowserRouter([
},
},
{
{
path
:
"/"
,
path
:
"/"
,
element
:
<
Home
/>,
element
:
<
Root
/>,
loader
:
async
()
=>
{
children
:
[
await
initialGlobalStateLoader
();
{
path
:
""
,
element
:
<
Home
/>,
loader
:
async
()
=>
{
await
initialGlobalStateLoader
();
try
{
try
{
await
initialUserState
();
await
initialUserState
();
}
catch
(
error
)
{
}
catch
(
error
)
{
// do nth
// do nth
}
}
const
{
host
,
user
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
if
(
isNullorUndefined
(
host
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
else
if
(
isNullorUndefined
(
user
))
{
}
else
if
(
isNullorUndefined
(
user
))
{
return
redirect
(
"/explore"
);
return
redirect
(
"/explore"
);
}
}
return
null
;
return
null
;
},
},
},
],
},
},
{
{
path
:
"/u/:userId"
,
path
:
"/u/:userId"
,
...
...
web/yarn.lock
View file @
595dbdb0
...
@@ -54,6 +54,13 @@
...
@@ -54,6 +54,13 @@
dependencies:
dependencies:
regenerator-runtime "^0.13.11"
regenerator-runtime "^0.13.11"
"@babel/runtime@^7.19.4":
version "7.21.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673"
integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==
dependencies:
regenerator-runtime "^0.13.11"
"@babel/types@^7.18.6":
"@babel/types@^7.18.6":
version "7.20.7"
version "7.20.7"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.7.tgz#54ec75e252318423fc07fb644dc6a58a64c09b7f"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.7.tgz#54ec75e252318423fc07fb644dc6a58a64c09b7f"
...
@@ -1703,6 +1710,13 @@ html-parse-stringify@^3.0.1:
...
@@ -1703,6 +1710,13 @@ html-parse-stringify@^3.0.1:
dependencies:
dependencies:
void-elements "3.1.0"
void-elements "3.1.0"
i18next-browser-languagedetector@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/i18next-browser-languagedetector/-/i18next-browser-languagedetector-7.0.1.tgz#ead34592edc96c6c3a618a51cb57ad027c5b5d87"
integrity sha512-Pa5kFwaczXJAeHE56CHG2aWzFBMJNUNghf0Pm4SwSrEMps/PTKqW90EYWlIvhuYStf3Sn1K0vw+gH3+TLdkH1g==
dependencies:
"@babel/runtime" "^7.19.4"
i18next@^21.9.2:
i18next@^21.9.2:
version "21.10.0"
version "21.10.0"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.10.0.tgz#85429af55fdca4858345d0e16b584ec29520197d"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.10.0.tgz#85429af55fdca4858345d0e16b584ec29520197d"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment