-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(flat-pages): change fold button to sidebar handle (#1922)
- Loading branch information
Showing
6 changed files
with
158 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/flat-pages/src/components/SidebarHandle/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import "./style.less"; | ||
|
||
import React from "react"; | ||
import { observer } from "mobx-react-lite"; | ||
|
||
import { ClassroomStore } from "@netless/flat-stores"; | ||
|
||
export interface SidebarHandleProps { | ||
classroom: ClassroomStore; | ||
} | ||
|
||
export const SidebarHandler = observer<SidebarHandleProps>(function SidebarHandle({ classroom }) { | ||
const whiteboard = classroom.whiteboardStore; | ||
|
||
const collapsed = whiteboard.isRightSideClose; | ||
|
||
return ( | ||
<label className="sidebar-handler"> | ||
<input | ||
checked={collapsed} | ||
type="checkbox" | ||
onChange={() => whiteboard.setRightSideClose(!collapsed)} | ||
/> | ||
<svg fill="none" height="42" viewBox="0 0 17 42" width="17"> | ||
<path | ||
className="sidebar-handler-border-color sidebar-handler-bg-color" | ||
d="M17.0 41.0H5.0C2.7909 41.0 1.0 39.2091 1.0 37.0V5.0C1.0 2.79086 2.7909 1.0 5.0 1.0H17.0" | ||
fill="#fff" | ||
stroke="#000" | ||
/> | ||
{collapsed ? ( | ||
<path | ||
className="sidebar-handler-image-fill-color" | ||
clipRule="evenodd" | ||
d="M8 19L10 17V25L8 23L6 21L8 19ZM12 17H11V25H12V17Z" | ||
fill="#fff" | ||
fillRule="evenodd" | ||
/> | ||
) : ( | ||
<path | ||
className="sidebar-handler-image-fill-color" | ||
clipRule="evenodd" | ||
d="M10 19L8 17V25L10 23L12 21L10 19ZM6 17H7V25H6V17Z" | ||
fill="#fff" | ||
fillRule="evenodd" | ||
/> | ||
)} | ||
</svg> | ||
</label> | ||
); | ||
}); |
81 changes: 81 additions & 0 deletions
81
packages/flat-pages/src/components/SidebarHandle/style.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
.sidebar-handler { | ||
appearance: none; | ||
border: 0; | ||
width: 17px; | ||
position: absolute; | ||
right: 100%; | ||
top: 50%; | ||
transform: translate(0, -50%); | ||
font-size: 0; | ||
z-index: 100; | ||
cursor: pointer; | ||
pointer-events: auto; | ||
|
||
input[type="checkbox"] { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
appearance: none; | ||
margin: 0; | ||
width: 100%; | ||
height: 100%; | ||
cursor: pointer; | ||
opacity: 0; | ||
z-index: -1; | ||
} | ||
|
||
svg { | ||
opacity: 0; | ||
transition: opacity 0.5s 1s; | ||
pointer-events: none; | ||
} | ||
|
||
&:focus-visible { | ||
outline: 2px solid -webkit-focus-ring-color; | ||
} | ||
|
||
&:hover svg, | ||
&.collapsed svg { | ||
opacity: 1; | ||
transition: opacity 0.2s; | ||
} | ||
} | ||
|
||
.sidebar-handler-bg-color { | ||
fill: #ffffff; | ||
} | ||
|
||
.sidebar-handler-border-color { | ||
stroke: var(--grey-1); | ||
} | ||
|
||
.sidebar-handler-image-stroke-color { | ||
stroke: var(--grey-6); | ||
} | ||
|
||
.sidebar-handler-image-fill-color { | ||
fill: var(--grey-6); | ||
} | ||
|
||
.realtime-panel:hover+.sidebar-handler svg { | ||
opacity: 1; | ||
transition: opacity 0.2s; | ||
} | ||
|
||
.flat-color-scheme-dark { | ||
.sidebar-handler-bg-color { | ||
fill: var(--grey-9); | ||
} | ||
|
||
.sidebar-handler-border-color { | ||
stroke: var(--grey-8); | ||
} | ||
|
||
.sidebar-handler-image-stroke-color { | ||
stroke: var(--grey-5); | ||
} | ||
|
||
.sidebar-handler-image-fill-color { | ||
fill: var(--grey-5); | ||
} | ||
} |