[go: nahoru, domu]

Skip to content

Commit

Permalink
feat: add custom menubar sample for startup (opensumi#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaaaash authored Mar 2, 2022
1 parent 33b00a9 commit ce5784e
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/startup/entry/sample-modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Provider, Injectable } from '@opensumi/di';
import { BrowserModule } from '@opensumi/ide-core-browser';

import { EditorEmptyComponentContribution } from './editor-empty-component.contribution';
import { MenuBarContribution } from './menu-bar/menu-bar.contribution';
import { StatusBarContribution } from './status-bar.contribution';

@Injectable()
export class SampleModule extends BrowserModule {
providers: Provider[] = [EditorEmptyComponentContribution, StatusBarContribution];
providers: Provider[] = [MenuBarContribution, EditorEmptyComponentContribution, StatusBarContribution];
}
1 change: 1 addition & 0 deletions packages/startup/entry/sample-modules/menu-bar/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Injectable } from '@opensumi/di';
import { ComponentContribution, ComponentRegistry, Domain } from '@opensumi/ide-core-browser';
import { MenuBarView } from './menu-bar.view';

@Injectable()
@Domain(ComponentContribution)
export class MenuBarContribution implements ComponentContribution {
// Component key
static MenuBarContainer = '@opensumi/menu-bar-example';

registerComponent(registry: ComponentRegistry): void {
registry.register(MenuBarContribution.MenuBarContainer, {
component: MenuBarView,
id: MenuBarContribution.MenuBarContainer,
});
}
}
16 changes: 16 additions & 0 deletions packages/startup/entry/sample-modules/menu-bar/menu-bar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.menu_bar_view {
display: flex;
background-color: var(--kt-menubar-background);
height: var(--tabBar-height);
align-items: center;
}
.menu_bar_view .menu_bar_logo {
display: inline-block;
height: 24px;
width: 24px;
background-image: url(logo.svg);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
margin-left: 10px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.menu_bar_view {
display: flex;
background-color: var(--kt-menubar-background);
height: var(--tabBar-height);
align-items: center;

.menu_bar_logo {
display: inline-block;
height: 24px;
width: 24px;
background-image: url(./logo.svg);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
margin-left: 10px;
}
}
16 changes: 16 additions & 0 deletions packages/startup/entry/sample-modules/menu-bar/menu-bar.view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { MenuBar } from '@opensumi/ide-menu-bar/lib/browser/menu-bar.view';

import * as styles from './menu-bar.module.less';

/**
* Custom menu bar component.
* Add a logo in here, and keep
* opensumi's original menubar.
*/
export const MenuBarView = () => (
<div className={styles.menu_bar_view}>
<span className={styles.menu_bar_logo} />
<MenuBar />
</div>
);
2 changes: 1 addition & 1 deletion packages/startup/entry/web/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ renderApp({
...defaultConfig,
...{
[SlotLocation.top]: {
modules: ['@opensumi/ide-menu-bar', 'toolbar'],
modules: ['@opensumi/menu-bar-example', 'toolbar'],
},
},
...{
Expand Down

0 comments on commit ce5784e

Please sign in to comment.