-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(status bar): tuning the status bar component
- Loading branch information
Showing
8 changed files
with
106 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from 'react'; | ||
import { injectable } from 'tsyringe'; | ||
import { EditorMarkers } from 'mo/workbench/statusBar/editor'; | ||
import { ProblemsMarkers } from 'mo/workbench/statusBar/problems'; | ||
export interface IStatusBarItem<T = any> extends HTMLElementProps { | ||
id: string; | ||
sortIndex: number; | ||
data?: T; | ||
onClick?(e: React.MouseEvent, item?: IStatusBarItem); | ||
render?: (item: IStatusBarItem) => ReactNode; | ||
name?: string; | ||
} | ||
|
||
export interface IStatusBar { | ||
rightItems: IStatusBarItem[]; | ||
leftItems: IStatusBarItem[]; | ||
hidden?: boolean; | ||
} | ||
|
||
export const STATUS_PROBLEMS: IStatusBarItem = { | ||
id: 'MoProblems', | ||
sortIndex: 1, | ||
data: { | ||
warnings: 0, | ||
errors: 0, | ||
infos: 0, | ||
}, | ||
name: 'Problems', | ||
render: (item: IStatusBarItem) => <ProblemsMarkers {...item} />, | ||
}; | ||
|
||
export const STATUS_EDITOR_INFO: IStatusBarItem = { | ||
id: 'MoEditorInfo', | ||
sortIndex: 2, | ||
data: { | ||
ln: 0, | ||
col: 0, | ||
}, | ||
name: 'Go to Line/Column', | ||
render: (item: IStatusBarItem) => <EditorMarkers {...item} />, | ||
}; | ||
|
||
/** | ||
* The activity bar event definition | ||
*/ | ||
export enum StatusBarEvent { | ||
/** | ||
* Selected an activity bar | ||
*/ | ||
onClick = 'statusBar.onClick', | ||
/** | ||
* Activity bar data changed | ||
*/ | ||
DataChanged = 'statusBar.data', | ||
} | ||
@injectable() | ||
export class StatusBarModel implements IStatusBar { | ||
public leftItems: IStatusBarItem[] = []; | ||
public rightItems: IStatusBarItem[] = []; | ||
public hidden = false; | ||
|
||
constructor( | ||
leftItems: IStatusBarItem[] = [STATUS_PROBLEMS], | ||
rightItems: IStatusBarItem[] = [STATUS_EDITOR_INFO], | ||
hidden = false | ||
) { | ||
this.leftItems = leftItems; | ||
this.rightItems = rightItems; | ||
this.hidden = hidden; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as React from 'react'; | ||
|
||
export function EditorMarkers(props: any) { | ||
const { data = { ln: 0, col: 0 } } = props; | ||
return <span>{`Ln ${data.ln}, Col ${data.col}`}</span>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { Icon } from 'mo/components/icon'; | ||
export function ProblemsMarkers(props: any) { | ||
const { data = { errors: 0, warnings: 0, infos: 0 } } = props; | ||
return ( | ||
<React.Fragment> | ||
<Icon type="error" /> | ||
{` ${data.errors} `} | ||
<Icon type="warning" /> | ||
{` ${data.warnings} `} | ||
<Icon type="info" /> | ||
{` ${data.infos}`} | ||
</React.Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
&__left-items, | ||
&__right-items { | ||
align-items: center; | ||
display: flex; | ||
height: 100%; | ||
} | ||
|