Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #81 from Ultimaker/form-disable-button
Browse files Browse the repository at this point in the history
Making the popup and form components more flexible
  • Loading branch information
Alan authored Oct 23, 2018
2 parents 30f8030 + 9dfccc0 commit d34a3bd
Show file tree
Hide file tree
Showing 15 changed files with 398 additions and 241 deletions.
123 changes: 56 additions & 67 deletions src/components/__tests__/__snapshots__/about_dialog.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,68 @@ exports[`The AboutDialog component should render 1`] = `
<div
className="about-dialog"
>
<Modal
onOverlayClickHandler={[MockFunction]}
<PopupBase
headerText="About test app"
width="md"
>
<Tile
align="left"
padding="md"
>
<div
className="about-dialog__header"
<p>
Version: 1.0.0
</p>
<p>
For support visit:
   
<a
href="https://ultimaker.support.com/"
target="_blank"
>
About test app
</div>
<p>
Version: 1.0.0
</p>
<p>
For support visit:
   
<a
href="https://ultimaker.support.com/"
target="_blank"
Support link
</a>
</p>
<p>
test app uses the following Open Source components:
</p>
<table
className="about-components-list"
>
<tbody>
<tr
key="testComponent"
>
Support link
</a>
</p>
<p>
test app uses the following Open Source components:
</p>
<table
className="about-components-list"
>
<tbody>
<tr
key="testComponent"
<td
className="about-component-name"
>
<td
className="about-component-name"
<a
href="https://ultimaker.com/"
target="_blank"
>
<a
href="https://ultimaker.com/"
target="_blank"
>
testComponent
</a>
</td>
<td
className="about-component-license"
testComponent
</a>
</td>
<td
className="about-component-license"
>
<a
href="https://spdx.org/licenses/MIT.html"
target="_blank"
>
<a
href="https://spdx.org/licenses/MIT.html"
target="_blank"
>
license MIT
</a>
</td>
</tr>
</tbody>
</table>
<div
className="about-dialog__btn"
license MIT
</a>
</td>
</tr>
</tbody>
</table>
<FormActions>
<Button
className=""
linkToNewTab={false}
onClickHandler={[MockFunction]}
shape="rectangle"
style="primary"
type="button"
>
<Button
className=""
linkToNewTab={false}
onClickHandler={[MockFunction]}
shape="rectangle"
style="primary"
type="button"
>
Close
</Button>
</div>
</Tile>
</Modal>
Close
</Button>
</FormActions>
</PopupBase>
</div>
`;
74 changes: 36 additions & 38 deletions src/components/__tests__/__snapshots__/form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,18 @@ exports[`The Form component should render 1`] = `
noValidate={true}
onSubmit={[Function]}
>
<div
className="form__actions"
>
<div
className="form__btn-container"
<FormActions>
<Button
className=""
disabled={true}
linkToNewTab={false}
shape="rectangle"
style="primary"
type="submit"
>
<Button
className=""
disabled={true}
linkToNewTab={false}
shape="rectangle"
style="primary"
type="submit"
>
primaryBtnText
</Button>
</div>
</div>
primaryBtnText
</Button>
</FormActions>
</form>
`;

Expand Down Expand Up @@ -107,35 +101,39 @@ exports[`The Form component should render with a form item 1`] = `
</TextField>
</InputField>
</div>
<div
className="form__actions"
>
<FormActions>
<div
className="form__btn-container"
className="form__actions"
>
<Button
className=""
disabled={true}
linkToNewTab={false}
shape="rectangle"
style="primary"
type="submit"
<div
className="form__btn-container"
key="0"
>
<button
className="btn btn--primary btn--rectangle disabled"
<Button
className=""
disabled={true}
onClick={[Function]}
key=".0"
linkToNewTab={false}
shape="rectangle"
style="primary"
type="submit"
>
<span
className="text"
<button
className="btn btn--primary btn--rectangle disabled"
disabled={true}
onClick={[Function]}
type="submit"
>
primaryBtnText
</span>
</button>
</Button>
<span
className="text"
>
primaryBtnText
</span>
</button>
</Button>
</div>
</div>
</div>
</FormActions>
</form>
</Form>
`;
38 changes: 38 additions & 0 deletions src/components/__tests__/__snapshots__/form_actions.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The form actions component should render its children 1`] = `
<div
className="form__actions"
>
<div
className="form__btn-container"
key="0"
>
<Button
className=""
key=".0"
linkToNewTab={false}
shape="rectangle"
style="primary"
type="button"
>
First Button
</Button>
</div>
<div
className="form__btn-container"
key="1"
>
<Button
className=""
key=".1"
linkToNewTab={false}
shape="rectangle"
style="primary"
type="button"
>
Second Button
</Button>
</div>
</div>
`;
52 changes: 16 additions & 36 deletions src/components/__tests__/__snapshots__/popup.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The Popup component should render a confirm popup 1`] = `
<div
className="popup"
<PopupBase
headerText="Popup header"
width="sm"
>
<Modal
width="sm"
<p
key="0"
>
<div
className="popup__container"
>
<div
className="popup__content"
>
<div
className="popup__header"
>
Popup header
</div>
<div
className="popup__body"
>
<p
key="0"
>
Popup body
</p>
<Form
alwaysEnableSubmitButton={true}
onSubmitHandler={[Function]}
primaryBtnShowSpinner={false}
primaryBtnText="Primary button"
secondaryBtnHandler={[Function]}
secondaryBtnShowSpinner={false}
/>
</div>
</div>
</div>
</Modal>
</div>
Popup body
</p>
<Form
alwaysEnableSubmitButton={true}
onSubmitHandler={[Function]}
primaryBtnShowSpinner={false}
primaryBtnText="Primary button"
secondaryBtnHandler={[Function]}
secondaryBtnShowSpinner={false}
/>
</PopupBase>
`;
28 changes: 28 additions & 0 deletions src/components/__tests__/__snapshots__/popup_base.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The PopupBase component should render a modal 1`] = `
<div
className="popup"
>
<Modal
width="sm"
>
<div
className="popup__container"
>
<div
className="popup__content"
>
<div
className="popup__header"
>
PopupBase header
</div>
<div
className="popup__body"
/>
</div>
</div>
</Modal>
</div>
`;
24 changes: 24 additions & 0 deletions src/components/__tests__/form_actions.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2018 Ultimaker B.V.
import * as React from 'react';
import { shallow, mount } from 'enzyme';

// component
import FormActions from '../form_actions';
import Button from '../button';

describe('The form actions component', () => {
let wrapper;

beforeEach(() => {
wrapper = shallow(
<FormActions>
<Button>First Button</Button>
<Button>Second Button</Button>
</FormActions>
);
});

it('should render its children', () => {
expect(wrapper).toMatchSnapshot();
});
});
Loading

0 comments on commit d34a3bd

Please sign in to comment.