added fullscreen button for notes and snippets#602
added fullscreen button for notes and snippets#602nadr0 wants to merge 14 commits intoBoostIO:masterfrom nadr0:master
Conversation
| const noteDetail = document.querySelector(".NoteDetail") | ||
| const mainBody = document.querySelector(".Main__body___browser-main-") | ||
| const sliderRight = document.querySelector(".Main__slider-right___browser-main-") | ||
| const slider = document.querySelector(".Main__slider___browser-main-") |
There was a problem hiding this comment.
Those class names such as .Main__slider___browser-main- depends on the specification of webpack, so could you name any other one to them?
There was a problem hiding this comment.
I had to give them Ids because they don't have any other classes on them
| status: false, | ||
| oldState: { | ||
| nd : 0, | ||
| mb : 0 |
There was a problem hiding this comment.
Could you change the names? It's hard to understand.
There was a problem hiding this comment.
You can simply change to them.
fullScreen: false,
widthOfNoteDetail: 0,
widthOfMainBody: 0
| <button styleName='control-fullScreenButton' | ||
| onMouseDown={(e) => this.handleFullScreenButton(e)} | ||
| > | ||
| <i className={'fa fa-arrows-alt'} styleName='fullScreen-button' /> |
There was a problem hiding this comment.
Probably, you can simply use 'fa fa-arrows-alt'.
There was a problem hiding this comment.
err, you still have to leave the fa in the front.
There was a problem hiding this comment.
Sorry, could you explain the reason more clearly? It works fine at least in my environment (MacOS).
There was a problem hiding this comment.
haha totally tunnel visioned what you said and didn't realize you mean take off the {}
There was a problem hiding this comment.
you mean take off the {}
Yes 🙋♀️
| status: false, | ||
| oldState: { | ||
| nd : 0, | ||
| mb : 0 |
There was a problem hiding this comment.
You can simply change to them.
fullScreen: false,
widthOfNoteDetail: 0,
widthOfMainBody: 0
|
|
||
| handleFullScreenButton (e) { | ||
|
|
||
| this.state.fullScreen.status = !this.state.fullScreen.status |
There was a problem hiding this comment.
You should use this.state.setState().
const currentScreenState = Object.assign(this.state.fullScreen, {status: !this.state.fullScreen.status})
this.setState({ fullScreen: currentScreenScreen })
|
eslint is now passing but for some reason a linux test case is now failing when it didn't before. |
| } | ||
|
|
||
| handleFullScreenButton (e) { | ||
| const currentScreenState = !Object.assign({}, this.state).fullScreen |
There was a problem hiding this comment.
Now that you don't have to use Object.assign (I commented that before I offer you to change the structure of the state).
You can simply write this.setState({ fullScreen: !this.state.fullScreen }).
There was a problem hiding this comment.
gotcha, I ended up having to wrap the show/hide code inside the callback of the setState. It wasn't being updated properly so I read the react docs and found " React does not guarantee that the state changes are applied immediately.".
| fullScreen: false, | ||
| widthOfNoteDetail: 0, | ||
| widthOfMainBody: 0 | ||
|
|
|
The test occasionally fails 😨 |
| isLocked: false, | ||
| fullScreen: false, | ||
| widthOfNoteDetail: 0, | ||
| widthOfMainBody: 0 |
There was a problem hiding this comment.
Alright, let's move on to the architectural review!
First of all, these states should not be placed the component because they're out of the role of it.
I think browser/main/Main.js should manage them rather than MarkdownNoteDetail because those states are overall states for Boostnote, and you'll have to use eventEmitter to call handleFullScreenButton() from MarkdownNoteDetail.
I believe this PR (https://github.com/BoostIO/Boostnote/pull/283/files) is helpful for you!
There was a problem hiding this comment.
If you don't make out what I say (my English), feel free to ask me anything 😄
There was a problem hiding this comment.
Yeah I was concerned about that from the start. I ended up moving the logic/event into browser/main/Main.js like you suggested. I just have emit's inside the MarkdownNoteDetail and the snippet file. I tried to follow the code from the PR you recommend.
Also, thanks for all the help!
browser/main/Main.js
Outdated
| mainBodyWidth: 0 | ||
| } | ||
|
|
||
| this.fullScreenEditorCode = () => this.handleFullScreenButton() |
There was a problem hiding this comment.
I prefer this.toggleFullScreen to this name.
| sliderLeft.style.display = 'block' | ||
| } | ||
| }) | ||
| } |
There was a problem hiding this comment.
This is the last step (probably 😉). Let's change some codes in order to easy to maintain. To begin with, you can remove variables. I assume slideRight and slideLeft is not required, only noteDetail and mainBody is needed in this method.
Next, you can separate this method into 3, show, hide, and handleFullScreenButton.
handleFullScreenButton (e) {
const noteDetail = document.querySelector('.NoteDetail')
const mainBody = document.querySelector('#main-body')
this.setState({ fullScreen: !this.state.fullScreen }, () => {
if (this.state.fullScreen) {
this.hideLeftLists(noteDetail, mainBody)
} else {
this.showLeftLists(noteDetail, mainBody)
}
})
}
hideLeftLists(noteDetail, mainBody) {
this.state.noteDetailWidth = noteDetail.style.left
this.state.mainBodyWidth = mainBody.style.left
noteDetail.style.left = '0px'
mainBody.style.left = '0px'
}
showLeftLists(noteDetail, mainBody) {
noteDetail.style.left = this.state.noteDetailWidth
mainBody.style.left = this.state.mainBodyWidth
}
And I would like to have your opinion. Do you think the names of each method proper? I think they're not the best.
There was a problem hiding this comment.
sliderRight and sliderLeft are important because if you are in the editor mode, the slider bars to move the lists appear through the editor. You would be able to drag those sliders which is not good. I need to turn those off or display none them while you are in fullscreen.
I do like how you separated the code into 3 functions. I do not like the name leftLists, it is not descriptive. I do not quite know what to call them. If they have different names we should use them? I just called them lists because I don't know what else to call them.
There was a problem hiding this comment.
There was a problem hiding this comment.
I got it. I think the problem is solved by css. z-index might be helpful. You can apply z-index to those sliders and NoteDetail.
There was a problem hiding this comment.
Are you saying edit the CSS files or do it dynamically in the javascript? I can do this tomorrow.
There was a problem hiding this comment.
Please edit the CSS 😄
Thank you so much!
|
@nadr0 I fixt the broken test, so can you rebase the current master branch? |
|
I don't think the rebase ended up working? |
|
@nadr0 Please rebase upstream/master into this branch. |
allows user to hide the sidebars for fullscreen editing
allows user to hide the sidebars for fullscreen editing
|
@nadr0 You have to delete the merge commit. |
|
my git skills aren't up to par 😓 |
|
@nadr0 Leave it to me. |


(#547)
allows user to hide the sidebars for fullscreen editing, there is an expand button next to the trash ca., You press it to expand to fullscreen and go back to your old view. Images added below.
I have never used this stack before so I don't quite fully understand react+redux so the code falls back to the dom to edit the divs.
Anyone point me in the right direction to clean the handleFullScreenButton() call?
I would want a hide() function on certain react components? For I could just call those like