Merge pull request #81 from ragestudio/floating-sidebar

Floating sidebar
This commit is contained in:
srgooglo 2022-11-19 06:06:43 +01:00 committed by GitHub
commit 9fd62e41be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 69 additions and 25 deletions

View File

@ -15,6 +15,7 @@
"postCard_expansible_actions": true,
"feed_max_fetch": 20,
"style.compactMode": false,
"sidebar.floating": false,
"language": "en",
"sidebarKeys": [
"home",

View File

@ -16,6 +16,16 @@ export default [
"experimental": true,
"storaged": true
},
{
"id": "sidebar.floating",
"title": "Floating Sidebar",
"description": "Make the sidebar floats over layout content.",
"component": "Switch",
"icon": "MdOutlineLastPage",
"group": "layout",
"emitEvent": "app.softReload",
"storaged": true
},
{
"id": "reduceAnimations",
"storaged": true,

View File

@ -123,6 +123,15 @@ class App extends React.Component {
window.electron.ipcRenderer.invoke("app.minimize")
}
},
"app.reload": () => {
window.location.reload()
},
"app.softReload": () => {
this.forceUpdate()
app.eventBus.emit("layout.forceUpdate")
app.eventBus.emit("router.forceUpdate")
},
"app.openSearcher": () => {
App.publicMethods.openSearcher()
},

View File

@ -227,6 +227,7 @@ export default class Sidebar extends React.Component {
classnames(
"app_sidebar",
{
["floating"]: window.app?.settings.get("sidebar.floating"),
["collapsed"]: this.state.visible && this.state.collapsed,
["elevated"]: this.state.visible && this.state.elevated,
["hidden"]: !this.state.visible,

View File

@ -25,6 +25,10 @@
border-radius: 0 @app_sidebar_borderRadius @app_sidebar_borderRadius 0;
border: 1px solid var(--sidebar-background-color);
&.floating {
position: absolute;
}
&.collapsed {
width: 80px;
min-width: 80px;

View File

@ -224,7 +224,12 @@ export default class SidedrawerController extends React.Component {
render() {
return <div
className="sidedrawers-wrapper"
className={classnames(
"sidedrawers-wrapper",
{
["floating-sidebar"]: window.app?.settings.get("sidebar.floating")
}
)}
>
{this.state.drawers}
</div>

View File

@ -3,6 +3,12 @@
.sidedrawers-wrapper {
display: flex;
flex-direction: row;
&.floating-sidebar {
z-index: 950;
position: absolute;
margin-left: @app_sidebar_collapsed_width;
}
.sidedrawer {
position: relative;

View File

@ -49,6 +49,7 @@
margin: 0;
font-family: "DM Mono", monospace;
align-self: start;
font-size: 1rem;
cursor: pointer;
}

View File

@ -91,6 +91,10 @@ const SettingItem = (props) => {
}
}
if (item.storaged) {
await window.app.settings.set(item.id, updateValue)
}
if (typeof item.emitEvent === "string") {
let emissionPayload = updateValue
@ -105,10 +109,6 @@ const SettingItem = (props) => {
return false
}
if (item.storaged) {
await window.app.settings.set(item.id, updateValue)
}
if (item.debounced) {
setDelayedValue(null)
}

View File

@ -25,6 +25,9 @@ export default class Layout extends React.PureComponent {
"app.initialization.finish": () => {
app.eventBus.emit("layout.render.unlock")
},
"layout.forceUpdate": () => {
this.forceUpdate()
},
"layout.render.lock": () => {
this.setState({
renderLock: true,

View File

@ -12,13 +12,18 @@ export default (props) => {
<Drawer />
<Sidebar user={props.user} />
<Sidedrawer />
<Layout className="content_layout">
<Layout.Content className={classnames("layout_page", ...props.layoutPageModesClassnames ?? [])}>
<div id="transitionLayer" className="fade-transverse-active">
{React.cloneElement(props.children, props)}
</div>
</Layout.Content>
</Layout>
<Layout.Content className={
classnames(
"content_layout",
...props.contentClassnames ?? [],
{
["floating-sidebar"]: window.app?.settings.get("sidebar.floating")
}
)}>
<div id="transitionLayer" className="fade-transverse-active">
{React.cloneElement(props.children, props)}
</div>
</Layout.Content>
</Layout>
</>
}
}

View File

@ -160,30 +160,29 @@ html {
}
}
.ant-layout,
.content_layout {
width: 100%;
height: 100%;
max-height: 100vh;
background-color: transparent;
}
.layout_page {
position: relative;
-webkit-overflow-scrolling: touch;
height: 100%;
width: 100%;
max-height: 100vh;
padding: 10px;
overflow-x: hidden;
overflow-y: overlay;
transition: all 150ms ease-in-out;
margin: var(--layoutMargin);
padding: var(--layoutPadding);
background-color: transparent;
&.floating-sidebar {
margin-left: @app_sidebar_collapsed_width;
}
}
.app_background_decorator {