Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cf3f585

Browse files
committedApr 10, 2018
refactor: improve aside & sidebar
1 parent de42911 commit cf3f585

16 files changed

+179
-38
lines changed
 

‎.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = off
14+
trim_trailing_whitespace = false

‎build/change-version.js

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env node
2+
3+
'use strict'
4+
5+
/*!
6+
* Script to update version number references in the project.
7+
* Copyright 2017 The Bootstrap Authors
8+
* Copyright 2017 Twitter, Inc.
9+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
10+
*/
11+
12+
/* global Set */
13+
14+
const fs = require('fs')
15+
const path = require('path')
16+
const sh = require('shelljs')
17+
sh.config.fatal = true
18+
const sed = sh.sed
19+
20+
// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37
21+
RegExp.quote = (string) => string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')
22+
RegExp.quoteReplacement = (string) => string.replace(/[$]/g, '$$')
23+
24+
const DRY_RUN = false
25+
26+
function walkAsync(directory, excludedDirectories, fileCallback, errback) {
27+
if (excludedDirectories.has(path.parse(directory).base)) {
28+
return
29+
}
30+
fs.readdir(directory, (err, names) => {
31+
if (err) {
32+
errback(err)
33+
return
34+
}
35+
names.forEach((name) => {
36+
const filepath = path.join(directory, name)
37+
fs.lstat(filepath, (err, stats) => {
38+
if (err) {
39+
process.nextTick(errback, err)
40+
return
41+
}
42+
if (stats.isSymbolicLink()) {
43+
return
44+
}
45+
else if (stats.isDirectory()) {
46+
process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback)
47+
}
48+
else if (stats.isFile()) {
49+
process.nextTick(fileCallback, filepath)
50+
}
51+
})
52+
})
53+
})
54+
}
55+
56+
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) {
57+
original = new RegExp(RegExp.quote(original), 'g')
58+
replacement = RegExp.quoteReplacement(replacement)
59+
const updateFile = !DRY_RUN ? (filepath) => {
60+
if (allowedExtensions.has(path.parse(filepath).ext)) {
61+
sed('-i', original, replacement, filepath)
62+
}
63+
} : (filepath) => {
64+
if (allowedExtensions.has(path.parse(filepath).ext)) {
65+
console.log(`FILE: ${filepath}`)
66+
}
67+
else {
68+
console.log(`EXCLUDED:${filepath}`)
69+
}
70+
}
71+
walkAsync(directory, excludedDirectories, updateFile, (err) => {
72+
console.error('ERROR while traversing directory!:')
73+
console.error(err)
74+
process.exit(1)
75+
})
76+
}
77+
78+
function main(args) {
79+
if (args.length !== 2) {
80+
console.error('USAGE: change-version old_version new_version')
81+
console.error('Got arguments:', args)
82+
process.exit(1)
83+
}
84+
const oldVersion = args[0]
85+
const newVersion = args[1]
86+
const EXCLUDED_DIRS = new Set([
87+
'.git',
88+
'node_modules',
89+
'vendor'
90+
])
91+
const INCLUDED_EXTENSIONS = new Set([
92+
// This extension whitelist is how we avoid modifying binary files
93+
'',
94+
'.css',
95+
'.html',
96+
'.js',
97+
'.json',
98+
'.md',
99+
'.scss',
100+
'.txt',
101+
'.yml'
102+
])
103+
replaceRecursively('.', EXCLUDED_DIRS, INCLUDED_EXTENSIONS, oldVersion, newVersion)
104+
}
105+
106+
main(process.argv.slice(2))

‎dist/aside/app-aside.component.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { OnInit } from '@angular/core';
1+
import { ElementRef, OnInit } from '@angular/core';
22
export declare class AppAsideComponent implements OnInit {
3-
display: string;
3+
private el;
4+
display: any;
45
fixed: boolean;
56
offCanvas: boolean;
6-
constructor();
7+
constructor(el: ElementRef);
78
ngOnInit(): void;
89
isFixed(fixed: boolean): void;
910
isOffCanvas(offCanvas: boolean): void;
10-
displayBreakpoint(display: string): void;
11+
displayBreakpoint(display: any): void;
1112
}

‎dist/aside/app-aside.component.js

Lines changed: 15 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/aside/app-aside.component.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coreui/angular",
3-
"version": "0.0.1",
3+
"version": "2.0.0-alpha.1",
44
"peerDependencies": {
55
"@angular/common": "*",
66
"@angular/compiler": "*",

‎dist/sidebar/app-sidebar-nav.component.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/sidebar/app-sidebar-nav.component.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/sidebar/app-sidebar.component.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { OnInit } from '@angular/core';
22
export declare class AppSidebarComponent implements OnInit {
33
compact: boolean;
4-
display: string;
4+
display: any;
55
fixed: boolean;
66
minimized: boolean;
77
offCanvas: boolean;
@@ -13,5 +13,5 @@ export declare class AppSidebarComponent implements OnInit {
1313
isMinimized(minimized: boolean): void;
1414
isOffCanvas(offCanvas: boolean): void;
1515
fixedPosition(fixed: boolean): void;
16-
displayBreakpoint(display: string): void;
16+
displayBreakpoint(display: any): void;
1717
}

‎dist/sidebar/app-sidebar.component.js

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/sidebar/app-sidebar.component.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coreui/angular-dev",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-beta.0",
44
"devDependencies": {
55
"@angular/common": "5.2.6",
66
"@angular/compiler": "^5.2.6",
@@ -9,7 +9,7 @@
99
"@angular/platform-browser": "5.2.6",
1010
"@angular/platform-browser-dynamic": "5.2.6",
1111
"@angular/router": "5.2.6",
12-
"@coreui/styles": "^1.0.0-alpha.9",
12+
"@coreui/coreui": "^2.0.0-beta.4",
1313
"@types/chai": "^4.1.2",
1414
"@types/jasmine": "^2.8.6",
1515
"@types/webpack": "^3.8.8",

‎src/aside/app-aside.component.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, Input, OnInit } from '@angular/core';
2-
import { asideMenuCssClasses } from './../shared';
1+
import { Component, ElementRef, Input, OnInit } from '@angular/core';
2+
import { asideMenuCssClasses, Replace } from './../shared';
33

44
@Component({
55
selector: 'app-aside',
@@ -10,13 +10,14 @@ import { asideMenuCssClasses } from './../shared';
1010
`
1111
})
1212
export class AppAsideComponent implements OnInit {
13-
@Input() display: string;
13+
@Input() display: any;
1414
@Input() fixed: boolean;
1515
@Input() offCanvas: boolean;
1616

17-
constructor() { }
17+
constructor(private el: ElementRef) {}
1818

1919
ngOnInit() {
20+
Replace(this.el);
2021
this.isFixed(this.fixed);
2122
this.displayBreakpoint(this.display);
2223
}
@@ -29,9 +30,11 @@ export class AppAsideComponent implements OnInit {
2930
if (this.offCanvas) { document.querySelector('body').classList.add('aside-menu-off-canvas'); }
3031
}
3132

32-
displayBreakpoint(display: string): void {
33-
let cssClass;
34-
this.display ? cssClass = `aside-menu-${this.display}-show` : cssClass = asideMenuCssClasses[0];
35-
document.querySelector('body').classList.add(cssClass);
33+
displayBreakpoint(display: any): void {
34+
if (this.display !== false ) {
35+
let cssClass;
36+
this.display ? cssClass = `aside-menu-${this.display}-show` : cssClass = asideMenuCssClasses[0];
37+
document.querySelector('body').classList.add(cssClass);
38+
}
3639
}
3740
}

‎src/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "@coreui/angular",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-beta.0",
4+
"dependencies": {
5+
"@coreui/coreui": "^2.0.0-beta.4",
6+
},
47
"peerDependencies": {
58
"@angular/common": "*",
69
"@angular/compiler": "*",

‎src/sidebar/app-sidebar-nav.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ export class AppSidebarNavLinkComponent implements OnInit {
172172
<app-sidebar-nav-item [item]='child'></app-sidebar-nav-item>
173173
</ng-template>
174174
</ul>
175-
`
175+
`,
176+
styles: ['.nav-dropdown-toggle { cursor: pointer; }']
176177
})
177178
export class AppSidebarNavDropdownComponent implements OnInit {
178179
@Input() link: any;

‎src/sidebar/app-sidebar.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { sidebarCssClasses } from './../shared';
77
})
88
export class AppSidebarComponent implements OnInit {
99
@Input() compact: boolean;
10-
@Input() display: string;
10+
@Input() display: any;
1111
@Input() fixed: boolean;
1212
@Input() minimized: boolean;
1313
@Input() offCanvas: boolean;
@@ -44,9 +44,11 @@ export class AppSidebarComponent implements OnInit {
4444
if (this.fixed) { document.querySelector('body').classList.add('sidebar-fixed'); }
4545
}
4646

47-
displayBreakpoint(display: string): void {
48-
let cssClass;
49-
this.display ? cssClass = `sidebar-${this.display}-show` : cssClass = sidebarCssClasses[0];
50-
document.querySelector('body').classList.add(cssClass);
47+
displayBreakpoint(display: any): void {
48+
if (this.display !== false ) {
49+
let cssClass;
50+
this.display ? cssClass = `sidebar-${this.display}-show` : cssClass = sidebarCssClasses[0];
51+
document.querySelector('body').classList.add(cssClass);
52+
}
5153
}
5254
}

0 commit comments

Comments
 (0)
Please sign in to comment.