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

Push from patch/encapsulate #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
File renamed without changes.
11 changes: 11 additions & 0 deletions src/animatedHideableDiv.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<lightning-input type="toggle" label="Same address as above?" onchange={handleToggle}
message-toggle-active="Address values will be obtained from Office fields on submit"
message-toggle-inactive="Fill out this section with new information">
</lightning-input>
<div class="box open" ontransitionstart={handleTransitionStart} ontransitionend={handleTransitionEnd}>
<template if:true={areFieldsVisible}>
<c-address-fields></c-address-fields>
</template>
</div>
</template>
35 changes: 35 additions & 0 deletions src/animatedHideableDiv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { LightningElement } from "lwc";

export default class AnimatedHideableDiv extends LightningElement {

isSameAsAbove = false;
areFieldsVisible = true;

handleToggle(event) {
this.isSameAsAbove = event.target.checked;
let box = this.template.querySelector('.box');
box.className = this.isSameAsAbove ? "box closed" : "box open";
}

handleClick() {
this.template.querySelectorAll('lightning-input').forEach(field => {
console.log(field.label);
});
}



handleTransitionStart(event) {
const state = event.target.className;
if (state === 'box open') {
this.areFieldsVisible = true;
}
}
handleTransitionEnd(event) {
const state = event.target.className;
if (state === 'box closed') {
this.areFieldsVisible = false;
}
}

}
10 changes: 1 addition & 9 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<template>
<lightning-input type="toggle" label="Same address as above?" onchange={handleToggle}
message-toggle-active="Address values will be obtained from Office fields on submit"
message-toggle-inactive="Fill out this section with new information">
</lightning-input>
<div class="box open" ontransitionstart={handleTransitionStart} ontransitionend={handleTransitionEnd}>
<template if:true={areFieldsVisible}>
<c-address-fields></c-address-fields>
</template>
</div>
<c-animated-hideable-div></c-animated-hideable-div>
<div>
<lightning-layout multiple-rows>
<lightning-layout-item padding="horizontal-small" size="6">
Expand Down