Skip to content

Commit

Permalink
Merge pull request #226 from data-driven-forms/fix-pf4-buttons-spacing
Browse files Browse the repository at this point in the history
fix(pf4): updated form buttons to fix spacing.
  • Loading branch information
rvsia authored Nov 13, 2019
2 parents ccfb137 + dc40ea7 commit ae92d5e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 88 deletions.
2 changes: 1 addition & 1 deletion packages/pf4-component-mapper/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@patternfly/patternfly@2.5.0/patternfly-base.css"/>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@patternfly/patternfly@2.41.0/patternfly-base.css"/>
<title>Data driven forms</title>
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@
grid-column-end: 12;
align-self: end;
}

.data-driven-forms__pf4-button-group {
margin-bottom: 16px
}
16 changes: 5 additions & 11 deletions packages/pf4-component-mapper/src/form-fields/layout-components.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { layoutComponents } from '@data-driven-forms/react-form-renderer';
import { Form, Toolbar, ToolbarGroup, ToolbarItem, Button, ActionGroup, TextContent, Text, TextVariants } from '@patternfly/react-core';
import { Form, Button, ActionGroup, TextContent, Text, TextVariants } from '@patternfly/react-core';
import './layout-components-styles.scss';

const ButtonLayout = ({ label, bsStyle, children, ...props }) =>
<ToolbarGroup className="data-driven-forms__pf4-button-group">
<ToolbarItem>
<Button variant={ bsStyle || 'secondary' } { ...props }>
{ label }{ children }
</Button>
</ToolbarItem>
</ToolbarGroup>;
<Button variant={ bsStyle || 'secondary' } { ...props }>
{ label }{ children }
</Button>;

ButtonLayout.propTypes = {
label: PropTypes.string.isRequired,
Expand All @@ -24,9 +20,7 @@ ButtonLayout.propTypes = {

const ButtonGroupLayout = ({ children, ...props }) =>
<ActionGroup { ...props } >
<Toolbar>
{ children }
</Toolbar>
{ children }
</ActionGroup>;

ButtonGroupLayout.propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,80 +660,60 @@ exports[`FieldArray should render array field correctly 1`] = `
<div
className="pf-c-form__actions"
>
<Toolbar>
<div
className="pf-l-toolbar"
<ButtonLayout
key="form-submit"
label="Submit"
onClick={[Function]}
type="button"
variant="primary"
>
<Component
onClick={[Function]}
type="button"
variant="primary"
>
<ButtonLayout
key="form-submit"
label="Submit"
onClick={[Function]}
type="button"
variant="primary"
<ComponentWithOuia
component={[Function]}
componentProps={
Object {
"children": Array [
"Submit",
undefined,
],
"disabled": undefined,
"onClick": [Function],
"type": "button",
"variant": "primary",
}
}
consumerContext={null}
>
<ToolbarGroup
className="data-driven-forms__pf4-button-group"
<Button
onClick={[Function]}
ouiaContext={
Object {
"isOuia": false,
"ouiaId": null,
}
}
type="button"
variant="primary"
>
<div
className="pf-l-toolbar__group data-driven-forms__pf4-button-group"
<button
aria-disabled={null}
aria-label={null}
className="pf-c-button pf-m-primary"
disabled={false}
onClick={[Function]}
tabIndex={null}
type="button"
>
<ToolbarItem>
<div
className="pf-l-toolbar__item"
>
<Component
onClick={[Function]}
type="button"
variant="primary"
>
<ComponentWithOuia
component={[Function]}
componentProps={
Object {
"children": Array [
"Submit",
undefined,
],
"disabled": undefined,
"onClick": [Function],
"type": "button",
"variant": "primary",
}
}
consumerContext={null}
>
<Button
onClick={[Function]}
ouiaContext={
Object {
"isOuia": false,
"ouiaId": null,
}
}
type="button"
variant="primary"
>
<button
aria-disabled={null}
aria-label={null}
className="pf-c-button pf-m-primary"
disabled={false}
onClick={[Function]}
tabIndex={null}
type="button"
>
Submit
</button>
</Button>
</ComponentWithOuia>
</Component>
</div>
</ToolbarItem>
</div>
</ToolbarGroup>
</ButtonLayout>
</div>
</Toolbar>
Submit
</button>
</Button>
</ComponentWithOuia>
</Component>
</ButtonLayout>
</div>
</div>
</ActionGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from 'enzyme';
import { Toolbar, Button, ActionGroup, TextContent, Text } from '@patternfly/react-core';
import { Button, ActionGroup, TextContent, Text } from '@patternfly/react-core';
import { layoutComponents } from '@data-driven-forms/react-form-renderer';
import layoutMapper from '../form-fields/layout-components';

Expand All @@ -9,7 +9,6 @@ describe('Layout mapper', () => {
});

it('should return PF4 ButtonGroup', () => {
expect(mount(layoutMapper[layoutComponents.BUTTON_GROUP]({})).find(Toolbar)).toHaveLength(1);
expect(mount(layoutMapper[layoutComponents.BUTTON_GROUP]({})).find(ActionGroup)).toHaveLength(1);
});

Expand Down

0 comments on commit ae92d5e

Please sign in to comment.