Skip to content

Commit

Permalink
Undo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harshil1793 committed Sep 18, 2023
1 parent 0f70d67 commit 94a5d0a
Showing 1 changed file with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Element, State, Event, EventEmitter, Host, h, Prop, Listen } from '@stencil/core';
import { Component, Event, EventEmitter, Host, h, Prop, Listen } from '@stencil/core';

/**
* @componentName Button pair
Expand All @@ -12,7 +12,7 @@ import { Component, Element, State, Event, EventEmitter, Host, h, Prop, Listen }
shadow: true,
})
export class VaButtonPair {
@Element() el: HTMLElement;
// @Element() el: HTMLElement;

/**
* If `true`, button pair will use Continue and Back for button text.
Expand Down Expand Up @@ -77,11 +77,11 @@ export class VaButtonPair {
})
componentLibraryAnalytics: EventEmitter;

@Listen('resize', { target: 'window' })
handleResize() {
this.reorderButtons();
}
@State() isReordered: boolean = false;
// @Listen('resize', { target: 'window' })
// handleResize() {
// this.reorderButtons();
// }
// @State() isReordered: boolean = false;

/**
* Listen for the va-button GA event and capture it so
Expand Down Expand Up @@ -118,30 +118,30 @@ export class VaButtonPair {
this.secondaryClick.emit(e);
};

componentDidLoad() {
this.reorderButtons();
}
// componentDidLoad() {
// this.reorderButtons();
// }

reorderButtons() {
let container;
let buttons;
// reorderButtons() {
// let container;
// let buttons;

const groupSelector = this.uswds ? '.usa-button-group' : '.button-group';
const buttonSelector = this.uswds ? '.usa-button-group__item' : 'va-button';
// const groupSelector = this.uswds ? '.usa-button-group' : '.button-group';
// const buttonSelector = this.uswds ? '.usa-button-group__item' : 'va-button';

container = this.el.shadowRoot.querySelector(groupSelector);
buttons = Array.from(container.querySelectorAll(buttonSelector));
// container = this.el.shadowRoot.querySelector(groupSelector);
// buttons = Array.from(container.querySelectorAll(buttonSelector));

const reverseAndAppendButtons = () => {
buttons.reverse();
buttons.forEach(button => container.appendChild(button));
};
// const reverseAndAppendButtons = () => {
// buttons.reverse();
// buttons.forEach(button => container.appendChild(button));
// };

if ((window.innerWidth <= 480 && !this.isReordered) || (window.innerWidth > 480 && this.isReordered)) {
reverseAndAppendButtons();
this.isReordered = !this.isReordered;
}
}
// if ((window.innerWidth <= 480 && !this.isReordered) || (window.innerWidth > 480 && this.isReordered)) {
// reverseAndAppendButtons();
// this.isReordered = !this.isReordered;
// }
// }

render() {
const {
Expand Down Expand Up @@ -186,7 +186,7 @@ export class VaButtonPair {
} else {
return (
<Host>
<div class="button-group">
{/* <div class="button-group"> */}
<va-button
back
disable-analytics={disableAnalytics}
Expand All @@ -200,7 +200,7 @@ export class VaButtonPair {
onClick={handlePrimaryClick}
submit={submit}
/>
</div>
{/* </div> */}
</Host>
);
}
Expand Down

0 comments on commit 94a5d0a

Please sign in to comment.