Skip to content

Commit

Permalink
fix(core/drawer|inputgroup): fixed drawer display issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirci committed Nov 28, 2024
1 parent bc56a49 commit 87e0a0c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 63 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/components/drawer/drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
visibility: hidden;

display: flex;
position: absolute;
position: fixed;
flex-flow: column nowrap;
justify-content: flex-start;
align-items: center;
transform: translateX(16rem);
opacity: 0;

max-height: 100vh;
min-height: $large-space;
background-color: var(--theme-color-1);
border-radius: $default-border-radius;

transition: all var(--theme-medium-time) ease-out;
transition: transform var(--theme-medium-time) ease-out;

.toggle {
z-index: 100;
Expand Down
48 changes: 20 additions & 28 deletions packages/core/src/components/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export class Drawer {
private divElement?: HTMLElement;

@Watch('show')
onShowChanged(newValue: boolean) {
onShowChanged(newValue: boolean, oldValue?: boolean) {
if (newValue === !!oldValue) return;
this.show = newValue !== undefined ? newValue : !this.show;
this.toggleDrawer(this.show);
}
Expand Down Expand Up @@ -120,34 +121,24 @@ export class Drawer {
}
}

private slideOutRight(el?: HTMLElement) {
if (el) {
anime({
targets: el,
duration: Drawer.duration,
translateX: [0, '16rem'],
opacity: [1, 0],
easing: 'easeInSine',
complete: () => {
el.classList.add('d-none');
},
});
}
private slideOutRight(el: HTMLElement) {
anime({
targets: el,
duration: Drawer.duration,
translateX: [0, '16rem'],
opacity: [1, 0],
easing: 'easeInSine',
});
}

private slideInRight(el?: HTMLElement) {
if (el) {
anime({
targets: el,
duration: Drawer.duration,
translateX: ['16rem', 0],
opacity: [0, 1],
easing: 'easeOutSine',
begin: () => {
el.classList.remove('d-none');
},
});
}
private slideInRight(el: HTMLElement) {
anime({
targets: el,
duration: Drawer.duration,
translateX: ['16rem', 0],
opacity: [0, 1],
easing: 'easeOutSine',
});
}

componentDidLoad() {
Expand All @@ -160,7 +151,8 @@ export class Drawer {
class={{
'drawer-container': true,
toggle: this.show,
'd-none': true,
'full-height': this.fullHeight,

}}
style={{
width: this.width === 'auto' ? this.width : `${this.width}rem`,
Expand Down
61 changes: 28 additions & 33 deletions packages/core/src/components/input-group/input-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class InputGroup {
@State() inputPaddingLeft = 0;
@State() inputPaddingRight = 0;

startSlotRef: HTMLElement;
endSlotRef: HTMLElement;

private get inputElement() {
return this.hostElement.querySelector('input') as HTMLInputElement;
}
Expand Down Expand Up @@ -61,6 +64,7 @@ export class InputGroup {
});
}


componentDidRender() {
this.prepareInputElement();
}
Expand Down Expand Up @@ -100,50 +104,41 @@ export class InputGroup {
}

private startSlotChanged() {
const slot = this.hostElement.shadowRoot.querySelector(
'slot[name="input-start"]'
);
const startPadding = this.getChildrenWidth(this.startSlotRef);

setTimeout(() => {
const startPadding = this.getChildrenWidth(slot);
if (startPadding !== 0) {
this.inputPaddingLeft = 11 + startPadding;
} else {
this.inputPaddingLeft = 0;
}

if (startPadding !== 0) {
this.inputPaddingLeft = 11 + startPadding;
} else {
this.inputPaddingLeft = 0;
}
if (!this.inputElement) {
return;
}

if (!this.inputElement) {
return;
}
const isInputInvalid =
!this.inputElement.validity.valid ||
this.inputElement.classList.contains('is-invalid');

const isInputInvalid =
!this.inputElement.validity.valid ||
this.inputElement.classList.contains('is-invalid');
const formWasValidated =
this.inputElement.form?.classList.contains('was-validated') ||
this.inputElement.form?.noValidate === false;

const formWasValidated =
this.inputElement.form?.classList.contains('was-validated') ||
this.inputElement.form?.noValidate === false;
if (formWasValidated && isInputInvalid) {
const left = this.inputPaddingLeft !== 0 ? this.inputPaddingLeft : 7;
this.inputElement.style.backgroundPosition = `left ${left}px center`;
this.inputPaddingLeft += 26;
}

if (formWasValidated && isInputInvalid) {
const left = this.inputPaddingLeft !== 0 ? this.inputPaddingLeft : 7;
this.inputElement.style.backgroundPosition = `left ${left}px center`;
this.inputPaddingLeft += 26;
}
});
}

private endSlotChanged() {
const slot = this.hostElement.shadowRoot.querySelector(
'slot[name="input-end"]'
);
this.inputPaddingRight = 15 + this.getChildrenWidth(this.endSlotRef);

setTimeout(() => {
this.inputPaddingRight = 15 + this.getChildrenWidth(slot);
});
}

private getChildrenWidth(slotElement: Element) {

if (!slotElement) {
return 0;
}
Expand All @@ -166,11 +161,11 @@ export class InputGroup {
return (
<Host class={{ disabled: this.disabled }}>
<div class="group group-start">
<slot name="input-start"></slot>
<slot ref={(el: HTMLElement) => this.startSlotRef = el} name="input-start"></slot>
</div>
<slot></slot>
<div class="group group-end">
<slot name="input-end"></slot>
<slot ref={(el: HTMLElement) => this.endSlotRef = el} name="input-end"></slot>
</div>
</Host>
);
Expand Down

0 comments on commit 87e0a0c

Please sign in to comment.