Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fullWidth prop to EuiButton #1665

Merged
merged 4 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src-docs/src/views/form_layouts/inline_popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default class extends Component {
name="poprange"
/>
</EuiFormRow>
<EuiButton fullWidth>Save</EuiButton>
</EuiForm>
);

Expand Down
15 changes: 15 additions & 0 deletions src/components/button/__snapshots__/button.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ exports[`EuiButton props fill is rendered 1`] = `
</button>
`;

exports[`EuiButton props fullWidth is rendered 1`] = `
<button
class="euiButton euiButton--primary euiButton--fullWidth"
type="button"
>
<span
class="euiButton__content"
>
<span
class="euiButton__text"
/>
</span>
</button>
`;

exports[`EuiButton props href secures the rel attribute when the target is _blank 1`] = `
<a
class="euiButton euiButton--primary"
Expand Down
5 changes: 5 additions & 0 deletions src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,8 @@ $buttonTypes: (
}
}
}

.euiButton--fullWidth {
display: block;
width: 100%;
}
7 changes: 7 additions & 0 deletions src/components/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const EuiButton = ({
buttonRef,
contentProps,
textProps,
fullWidth,
...rest
}) => {

Expand All @@ -69,6 +70,7 @@ export const EuiButton = ({
className,
{
'euiButton--fill': fill,
'euiButton--fullWidth': fullWidth,
},
);

Expand Down Expand Up @@ -162,6 +164,11 @@ EuiButton.propTypes = {
*/
color: PropTypes.oneOf(COLORS),
size: PropTypes.oneOf(SIZES),

/**
* Expands button to fill the width of the parent
*/
fullWidth: PropTypes.bool,
isDisabled: PropTypes.bool,
href: PropTypes.string,
target: PropTypes.string,
Expand Down
11 changes: 11 additions & 0 deletions src/components/button/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ describe('EuiButton', () => {
});
});

describe('fullWidth', () => {
it('is rendered', () => {
const component = render(
<EuiButton fullWidth />
);

expect(component)
.toMatchSnapshot();
});
});

describe('iconType', () => {
it('is rendered', () => {
const component = render(
Expand Down
1 change: 1 addition & 0 deletions src/components/button/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ declare module '@elastic/eui' {
size?: ButtonSize;
isLoading?: boolean;
isDisabled?: boolean;
fullWidth?: boolean;
contentProps?: HTMLAttributes<HTMLSpanElement>;
textProps?: HTMLAttributes<HTMLSpanElement>;
}
Expand Down