Skip to content

Commit

Permalink
Merge pull request scandipwa#5206 from matesich/ts-migration
Browse files Browse the repository at this point in the history
TS fixes
  • Loading branch information
AleksandrsKondratjevs authored Oct 14, 2022
2 parents fb13746 + b27afe8 commit d37167c
Show file tree
Hide file tree
Showing 33 changed files with 160 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
text-align: end;
opacity: 0;
animation: appear 100ms 300ms forwards;
min-height: 45px;
display: flex;
align-items: center;
justify-content: flex-end;

@include mobile {
text-align: start;
Expand All @@ -64,7 +68,7 @@
align-items: center;
align-content: center;
}

.FieldSelect {
&-SortSelect {
font-size: 16px;
Expand All @@ -73,7 +77,7 @@
@include desktop {
display: none;
}
}
}
}

.ChevronIcon {
Expand All @@ -82,7 +86,7 @@
inset-inline-end: 0;

@supports (-webkit-touch-callout: none) {
/* CSS specific to iOS devices */
/* CSS specific to iOS devices */
inset-block-start: 3px;
}
}
Expand Down Expand Up @@ -113,7 +117,7 @@
}
}

.Field {
.Field {
&-LabelContainer {
.ChevronIcon {
margin-block-start: 3px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ export class ClickOutsideComponent extends PureComponent<ClickOutsideComponentPr

this.handleClick = this.handleClick.bind(this);

this.childrenRefs = Children.map(
children,
this.childrenRefs = Children.toArray(children).map(
() => createRef<HTMLElement>(),
) || [];
}

componentDidMount(): void {
document.addEventListener('click', this.handleClick);
/*
* delaying adding the clickoutside event because of the issue with popup,
* where event was triggered immediatly
* vvv
*/
setTimeout(() => {
document.addEventListener('click', this.handleClick);
}, 0);
}

componentWillUnmount(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
margin: 0;
opacity: 1;
padding-inline-start: 0;
line-height: 23px;
line-height: 20px;
min-height: 0;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/scandipwa/src/component/Field/Field.style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
}
}

&_numberWithControls {
&_number_with_controls {
align-items: center;
display: inline-flex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

.Field {
&_type {
&_numberWithControls {
&_number_with_controls {
[type="number"] {
appearance: textfield;
color: var(--color-black);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ $select-arrow-width: 14px !default;
cursor: pointer;
display: flex;
align-items: center;

#storeSwitcher,
#CurrencySwitcherList {
line-height: 20px;

@include mobile {
border-bottom: 1px solid var(--primary-divider-color);
}
}
}

.ChevronIcon {
Expand All @@ -48,7 +39,6 @@ $select-arrow-width: 14px !default;

&-Select {
width: 100%;
margin-block-start: -2px;
padding-inline-end: 40px;
min-height: 30px;
height: max-content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}

.Field {
&_type_numberWithControls {
&_type_number_with_controls {
margin-block-start: 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class ListIconComponent extends PureComponent<ListIconComponentProps> {
<svg
block="ListIcon"
mods={ { isActive } }
width="27"
height="27"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class MyAccountAddressFormContainer <
}

getCurrentAddress(): InitialDataAddress {
const { address, address: { id: addressId } } = this.props;
const { address, address: { id: addressId } = {} } = this.props;

if (!addressId) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
export const getStreetFields = (props: MyAccountAddressFormProps): Partial<FieldContainerProps>[] => {
const {
addressLinesQty = 1,
address: { street = [] },
address: { street = [] } = {},
} = props;

if (addressLinesQty === 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class MyAccountAddressPopupComponent extends PureComponent<MyAccountAddre
}

renderContent(): ReactElement {
const { payload: { action } } = this.props;
const { payload: { action } = {} } = this.props;

switch (action) {
case MyAccountAddressPopupAction.EDIT_ADDRESS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ State extends NavigationAbstractContainerState,

setNavigationState(this.getNavigationState());
history.listen((history) => {
const { state } = history;

// vvv ignoring the route change for popup
if (state && state.popupOpen) {
return;
}

this.handlePageScroll();
this.setState(this.onRouteChanged(history));
});
Expand Down
5 changes: 2 additions & 3 deletions packages/scandipwa/src/component/Popup/Popup.container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { hideActiveOverlay, hideActivePopup } from 'Store/Overlay/Overlay.action
import { PopupPayload } from 'Store/Popup/Popup.type';
import { ReactElement } from 'Type/Common.type';
import { noopFn } from 'Util/Common';
import history from 'Util/History';
import { RootState } from 'Util/Store/Store.type';

import Popup from './Popup.component';
Expand Down Expand Up @@ -75,7 +76,7 @@ export class PopupContainer extends PureComponent<PopupContainerProps> {
name: Page.POPUP,
title: this._getPopupTitle(),
onCloseClick: () => {
history.back();
history.goBack();
},
});

Expand All @@ -99,7 +100,6 @@ export class PopupContainer extends PureComponent<PopupContainerProps> {
contentMix,
onClose,
onHide,
onVisible,
shouldPopupClose,
hideActiveOverlay,
resetHideActivePopup,
Expand All @@ -120,7 +120,6 @@ export class PopupContainer extends PureComponent<PopupContainerProps> {
shouldPopupClose,
onClose,
onHide,
onVisible,
hideActiveOverlay,
resetHideActivePopup,
goToPreviousNavigationState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ export class ProductComponent<P extends ProductComponentProps = ProductComponent
product: {
options,
},

updateSelectedValues,
} = this.props;

return (
<ProductCustomizableOptions
options={ options }
updateSelectedValues={ updateSelectedValues }

/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
.Field {
&-Wrapper {
&_type {
&_numberWithControls {
&_number_with_controls {
@include mobile {
display: flex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
flex: 1 1;
}

&_numberWithControls {
&_number_with_controls {
display: flex;
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@
&_customQuantity {
.Field {
&_type {
&_numberWithControls {
&_number_with_controls {
margin-inline-start: 16px;
margin-block-start: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ProductCompareComponent extends Component<ProductCompareComponentPr
return products !== nextProducts || isLoading !== nextIsLoading;
}

renderScroll() {
renderScroll(): ReactElement {
const { handleScroll, scrollerScroll, scrollerContent } = this.props;

return (
Expand Down Expand Up @@ -168,7 +168,7 @@ export class ProductCompareComponent extends Component<ProductCompareComponentPr
));
}

renderProducts() {
renderProducts(): ReactElement {
const { handleBlockScroll, productCompare, productCompareRow } = this.props;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
--product-compare-sidebar-padding: 30px;
--product-compare-item-count: 3.2;
--product-compare-item-gap: 15px;
--prouduct-compare-additional-gap: 18px;
--product-compare-column-width: calc(300px + var(--product-compare-item-gap) * 2);
}

Expand Down Expand Up @@ -72,7 +71,9 @@
}

@include mobile {
padding: 0;
&:last-child {
padding-inline-end: var(--product-compare-item-gap);
}
}
}

Expand All @@ -91,7 +92,7 @@
align-items: center;
position: sticky;
inset-inline-start: 0;
max-width: calc(var(--product-compare-sidebar-width) + var(--product-compare-item-gap));
max-width: var(--product-compare-sidebar-width);

@include mobile {
display: none;
Expand Down Expand Up @@ -132,6 +133,10 @@

@include mobile {
margin-block-start: 26px;

&:last-child {
padding-inline-end: var(--product-compare-item-gap);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

flex: 0 0 auto;
padding-block: 0;
padding-inline: var(--product-compare-item-gap) calc(var(--product-compare-item-gap) + var(--prouduct-compare-additional-gap));
padding-inline: var(--product-compare-item-gap) var(--product-compare-item-gap);
width: var(--product-compare-column-width);
text-align: justify;

Expand All @@ -66,6 +66,12 @@
&:last-child {
padding-inline-end: 0;
}

@include mobile {
&:last-child {
padding-inline-end: var(--product-compare-item-gap);
}
}
}

&-OutOfStock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
.ProductCompareItem {
display: flex;
flex-direction: column;
padding: 10px;
padding: var(--product-compare-item-gap);
padding-inline-end: 0;
position: relative;
height: 100%;
min-height: 100px;
Expand Down Expand Up @@ -45,13 +46,10 @@

&-Actions {
display: flex;
justify-content: space-between;
align-items: center;
}

.ProductWishlistButton {
margin-inline: 16px;
}

&-Title {
flex: 1;
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ P extends ProductConfigurableAttributesComponentProps = ProductConfigurableAttri
attribute_id,
} = option;
const isUnselected = addToCartTriggeredWithError ? !parameters[attribute_code] : false;
const [{ swatch_data }] = attribute_options
const [{ swatch_data }] = Object.values(attribute_options).length
? Object.values(attribute_options)
: [{ swatch_data: undefined }];
const isSwatch = !!swatch_data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
height: 500px;
margin-inline: 45px;

@include ultra-narrow-desktop {
min-width: 332px;
}

@include narrow-desktop {
min-width: 507px;
min-width: 482px;
}

@include mobile {
Expand Down
Loading

0 comments on commit d37167c

Please sign in to comment.