-
Notifications
You must be signed in to change notification settings - Fork 2.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
vsx-extensions-view-styling-improvements #8086
vsx-extensions-view-styling-improvements #8086
Conversation
d4a2b84
to
005516f
Compare
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.
005516f
to
5f2c6d4
Compare
@vince-fugnitto thanks for looking this over, I've just pushed up a slight change that fixes the scrollbar issue: |
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.
The changes look very good! 👍
The next improvement would be to start the scrollbar right after the sticky header (similarly to vscode), but I think it can be done afterwards, the changes already are a big improvement.
Thanks @vince-fugnitto, I agree with you on the scrollbar improvement😎. I also noticed the quick scroll-to-top icon on the bottom right that could be added as well. |
@kenneth-marut-work do you think the scroll issue should be included in the pull-request (since it is introduced with the sticky header)? The icon to scroll-to-top would be a subsequent improvement which is out of scope at the moment. |
@vince-fugnitto Sounds good to me, I can certainly make that change in this PR 👍 |
5f2c6d4
to
cb28fe6
Compare
@vince-fugnitto I've moved the location of the scrollbar to under the header, it required a couple of modifications to the widget and PS container, but it's working well on my machine in both browser and electron. Here's a screencast: @colin-grant-work thanks for the help on this! |
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.
Functionality the changes look very good 👍
I'll give others the chance to review as well :)
Hi @lmcbout
I do not see this behavior in VSCode, is this still something we would like to implement? See VSCode behavior below: |
cb28fe6
to
9bc1c82
Compare
@kenneth-marut-work no I wouldn’t add a scrollbar (neither horizontal or vertical) for the sticky header, it does not align with the rest of the framework nor with vscode. |
@vince-fugnitto thanks for the response, in that case I have pushed the adjustment regarding @lmcbout 's comment:
The change targets |
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.
LGTM
Concerning item 1
no I wouldn’t add a scrollbar (neither horizontal or vertical) for the sticky header, it does not align with the rest of the framework nor with vscode.
When the window width is narrow, we don't see any content on the right side. I don't think it is user friendly. I understand it is the same behavior on VSCode, but still :(
Lets keep it as it is right now and we will see if we get other comments about it later
Good jod @kenneth-marut-work
@@ -17,6 +17,7 @@ | |||
:root { | |||
--theia-vsx-extension-icon-size: calc(var(--theia-ui-icon-font-size)*3); | |||
--theia-vsx-extension-editor-icon-size: calc(var(--theia-vsx-extension-icon-size)*3); | |||
--theia-vsx-extension-header-height: 150px; |
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.
how do you get 150? Would it still work if some font size css variable is redefined? Could it be expressed as a formula?
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.
Thanks for the comment @akosyakov
I had originally used this value since VSCode seems to have a fixed header size of 166px but also includes a tabbar (which we do not have). I have removed this hard coded value and instead calculated the heights using JS from the deferred HTMLElements inside vsx-extension-editor.tsx
.
this.update(); | ||
this.toDispose.push(this.model.onDidChange(() => this.update())); | ||
} | ||
|
||
async getScrollContainer(): Promise<HTMLElement> { | ||
await waitForRevealed(this); |
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.
looks fragile, one should rather pass deferred promise into the rect component and resolve in ref assignment
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.
@akosyakov Thanks for the suggestion, I did not know about deferred technique but went ahead and implemented it according to my understanding
8d17032
to
6f92fff
Compare
} = this.props.extension; | ||
return <React.Fragment> | ||
<div className='header'> | ||
<div className='header' ref={element => this.resolveDeferredOnRender(element, deferredHeaderElementRender)}> |
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 just update the property of this class without any deferred the same in other places
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've updated this in my latest changes. The only remaining deferred item is the scroll container which is used for getScrollContainer
inside vsx-extension-editor
@@ -99,6 +100,9 @@ export class VSXExtension implements VSXExtensionData, TreeElement { | |||
readonly search: VSXExtensionsSearchModel; | |||
|
|||
protected readonly data: Partial<VSXExtensionData> = {}; | |||
deferredScrollContainerRender: Deferred<HTMLDivElement> | undefined; |
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 don't break encapsulation, clients should be able to modify rendered DOM elements
protected _header: HTMLDivElement | undefined;
get header(): HTMLDIvElement | undefined {
return this._header;
}
the same for other properties
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.
Thanks for the suggestions, I've reorganized the logic so that these elements remain encapsulated. I have also added a method to reset the vsx-extension.tsx
deferred scrollContainer property during tab close/reopen since the previously opened instance will persist through a close/reopen
super.onResize(msg); | ||
const bodyElement = await this.deferredBodyElementRender.promise; | ||
const scrollContainer = await this.deferredScrollContainerRender.promise; | ||
if (bodyElement && scrollContainer) { |
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.
it does not look good, since we modify rendered DOM than we should touch only virtual, we should propagate onResize to VSXExtension
and there update new sizes as part of the state to retrigger DOM update via React
6f92fff
to
d5c3701
Compare
99b8480
to
eb9cbef
Compare
@@ -100,6 +104,56 @@ export class VSXExtension implements VSXExtensionData, TreeElement { | |||
|
|||
protected readonly data: Partial<VSXExtensionData> = {}; | |||
|
|||
protected _body: HTMLDivElement | undefined; |
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.
It should be replaced with:
protected _editor: VSXExtensionEditorComponent | undefined;
renderEditor(): React.ReactNode {
return <VSXExtensionEditorComponent extension={this} ref={ref = (this._editor = ref || undefined)} />;
}
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.
Hi @akosyakov, the reason I have these additional (body
, header
, and scrollContainer
) elements is because it seems that the absence of a readme
on line 475 could potentially cause the body
and scroll-container
to not be rendered. Additionally because there is manipulation of the virtual DOM and I need a ref to all 3 elements in setContainerHeights
and updateOnResize
to keep track of each individually.
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.
My problem is not that you add them, but how, i.e. there are public APIs to allow setting them by child components. Instead proper encapsulation should be applied, i.e. they should be exposed on child components instead and here we should only capture a child component ref::
const body = this._editor?.body;
protected header?: HTMLDivElement; | ||
protected body?: HTMLDivElement; | ||
|
||
componentDidMount(): void { |
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 don't need all of these
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.
Since I am keeping track of these in VSXExtension
, I went ahead and removed these redundancies as well as some of the checks inside componentDidMount
. The refs are now set using the setter methods passed in as props and to VSXExtensionEditorComponent
, and componentDidMount
will trigger the initial header/body sizing calculations if the refs exist
eb9cbef
to
e5c6296
Compare
// TODO replace with webview | ||
readonly openLink = (event: React.MouseEvent) => { | ||
if (!this.body) { | ||
if (!this.props.extension.body) { |
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.
body ref should belong to this component, not to its parent, please don't break encapsulation
680deac
to
0dd4d84
Compare
@akosyakov Thanks for the comments, I've moved all refs used for sizing calculations to The
Please note I am aware that this breaks encapsulation of the
Also note build seems to be failing due to: |
} = this.props.extension; | ||
|
||
if (width !== undefined) { |
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.
Why is it happening on render but no on proper events like resize?
return this._width; | ||
} | ||
set width(width: number) { | ||
this._width = width; |
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.
On resitze event, you should call VSXExtensionEditorComponent.setState
and keep in the state everything what is required for rendering. render
function should not compute any new properties but simply use state and props to render. That's how react works.
@akosyakov, @kenneth-marut-work, reading over a number of the comments on this PR, my impression is that a lot of the discussion has revolved around questions of encapsulation and the proper location for various member variables. It seems to me that origin of a lot of this difficulty is that the existing implementation has made the When the Instead, I think Ken's instinct was correct to track the scroll container and other state relevant to the Does that sound like a reasonable adjustment to the current architecture? |
Moving |
22f2d78
to
37d7602
Compare
@akosyakov, I've pushed a new version that moves the call to Moving the I've also moved some of the styling logic - 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.
thanks, code wise it looks very clean now. Someone has to test it.
Signed-off-by: Kenneth Marut <kenneth.marut@ericsson.com> Signed-off-by: Colin Grant <colin.grant@ericsson.com>
37d7602
to
1a63d2d
Compare
@vince-fugnitto, would you be willing to give this a quick once over to make sure everything is still working after these latest changes? the CI checks are failing at the moment, but it looks like an error downloading rip-grep in one build, rather than a problem with the code. |
Of course :) I'll also restart the build (ripgrep issues occur for forked repositories since they do not have the necessary tokens). |
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.
The changes look very good 👍
I've verified that:
- the header is sticky
- the scrollbar works correctly (and starts after the header)
- the view is responsive (content wraps correctly, images are resized properly)
I'll merge tomorrow if there are no objections :) |
What it does
This PR introduces some styling improvements to the vsx-extensions view to be more inline with VSCodes respective view, these improvements include:
How to test
Review checklist
Reminder for reviewers