Skip to content

Commit

Permalink
feat(UISrefActive): pass down className
Browse files Browse the repository at this point in the history
UISrefActive now passes down `className`props to its child component together with the computed props
  • Loading branch information
elboman committed Jul 24, 2018
1 parent 103b57b commit fbb8152
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/components/UISrefActive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface UISrefActiveProps {
class?: string;
exact?: Boolean;
children?: any;
className?: string;
}

export interface UISrefActiveState {
Expand Down Expand Up @@ -51,6 +52,7 @@ class SrefActive extends Component<UISrefActiveProps, any> {
router: PropTypes.object.isRequired,
class: PropTypes.string.isRequired,
children: PropTypes.element.isRequired,
className: PropTypes.string,
};

state = {
Expand Down Expand Up @@ -137,12 +139,13 @@ class SrefActive extends Component<UISrefActiveProps, any> {

render() {
const { activeClasses } = this.state;
const { className } = this.props;
const children =
activeClasses.length > 0
? cloneElement(
this.props.children,
Object.assign({}, this.props.children.props, {
className: classNames(this.props.children.props.className, activeClasses),
className: classNames(className, this.props.children.props.className, activeClasses),
})
)
: this.props.children;
Expand Down
6 changes: 3 additions & 3 deletions src/components/UIView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export interface UIViewInjectedProps {

/** Component Props for `UIView` */
export interface UIViewProps {
router: UIRouterReact;
parentUIView: UIViewAddress;
router?: UIRouterReact;
parentUIView?: UIViewAddress;
name?: string;
className?: string;
style?: Object;
Expand Down Expand Up @@ -268,7 +268,7 @@ class View extends Component<UIViewProps, UIViewState> {
}
}

export class UIView extends React.Component {
export class UIView extends React.Component<UIViewProps, any> {
static displayName = 'UIView';
static __internalViewComponent: React.ComponentClass<UIViewProps> = View;

Expand Down

0 comments on commit fbb8152

Please sign in to comment.