Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Pinkney <joshpinkney@gmail.com>
  • Loading branch information
JPinkney committed May 19, 2019
1 parent bccd8ef commit 6f0e336
Showing 1 changed file with 58 additions and 54 deletions.
112 changes: 58 additions & 54 deletions packages/monaco/src/browser/monaco-quick-open-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ export interface MonacoQuickOpenControllerOpts extends monaco.quickOpen.IQuickOp
totalSteps?: number | undefined
buttons?: ReadonlyArray<TitleButton>

// TODO: Check these
prefix?: string;
password?: boolean;
ignoreFocusOut?: boolean;
readonly prefix?: string;
readonly password?: boolean;
readonly ignoreFocusOut?: boolean;
onType?(lookFor: string, acceptor: (model: monaco.quickOpen.QuickOpenModel) => void): void;
onClose?(canceled: boolean): void;
}
Expand All @@ -60,6 +59,9 @@ class MonacoTitleBar {
private disposableCollection: DisposableCollection;
constructor() {
this.titleElement = document.createElement('h3');
this.titleElement.style.flex = '1';
this.titleElement.style.textAlign = 'center';
this.titleElement.style.margin = '5px 0';

this.disposableCollection = new DisposableCollection();
this.disposableCollection.push(this.onDidTriggerButtonEmitter = new Emitter());
Expand Down Expand Up @@ -148,101 +150,103 @@ class MonacoTitleBar {
return this._buttons.filter(val => val.location === 1);
}

/**
* Take in an ID and return a list
* of associates css classes
*/
private iconPathIDtoClass(id: string) {
let iconClass = '';
switch (id) {
case 'folder': {
iconClass = FOLDER_ICON;
}
case 'file': {
iconClass = FILE_ICON;
}
case 'Back': {
iconClass = 'fa fa-arrow-left';
}
}
return iconClass.split(' ');
}

private createButtonElement(buttons: TitleButton[], themeID: string) {
const buttonDiv = document.createElement('div');
buttonDiv.style.display = 'inline-flex';
for (const b of buttons) {
const a = document.createElement('a');
a.style.width = '20px';
a.style.height = '20px';
const aElement = document.createElement('a');
aElement.style.width = '20px';
aElement.style.height = '20px';

if ('id' in b.iconPath) {
let clazz2 = '';
switch (b.iconPath.id) {
case 'folder': {
clazz2 = FOLDER_ICON;
}
case 'file': {
clazz2 = FILE_ICON;
}
case 'Back': {
clazz2 = 'fa fa-arrow-left';
}
}
const splitClassList = clazz2.split(' ');
for (const clazz of splitClassList) {
a.classList.add(clazz);
}
} else if ('light' in b.iconPath || 'dark' in b.iconPath) {
const iconClass = this.iconPathIDtoClass(b.iconPath.id);
aElement.classList.add(...iconClass);
} else if ('light' in b.iconPath && 'dark' in b.iconPath) {
const potentialIcon = b.iconPath as { dark: URI, light: URI };
a.style.backgroundImage = `url(\'${themeID === BuiltinThemeProvider.lightTheme.id ? potentialIcon.light : potentialIcon.dark}\')`;
aElement.style.backgroundImage = `url(\'${themeID === BuiltinThemeProvider.lightTheme.id ? potentialIcon.light : potentialIcon.dark}\')`;
} else {
a.style.backgroundImage = `url(\'${b.iconPath.toString()}\')`;
aElement.style.backgroundImage = `url(\'${b.iconPath.toString()}\')`;
}

if (b.iconClass) {
const splitClassList = b.iconClass.split(' '); // a.classList.add does not accept whitespace
for (const clazz of splitClassList) {
a.classList.add(clazz);
}
aElement.classList.add(...(b.iconClass.split(' ')));
}
a.classList.add('icon');
a.style.display = 'flex';
a.style.justifyContent = 'center';
a.style.alignItems = 'center';
a.title = b.tooltip ? b.tooltip : '';
a.onclick = () => {

aElement.classList.add('icon');
aElement.style.display = 'flex';
aElement.style.justifyContent = 'center';
aElement.style.alignItems = 'center';
aElement.title = b.tooltip ? b.tooltip : '';
aElement.onclick = () => {
this.onDidTriggerButtonEmitter.fire(b);
};
buttonDiv.appendChild(a);
buttonDiv.appendChild(aElement);
}
return buttonDiv;
}

public attachTitleBar(themeID: string) {
// Create a div that contains all the new title top stuff
private createTitleBarDiv() {
const div = document.createElement('div');
div.style.height = '1%'; // Reset the height to be valid
div.style.display = 'flex';
div.style.flexDirection = 'row';
div.style.flexWrap = 'wrap';
div.style.justifyContent = 'flex-start';
div.style.alignItems = 'center';
// div.style.textAlign = 'center';
return div;
}

private createLeftButtonDiv(themeID: string) {
const leftButtonDiv = document.createElement('div'); // Holds all the buttons that get added to the left
// leftButtonDiv.style.display = 'inherit';
leftButtonDiv.style.flex = '1';
leftButtonDiv.style.textAlign = 'left';

leftButtonDiv.appendChild(this.createButtonElement(this.getLeftButtons(), themeID));
return leftButtonDiv;
}

private createRightButtonDiv(themeID: string) {
const rightButtonDiv = document.createElement('div');
rightButtonDiv.style.flex = '1';
rightButtonDiv.style.textAlign = 'right';

rightButtonDiv.appendChild(this.createButtonElement(this.getRightButtons(), themeID));
return rightButtonDiv;
}

// Build the string that is needed for the title
this.updateInnerTitleText();
public attachTitleBar(themeID: string) {
const div = this.createTitleBarDiv();

this.titleElement.style.flex = '1';
this.titleElement.style.textAlign = 'center';
this.titleElement.style.margin = '5px 0';
this.updateInnerTitleText();

div.appendChild(leftButtonDiv);
div.appendChild(this.createLeftButtonDiv(themeID));
div.appendChild(this.titleElement);
div.appendChild(rightButtonDiv);
div.appendChild(this.createRightButtonDiv(themeID));

return div;
}

/**
* Show the title bar if it is not attached AND
* steps or title is defined.
*
* If the title bar is already showing and step and title
* is defined then we need to update the properties
*/
shouldShowTitleBar(): boolean {
return ((this._step !== undefined) || (this._title !== undefined));
}
Expand Down

0 comments on commit 6f0e336

Please sign in to comment.