Skip to content

Commit

Permalink
fix(core/wizard): Fix header icons at smaller widths
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Reynolds committed Apr 10, 2018
1 parent be938ab commit 71d978f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 20 additions & 5 deletions app/scripts/modules/core/src/modal/wizard/WizardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface IWizardPageProps {
}

export interface IWizardPageState {
hasErrors: boolean;
isDirty: boolean;
label: string;
}

Expand All @@ -41,6 +43,8 @@ export function wizardPage<P = {}>(
constructor(props: P & IWizardPageProps) {
super(props);
this.state = {
hasErrors: false,
isDirty: false,
label: WizardPage.label,
};
}
Expand All @@ -53,6 +57,13 @@ export function wizardPage<P = {}>(
this.props.onMount(undefined);
}

private dirtyCallback(name: string, dirty: boolean): void {
if (name === this.state.label) {
this.setState({ isDirty: dirty });
this.props.dirtyCallback(name, dirty);
}
}

private handleRef(element: any) {
if (element) {
this.element = element;
Expand All @@ -61,17 +72,21 @@ export function wizardPage<P = {}>(

private handleWrappedRef(wrappedComponent: any) {
if (wrappedComponent) {
this.validate = wrappedComponent.validate;
this.validate = (values: { [key: string]: any }) => {
const errors = wrappedComponent.validate(values);
this.setState({ hasErrors: Object.keys(errors).length > 0 });
return errors;
}
}
}

public render() {
const { dirtyCallback, dirty, done, mandatory } = this.props;
const { label } = this.state;
const { done, mandatory } = this.props;
const { hasErrors, isDirty, label } = this.state;
const showDone = done || !mandatory;
const className = classNames({
default: !showDone,
dirty,
dirty: hasErrors || isDirty,
done: showDone,
});

Expand All @@ -81,7 +96,7 @@ export function wizardPage<P = {}>(
<h4 className={className}>{label}</h4>
</div>
<div className="wizard-page-body">
<WrappedComponent {...this.props} dirtyCallback={dirtyCallback} ref={this.handleWrappedRef} />
<WrappedComponent {...this.props} dirtyCallback={this.dirtyCallback} ref={this.handleWrappedRef} />
</div>
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/core/src/modal/wizard/modalWizard.less
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ v2-modal-wizard, .wizard-modal {
background-color: var(--color-dovegray);
content: '';
transition: 0.25s;
font-size: 15px;
}
&.done {
&:before {
Expand All @@ -122,6 +123,7 @@ v2-modal-wizard, .wizard-modal {
color: var(--color-danger);
background-color: transparent;
content: "\e088";
font-family: 'Glyphicons Halflings';
}
}
&.waiting {
Expand Down

0 comments on commit 71d978f

Please sign in to comment.