wexond / browser-base

Modern and feature-rich web browser base based on Electron
https://wexond.net
2.68k stars 406 forks source link

Arg. Ok, I need help... #578

Closed ScottWallace closed 3 years ago

ScottWallace commented 3 years ago

I'm looking to add a left-hand sidebar to each newtab, toggle-able globally from a menu.

I started thinking I'd add it to the newtab code, but then it disappears when the user navigates away from the home page.

Then, I tried editing src/renderer/views/app/components/App/index to add it there, with code like this:

        <div style={{ display: 'flex', flexDirection: 'column', flexWrap: 'nowrap', justifyContent: 'flex-start', }}>
          <SideBar />
          <div id='webContent' className='webContent'><p>web content</p></div>
        </div>

with the plan of finding where the webcontent is added, and doing an appendChild to the div with the id webContent.

But, I can't find it. I thought it was just adding the webContent to App by doing an appendChild to it's StyledApp, but I swear, after a full day searching, I can not figure out how the webContent gets inserted here. Arg!

I'd appreciate a hint, or, if I'm plainly going in the wrong direction, I hope you'll let me know. I don't like asking when I'm sure I can figure it out, but my hunt has come to an end and I'm having to turn to you for help.

Help!

ScottWallace commented 3 years ago

Ok, I think I've got something cooking. I made the realization that the view isn't 'placed' in the src/renderer/views/app/components/App/index file, it simply floats above it, according to its own set bounds.

So, I created a new SideBarView (similar to View), and gave its own responsive bounds based on changes by fixBounds in ViewManager. SideBarView is now a property of ViewManager, and is instantiated there. In theory, it should always maintain it's left-affixed location, with the changes in ViewManager's bounds functions to set the location of the View according to whether the SideBarView is visible.

Not quite all the way there yet, but I'm getting closer.

ScottWallace commented 3 years ago

Nope, that wasn't right.

ScottWallace commented 3 years ago

Ok, I figured it out. The SideBar needs to be a styled div, not a View-style object. Once I made it a div, gave it a good flex position, handled the placement of the viewmanager's views to give it space, everything's good.

I was making it harder than it needed to be.