-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added fullscreen button for notes and snippets #602
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your great PR! 😄
To begin with, could you fix some pointed by eslint?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change the names? It's hard to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, you can simply use 'fa fa-arrows-alt'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err, you still have to leave the fa in the front.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, could you explain the reason more clearly? It works fine at least in my environment (MacOS).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha totally tunnel visioned what you said and didn't realize you mean take off the {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean take off the {}
Yes 🙋♀️
status: false, | ||
oldState: { | ||
nd : 0, | ||
mb : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simply change to them.
fullScreen: false,
widthOfNoteDetail: 0,
widthOfMainBody: 0
@@ -230,6 +237,34 @@ class MarkdownNoteDetail extends React.Component { | |||
} | |||
} | |||
|
|||
handleFullScreenButton (e) { | |||
|
|||
this.state.fullScreen.status = !this.state.fullScreen.status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -230,6 +233,30 @@ class MarkdownNoteDetail extends React.Component { | |||
} | |||
} | |||
|
|||
handleFullScreenButton (e) { | |||
const currentScreenState = !Object.assign({}, this.state).fullScreen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line 😎
The test occasionally fails 😨 |
isLocked: false, | ||
fullScreen: false, | ||
widthOfNoteDetail: 0, | ||
widthOfMainBody: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't make out what I say (my English), feel free to ask me anything 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
browser/main/Main.js
Outdated
} | ||
|
||
this.fullScreenEditorCode = () => this.handleFullScreenButton() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this.toggleFullScreen
to this name.
browser/main/Main.js
Outdated
sliderLeft.style.display = 'block' | ||
} | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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