Skip to content

Commit

Permalink
WIP Edit profile view
Browse files Browse the repository at this point in the history
  • Loading branch information
gbajaj91 committed Jun 13, 2024
1 parent 1a76841 commit 075cddd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
16 changes: 15 additions & 1 deletion blocks/form-handler/form-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const SPECTRUM_COMPONENTS = [
'divider',
'button',
'progress-circle',
'overlay',
'dialog',
];

function replaceAnchorWithButton(anchor) {
Expand Down Expand Up @@ -483,7 +485,19 @@ async function buildECCForm(el) {
currentStep: 0,
farthestStep: 0,
maxStep: el.querySelectorAll('.fragment').length - 1,
payload: {},
payload: {
profiles:[{
id:'122',
firstName:'John',
lastName:'Doe',
title:'CEO',
bio:'I am a CEO',
socialMedia:[{
url:'www.linkedin.com'
}],
type:'Speaker',
}]
},
// TODO: split payload and response data handler callbacks.
response: {},
};
Expand Down
12 changes: 12 additions & 0 deletions components/profile/profile.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ h5 {
.icon-remove-circle:hover {
opacity: 1;
}
.edit-profile {
align-self: end;
}
modal{
width: 1000px;
}
.profile-edit-view {
width: 1000px;
}
`;
19 changes: 15 additions & 4 deletions components/profile/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Profile extends LitElement {
this.profile.socialMedia[index] = { url: value };
}

renderProfileForm() {
renderProfileForm(title) {
const fieldLabelsJSON = {
...defaultFieldLabels,
...(this.fieldlabels ?? {}),
Expand Down Expand Up @@ -101,7 +101,8 @@ export class Profile extends LitElement {
const quietTextfieldConfig = { size: 'xl', quiet: true };

return html`
<h2>${fieldLabelsJSON.heading}</h2>
<div class="profile-edit-view">
<h2>${title}</h2>
<div>
<div><sp-field-label size="l" required>${fieldLabelsJSON.chooseType}</sp-field-label></div>
<sp-picker label=${fieldLabelsJSON.chooseType} value=${this.profile?.type} size="l" @change=${(event) => this.updateValue('type', event.target.value)}>
Expand Down Expand Up @@ -186,13 +187,23 @@ export class Profile extends LitElement {
${this.profile?.socialMedia ? repeat(this.profile?.socialMedia, (socialMedia) => html`<p>${socialMedia.url}</p>`) : nothing}
</div>
<sp-divider></sp-divider>
<sp-button variant="primary">Save Profile</sp-button>
<overlay-trigger type="modal" class="edit-profile">
<sp-dialog-wrapper
slot="click-content"
dismiss-label="Close"
underlay
>
${this.renderProfileForm('Edit Profile')}
</sp-dialog-wrapper>
<sp-button slot="trigger" variant="primary" class="save-profile-button">Edit Profile</sp-button>
</overlay-trigger>
`;
}

render() {
if (!this.profile.id) {
return this.renderProfileForm();
return this.renderProfileForm(this.fieldlabels.heading);
}
return this.renderProfileView();
}
Expand Down

0 comments on commit 075cddd

Please sign in to comment.