Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function AcuantCapture(
<div className="margin-top-2">
{isMobile && (
<Button
isSecondary={!value}
isOutline={!value}
isUnstyled={!!value}
onClick={startCaptureOrTriggerUpload}
className={value ? 'margin-right-1' : 'margin-right-2'}
Expand Down
29 changes: 14 additions & 15 deletions app/javascript/packages/document-capture/components/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
/**
* @typedef ButtonProps
*
* @prop {ButtonType=} type Button type, defaulting to "button".
* @prop {(ReactMouseEvent)=>void=} onClick Click handler.
* @prop {ReactNode=} children Element children.
* @prop {boolean=} isPrimary Whether button should be styled as primary button.
* @prop {boolean=} isSecondary Whether button should be styled as secondary button.
* @prop {boolean=} isDisabled Whether button is disabled.
* @prop {boolean=} isUnstyled Whether button should be unstyled, visually as a
* link.
* @prop {boolean=} isVisuallyDisabled Whether button should appear disabled (but
* remain clickable).
* @prop {string=} className Optional additional class names.
* @prop {ButtonType=} type Button type, defaulting to "button".
* @prop {(ReactMouseEvent)=>void=} onClick Click handler.
* @prop {ReactNode=} children Element children.
* @prop {boolean=} isWide Whether button should be styled as primary button.
* @prop {boolean=} isOutline Whether button should be styled as secondary button.
* @prop {boolean=} isDisabled Whether button is disabled.
* @prop {boolean=} isUnstyled Whether button should be unstyled, visually as a link.
* @prop {boolean=} isVisuallyDisabled Whether button should appear disabled (but remain clickable).
* @prop {string=} className Optional additional class names.
*/

/**
Expand All @@ -25,17 +23,18 @@ function Button({
type = 'button',
onClick,
children,
isPrimary,
isSecondary,
isWide,
isOutline,
isDisabled,
isUnstyled,
isVisuallyDisabled,
className,
}) {
const classes = [
'btn',
isPrimary && 'btn-primary btn-wide',
isSecondary && 'btn-secondary',
isWide && 'btn-wide',
!isOutline && !isUnstyled && 'btn-primary',
isOutline && 'btn-secondary',
isUnstyled && 'btn-link',
isVisuallyDisabled && 'btn-disabled',
className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function FormSteps({
/>
<Button
type="submit"
isPrimary
isWide
className="display-block margin-y-5"
isVisuallyDisabled={!canContinue}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('document-capture/components/button', () => {
expect(button.nodeName).to.equal('BUTTON');
expect(button.type).to.equal('button');
expect(button.classList.contains('btn')).to.be.true();
expect(button.classList.contains('btn-primary')).to.be.false();
expect(button.classList.contains('btn-primary')).to.be.true();
expect(button.classList.contains('btn-secondary')).to.be.false();
expect(button.classList.contains('btn-wide')).to.be.false();
expect(button.classList.contains('btn-link')).to.be.false();
Expand All @@ -32,8 +32,8 @@ describe('document-capture/components/button', () => {
expect(onClick.getCall(0).args[0]).to.equal('click');
});

it('renders as primary', () => {
const { getByText } = render(<Button isPrimary>Click me</Button>);
it('renders as wide', () => {
const { getByText } = render(<Button isWide>Click me</Button>);

const button = getByText('Click me');

Expand All @@ -43,8 +43,8 @@ describe('document-capture/components/button', () => {
expect(button.classList.contains('btn-link')).to.be.false();
});

it('renders as secondary', () => {
const { getByText } = render(<Button isSecondary>Click me</Button>);
it('renders as outline', () => {
const { getByText } = render(<Button isOutline>Click me</Button>);

const button = getByText('Click me');

Expand Down