Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 5509e3e

Browse files
committed
build it on CI, and make base widget better
1 parent cefa010 commit 5509e3e

File tree

4 files changed

+55
-10
lines changed

4 files changed

+55
-10
lines changed

.circleci/config.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
- image: projectstorm/react-diagrams-ci
10+
11+
working_directory: ~/repo
12+
13+
steps:
14+
- checkout
15+
16+
# Download and cache dependencies
17+
- restore_cache:
18+
keys:
19+
- v1-dependencies-{{ checksum "package.json" }}
20+
21+
- run: yarn install
22+
23+
- save_cache:
24+
paths:
25+
- node_modules
26+
key: v1-dependencies-{{ checksum "package.json" }}
27+
28+
# run tests!
29+
- run: yarn run build:ts:prod

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PATH_add ./node_modules/.bin
2+

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# STORM React Core (WIP)
1+
# STORM React Core
2+
3+
4+
[![NPM](https://img.shields.io/npm/v/storm-react-forms.svg)](https://npmjs.org/package/@projectstorm/react-core)
5+
[![NPM](https://img.shields.io/npm/dt/storm-react-forms.svg)](https://npmjs.org/package/@projectstorm/react-core)
6+
[![CircleCI](https://circleci.com/gh/projectstorm/react-core/tree/master.svg?style=svg)](https://circleci.com/gh/projectstorm/react-core/tree/master)
7+
8+
Base project for all the storm projects. It contains a bunch of helper widgets, tools and typescript
9+
objects for make glorius consistency.
210

src/widgets/BaseWidget.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface BaseWidgetProps {
1717
extraProps?: any;
1818
}
1919

20-
export type BEMOptions = string | { [selector: string]: boolean };
20+
export type BEMOptions = string | string[] | { [selector: string]: boolean };
2121

2222
export class BaseWidget<P extends BaseWidgetProps = BaseWidgetProps, S = any> extends React.Component<P, S> {
2323
className: string;
@@ -32,15 +32,18 @@ export class BaseWidget<P extends BaseWidgetProps = BaseWidgetProps, S = any> ex
3232
}
3333

3434
bem(selector: BEMOptions): string {
35+
if(_.isArray(selector)){
36+
return _.map(selector, (entry) => {
37+
return this.buildClass(entry as string);
38+
}).join(' ');
39+
}
3540
if (selector && typeof selector === "object") {
3641
return _
37-
.map(selector, (value: boolean, key: string) => {
38-
if (!!value) {
39-
return this.buildClass(key);
40-
}
41-
return "";
42-
})
43-
.join(" ");
42+
.chain(selector)
43+
.filter()
44+
.map(this.buildClass.bind(this))
45+
.value()
46+
.join(' ');
4447
}
4548
return this.buildClass(selector as string);
4649
}
@@ -50,7 +53,10 @@ export class BaseWidget<P extends BaseWidgetProps = BaseWidgetProps, S = any> ex
5053
if (selector) {
5154
className += " " + this.bem(selector);
5255
}
53-
return this.buildClass() + this.props.className || "";
56+
if(this.props.className){
57+
className += " " + this.props.className;
58+
}
59+
return className;
5460
}
5561

5662
getProps(options?: BEMOptions): any {

0 commit comments

Comments
 (0)