Skip to content

Commit

Permalink
feat: add sidebar (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
lskramarov authored and pimenovoleg committed Jun 26, 2019
1 parent 481f7e9 commit 9f618eb
Show file tree
Hide file tree
Showing 42 changed files with 708 additions and 664 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
"server-dev:icon": "npm run server-dev -- --env.component icon",
"server-dev:input": "npm run server-dev -- --env.component input",
"server-dev:flex-layout": "npm run server-dev -- --env.component flex-layout",
"server-dev:layout": "npm run server-dev -- --env.component layout",
"server-dev:link": "npm run server-dev -- --env.component link",
"server-dev:list": "npm run server-dev -- --env.component list",
"server-dev:modal": "npm run server-dev -- --env.component modal",
Expand All @@ -178,6 +177,7 @@
"server-dev:progress-spinner": "npm run server-dev -- --env.component progress-spinner",
"server-dev:radio": "npm run server-dev -- --env.component radio",
"server-dev:select": "npm run server-dev -- --env.component select",
"server-dev:sidebar": "npm run server-dev -- --env.component sidebar",
"server-dev:sidepanel": "npm run server-dev -- --env.component sidepanel",
"server-dev:splitter": "npm run server-dev -- --env.component splitter",
"server-dev:tabs": "npm run server-dev -- --env.component tabs",
Expand Down
63 changes: 63 additions & 0 deletions packages/cdk/keycodes/keycodes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* tslint:disable:no-magic-numbers no-bitwise */

export const MAC_ENTER = 3;
export const BACKSPACE = 8;
Expand Down Expand Up @@ -128,3 +129,65 @@ export function hasModifierKey(event: KeyboardEvent, ...modifiers: ModifierKey[]

return event.altKey || event.shiftKey || event.ctrlKey || event.metaKey;
}

export function isControl(event) {
const keyCode = event.which;
switch (keyCode) {
case SHIFT:
case CONTROL:
case ALT:
return true;
default:
return !!event.metaKey;
}
}

export function isNumberKey(event) {
const keyCode = event.which ? event.which : event;

return keyCode >= 49 && keyCode <= 57;
}

export function isLetterKey(event) {
const keyCode = event.which ? event.which : event;

return keyCode >= 65 && keyCode <= 90;
}

export function isFunctionKey(event) {
const keyCode = event.which ? event.which : event;

return keyCode >= 112 && keyCode <= 123;
}

export function isVerticalMovement(event) {
return ~[UP_ARROW, DOWN_ARROW, PAGE_DOWN, PAGE_UP, HOME, END].indexOf(event);
}

export function isHorizontalMovement(event) {
return ~[LEFT_ARROW, RIGHT_ARROW, BACKSPACE, DELETE].indexOf(event);
}

export function isSelectAll(event) {
return event.ctrlKey && event.keyCode === 65;
}

export function isCopy(event) {
return event.ctrlKey && event.keyCode === 67;
}

export function isInput(event) {
return event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA';
}

export function isLeftBracket(event) {
return event.code === 'BracketLeft';
}

export function isRightBracket(event) {
return event.code === 'BracketRight';
}

export function isDigit(event) {
return [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(event.which) !== -1;
}
1 change: 0 additions & 1 deletion packages/dev-app/system-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ System.config({
'@ptsecurity/mosaic/progress-bar': 'dist/packages/mosaic/progress-bar/index.js',
'@ptsecurity/mosaic/progress-spinner': 'dist/packages/mosaic/progress-spinner/index.js',
'@ptsecurity/mosaic/icon': 'dist/packages/mosaic/icon/index.js',
'@ptsecurity/mosaic/layout': 'dist/packages/mosaic/layout/index.js',
'@ptsecurity/mosaic/link': 'dist/packages/mosaic/link/index.js',
'@ptsecurity/mosaic/radio': 'dist/packages/mosaic/radio/index.js',
'@ptsecurity/mosaic/checkbox': 'dist/packages/mosaic/checkbox/index.js',
Expand Down
2 changes: 0 additions & 2 deletions packages/mosaic-dev/all/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { McDropdownModule } from '@ptsecurity/mosaic/dropdown';
import { McFormFieldModule } from '@ptsecurity/mosaic/form-field';
import { McIconModule } from '@ptsecurity/mosaic/icon';
import { McInputModule } from '@ptsecurity/mosaic/input';
import { McLayoutModule } from '@ptsecurity/mosaic/layout';
import { McLinkModule } from '@ptsecurity/mosaic/link';
import { McListModule } from '@ptsecurity/mosaic/list';
import { McModalModule, McModalService } from '@ptsecurity/mosaic/modal';
Expand Down Expand Up @@ -204,7 +203,6 @@ export class DemoComponent {
McDropdownModule,
McInputModule,
McFormFieldModule,
McLayoutModule,
McNavbarModule,
McListModule,
McModalModule,
Expand Down
43 changes: 0 additions & 43 deletions packages/mosaic-dev/all/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -600,49 +600,6 @@ <h1>Input</h1>
</mc-form-field>
</div>

<div class="dev-box">
<h1>Layout</h1>

<mc-layout>
<mc-header>Header</mc-header>
<mc-content>Content</mc-content>
<mc-footer>Footer</mc-footer>
</mc-layout>

<br><br>

<mc-layout>
<mc-header>Header</mc-header>
<mc-layout>
<mc-content>Content</mc-content>
<mc-sidebar>Sidebar</mc-sidebar>
</mc-layout>
</mc-layout>

<br><br>

<mc-layout>
<mc-sidebar>Sidebar</mc-sidebar>
<mc-layout>
<mc-header>Header</mc-header>
<mc-content>Content</mc-content>
<mc-footer>Footer</mc-footer>
</mc-layout>
</mc-layout>

<br><br>

<mc-layout>
<mc-sidebar>Sidebar</mc-sidebar>
<mc-layout>
<mc-header>Header</mc-header>
<mc-content>Content</mc-content>
<mc-footer>Footer</mc-footer>
</mc-layout>
<mc-sidebar>Sidebar</mc-sidebar>
</mc-layout>
</div>

<div class="dev-box">
<h1>Link</h1>

Expand Down
38 changes: 0 additions & 38 deletions packages/mosaic-dev/layout/module.ts

This file was deleted.

26 changes: 0 additions & 26 deletions packages/mosaic-dev/layout/styles.scss

This file was deleted.

100 changes: 0 additions & 100 deletions packages/mosaic-dev/layout/template.html

This file was deleted.

60 changes: 60 additions & 0 deletions packages/mosaic-dev/sidebar/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* tslint:disable:no-console */
import { Component, NgModule, ViewEncapsulation } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { McIconModule } from '@ptsecurity/mosaic/icon';
import { McSidebarModule } from '@ptsecurity/mosaic/sidebar';
import { McSplitterModule } from '@ptsecurity/mosaic/splitter';

import { McButtonModule } from '../../mosaic/button';


@Component({
selector: 'app',
template: require('./template.html'),
styleUrls: ['./styles.scss'],
encapsulation: ViewEncapsulation.None
})
export class DemoComponent {
leftSidebarSidebarState: boolean = false;
leftSplitterState: boolean = false;

rightSidebarSidebarState: boolean = false;
rightSplitterState: boolean = false;

onStateChanged($event): void {
console.log('onStateChanged: ', $event);
}

toggleLeftSidebar() {
this.leftSidebarSidebarState = !this.leftSidebarSidebarState;
}

toggleRightSidebar() {
this.rightSidebarSidebarState = !this.rightSidebarSidebarState;
}
}


@NgModule({
declarations: [
DemoComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
McSplitterModule,
McButtonModule,
McSidebarModule
],
bootstrap: [
DemoComponent
]
})
export class DemoModule {}

platformBrowserDynamic()
.bootstrapModule(DemoModule)
.catch((error) => console.error(error));

Loading

0 comments on commit 9f618eb

Please sign in to comment.