Skip to content
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

Feature/preferences ui tab styling #7793

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/preferences/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
.theia-settings-container .preferences-tabbar-widget {
grid-area: tabbar;
margin: 3px 24px 0px 24px;
}

.theia-settings-container .preferences-tabbar-widget.with-shadow {
box-shadow: 0px 6px 5px -5px var(--theia-widget-shadow);
}

Expand All @@ -67,13 +70,26 @@

#theia-main-content-panel .theia-settings-container #preferences-scope-tab-bar .preferences-scope-tab {
background: var(--theia-editor-background);
border-right: unset;
border-bottom: var(--theia-border-width) solid var(--theia-tab-unfocusedInactiveForeground);
}

#theia-main-content-panel .theia-settings-container .tabbar-underline {
width: 100%;
position:absolute;
top: calc(var(--theia-private-horizontal-tab-height) + var(--theia-private-horizontal-tab-scrollbar-rail-height) / 2 - 1px);
border-top: 1px solid var(--theia-tab-unfocusedInactiveForeground);
z-index: -1;
}

#theia-main-content-panel .theia-settings-container #preferences-scope-tab-bar .preferences-scope-tab.p-mod-current {
color: var(--theia-panelTitle-activeForeground);
border-top: var(--theia-border-width) solid var(--theia-panelTitle-activeBorder);
border-bottom: var(--theia-border-width) solid var(--theia-panelTitle-activeBorder);
}

#theia-main-content-panel .theia-settings-container #preferences-scope-tab-bar .preferences-scope-tab.p-mod-current:not(.theia-mod-active) {
border-top: unset;
}

#theia-main-content-panel .theia-settings-container #preferences-scope-tab-bar .preferences-scope-tab.preferences-folder-tab .p-TabBar-tabLabel::after {
content: 'Folder';
Expand Down
1 change: 1 addition & 0 deletions packages/preferences/src/browser/util/preference-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export namespace Preference {

export interface MouseScrollDetails {
firstVisibleChildId: string;
isTop: boolean;
};

export interface SelectedTreeNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ export class PreferencesEditorWidget extends ReactWidget {

protected onScroll = (): void => {
const scrollContainer = this.node;
const scrollIsTop = scrollContainer.scrollTop === 0;
const visibleChildren: string[] = [];
this.addFirstVisibleChildId(scrollContainer, visibleChildren);
if (visibleChildren.length) {
this.preferencesEventService.onEditorScroll.fire({ firstVisibleChildId: visibleChildren[0] });
this.preferencesEventService.onEditorScroll.fire({
firstVisibleChildId: visibleChildren[0],
isTop: scrollIsTop
});
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const GENERAL_FOLDER_TAB_CLASSNAME = 'preference-folder';
const LABELED_FOLDER_TAB_CLASSNAME = 'preferences-folder-tab';
const FOLDER_DROPDOWN_CLASSNAME = 'preferences-folder-dropdown';
const FOLDER_DROPDOWN_ICON_CLASSNAME = 'preferences-folder-dropdown-icon';
const TABBAR_UNDERLINE_CLASSNAME = 'tabbar-underline';
const SHADOW_CLASSNAME = 'with-shadow';
const SINGLE_FOLDER_TAB_CLASSNAME = `${PREFERENCE_TAB_CLASSNAME} ${GENERAL_FOLDER_TAB_CLASSNAME} ${LABELED_FOLDER_TAB_CLASSNAME}`;
const UNSELECTED_FOLDER_DROPDOWN_CLASSNAME = `${PREFERENCE_TAB_CLASSNAME} ${GENERAL_FOLDER_TAB_CLASSNAME} ${FOLDER_DROPDOWN_CLASSNAME}`;
const SELECTED_FOLDER_DROPDOWN_CLASSNAME = `${PREFERENCE_TAB_CLASSNAME} ${GENERAL_FOLDER_TAB_CLASSNAME} ${LABELED_FOLDER_TAB_CLASSNAME} ${FOLDER_DROPDOWN_CLASSNAME}`;
Expand All @@ -53,6 +55,7 @@ export class PreferencesScopeTabBar extends TabBar<Widget> {
protected folderTitle: Title<Widget>;
protected currentWorkspaceRoots: FileStat[] = [];
protected currentSelection: Preference.SelectedScopeDetails = Preference.DEFAULT_SCOPE;
protected editorScrollAtTop = true;
protected setNewScopeSelection(newSelection: Preference.SelectedScopeDetails): void {

const newIndex = this.titles.findIndex(title => title.dataset.scope === newSelection.scope);
Expand All @@ -79,6 +82,19 @@ export class PreferencesScopeTabBar extends TabBar<Widget> {
this.doUpdateDisplay(newRoots);
});
this.workspaceService.onWorkspaceLocationChanged(() => this.updateWorkspaceTab());
this.preferencesEventService.onEditorScroll.event((e: Preference.MouseScrollDetails) => {
if (e.isTop !== this.editorScrollAtTop) {
this.editorScrollAtTop = e.isTop;
if (this.editorScrollAtTop) {
this.removeClass(SHADOW_CLASSNAME);
} else {
this.addClass(SHADOW_CLASSNAME);
}
}
});
const tabUnderline = document.createElement('div');
tabUnderline.className = TABBAR_UNDERLINE_CLASSNAME;
this.node.append(tabUnderline);
}

protected setupInitialDisplay(): void {
Expand All @@ -98,7 +114,7 @@ export class PreferencesScopeTabBar extends TabBar<Widget> {
tab.onkeypress = () => {
if (tab.className.includes(GENERAL_FOLDER_TAB_CLASSNAME) && this.currentWorkspaceRoots.length > 1) {
const tabRect = tab.getBoundingClientRect();
this.openContextMenu(tabRect);
this.openContextMenu(tabRect, tab, 'keypress');
} else {
this.setNewScopeSelection(this.titles[index].dataset as unknown as Preference.SelectedScopeDetails);
}
Expand Down Expand Up @@ -190,17 +206,20 @@ export class PreferencesScopeTabBar extends TabBar<Widget> {
const folderTab = this.contentNode.querySelector(`.${GENERAL_FOLDER_TAB_CLASSNAME}`);
if (folderTab && folderTab.contains(e.target as HTMLElement) && this.currentWorkspaceRoots.length > 1) {
const tabRect = folderTab.getBoundingClientRect();
this.openContextMenu(tabRect);
this.openContextMenu(tabRect, (folderTab as HTMLElement), 'click');
return;
}
super.handleEvent(e);
}

protected openContextMenu(tabRect: DOMRect | ClientRect): void {
protected openContextMenu(tabRect: DOMRect | ClientRect, folderTabNode: HTMLElement, source: 'click' | 'keypress'): void {
this.contextMenuRenderer.render({
menuPath: FOLDER_SCOPE_MENU_PATH,
anchor: { x: tabRect.left, y: tabRect.bottom },
args: [this.folderSelectionCallback, 'from-tabbar']
args: [this.folderSelectionCallback, 'from-tabbar'],
onHide: () => {
if (source === 'click') { folderTabNode.blur(); }
}
});
}

Expand Down