-
Notifications
You must be signed in to change notification settings - Fork 4
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
added event agenda component #7
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.event-agenda-component .field-container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
gap: 35px; | ||
} | ||
|
||
.event-agenda-component .text-field-row .time-pickers { | ||
display: flex; | ||
align-items: center; | ||
gap: 16px; | ||
padding-bottom: 13px; | ||
} | ||
|
||
.event-agenda-component .text-field-row .time-pickers > p { | ||
font-size: var(--type-heading-m-size); | ||
font-weight: 700; | ||
} | ||
|
||
.event-agenda-component .text-field-row .time-pickers .time-picker-wrapper { | ||
flex: 1; | ||
min-width: 150px; | ||
} | ||
|
||
.event-agenda-component .text-field-row .time-pickers .time-picker-wrapper select { | ||
border-radius: 4px; | ||
padding: 4px; | ||
height: 40px; | ||
width: 100%; | ||
border: 1px solid var(--color-gray-500); | ||
font-size: var(--type-body-xs-size); | ||
} | ||
|
||
.event-agenda-component .text-field-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
} | ||
|
||
.event-agenda-component .text-field-wrapper sp-textfield { | ||
width: 100%; | ||
margin-bottom: 0px; | ||
} | ||
|
||
.event-agenda-component .text-field-wrapper .attr-text { | ||
font-size: var(--type-body-xs-size); | ||
color: var(--color-secondary); | ||
text-align: right; | ||
} | ||
|
||
.event-agenda-component .checkbox-wrapper { | ||
display: flex; | ||
justify-content: flex-end; | ||
margin-top: 12px; | ||
} | ||
|
||
.event-agenda-component .checkbox-input { | ||
margin-right: 8px; | ||
} | ||
|
||
.event-agenda-component .checkbox-label { | ||
font-size: var(--type-body-xs-size); | ||
font-weight: normal; | ||
} | ||
|
127 changes: 127 additions & 0 deletions
127
blocks/event-agenda-component/event-agenda-component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import { getLibs } from '../../scripts/utils.js'; | ||
import { getIcon, handlize, generateToolTip } from '../../utils/utils.js'; | ||
|
||
const { createTag } = await import(`${getLibs()}/utils/utils.js`); | ||
const miloLibs = getLibs(); | ||
|
||
await Promise.all([ | ||
import(`${miloLibs}/deps/lit-all.min.js`), | ||
import(`${miloLibs}/features/spectrum-web-components/dist/textfield.js`), | ||
import(`${miloLibs}/features/spectrum-web-components/dist/checkbox.js`), | ||
]); | ||
|
||
async function decorateField(row, type = 'text') { | ||
row.classList.add('text-field-row'); | ||
const cols = row.querySelectorAll(':scope > div'); | ||
if (!cols.length) return; | ||
const [placeholderCol, maxLengthCol] = cols; | ||
const text = placeholderCol.textContent.trim(); | ||
const attrTextEl = createTag( | ||
'div', | ||
{ class: 'attr-text' }, | ||
maxLengthCol.textContent.trim() | ||
); | ||
|
||
const maxCharNum = maxLengthCol.querySelector('strong')?.textContent.trim(); | ||
const isRequired = attrTextEl.textContent.trim().endsWith('*'); | ||
let input; | ||
|
||
if (type === 'text') { | ||
input = createTag('sp-textfield', { | ||
id: 'agenda-field-details', | ||
class: 'text-input', | ||
placeholder: text, | ||
required: isRequired, | ||
quiet: true, | ||
size: 'xl', | ||
}); | ||
} | ||
|
||
if (maxCharNum) { | ||
input.setAttribute('maxlength', maxCharNum); | ||
} | ||
|
||
const wrapper = createTag('div', { class: 'field-container' }); | ||
const textWrapper = createTag('div', { class: 'text-field-wrapper' }); | ||
textWrapper.append(input, attrTextEl); | ||
row.innerHTML = ''; | ||
wrapper.append(cols[2], textWrapper); | ||
row.append(wrapper); | ||
|
||
const timePickerContainer = createTag('div'); | ||
timePickerContainer.classList.add('custom-time-picker'); | ||
|
||
buildTimePicker(cols[2]); | ||
|
||
return row; | ||
} | ||
|
||
function buildTimePicker(column) { | ||
column.classList.add('time-pickers'); | ||
const header = column.querySelector(':scope > p'); | ||
const rows = column.querySelectorAll('table tr'); | ||
const timePickerWrappers = []; | ||
|
||
rows.forEach((r) => { | ||
const timePickerWrapper = createTag('div', { | ||
class: 'time-picker-wrapper', | ||
}); | ||
const cols = r.querySelectorAll('td'); | ||
|
||
cols.forEach((c, j) => { | ||
if (j === 0) { | ||
const timeSlots = c.querySelectorAll('li'); | ||
const select = createTag('select', { | ||
id: 'time-picker', | ||
class: 'select-input', | ||
}); | ||
|
||
timeSlots.forEach((t) => { | ||
const text = t.textContent.trim(); | ||
const option = createTag('option', { value: handlize(text) }, text); | ||
select.append(option); | ||
}); | ||
|
||
timePickerWrapper.append(select); | ||
} | ||
}); | ||
|
||
timePickerWrappers.push(timePickerWrapper); | ||
}); | ||
|
||
column.innerHTML = ''; | ||
if (header) column.append(header); | ||
column.prepend(getIcon('clock')); | ||
timePickerWrappers.forEach((w) => { | ||
column.append(w); | ||
}); | ||
} | ||
|
||
async function decorateCheckBox(row) { | ||
const fieldSet = createTag('fieldset', { class: 'checkboxes' }); | ||
row.classList.add('agenda-info-addition'); | ||
const cols = row.querySelectorAll(':scope > div'); | ||
const[checkboxText] = cols | ||
const cn = checkboxText.textContent.trim(); | ||
row.innerHTML = ''; | ||
|
||
const checkbox = document.createElement('sp-checkbox'); | ||
checkbox.id = 'checkbox-agenda-info'; | ||
checkbox.name = 'checkbox-agenda-info-name'; | ||
checkbox.value = cn; | ||
checkbox.textContent = cn; | ||
|
||
const wrapper = createTag('div', { class: 'checkbox-wrapper' }); | ||
wrapper.append(checkbox); | ||
|
||
fieldSet.append(wrapper); | ||
row.append(fieldSet); | ||
} | ||
|
||
export default async function init(el) { | ||
el.classList.add('form-component'); | ||
generateToolTip(el); | ||
const rows = [...el.querySelectorAll(':scope > div')]; | ||
decorateField(rows[1], 'text'); | ||
decorateCheckBox(rows[2]); | ||
} |
21 changes: 21 additions & 0 deletions
21
blocks/form-handler/controllers/event-agenda-component-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function onSubmit(component, inputMap) { | ||
//Todo agenda details | ||
const agendaDetails = component.querySelector('#textfield > input'); | ||
const time = component.querySelector('#time-picker-time').value; | ||
const agendaInfoVisible = component.querySelector('#checkbox-agenda-info-will-appear-post-event').checked; | ||
|
||
|
||
|
||
|
||
const eventInfo = { | ||
...getMappedInputsOutput(component, inputMap), | ||
agendaInfoVisible, | ||
'Time': time, | ||
}; | ||
|
||
|
||
return eventInfo; | ||
} | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move these + the miloLibs = getLibs() into the init call. The convention is that these. I don't think this will break anything but we should try to load the modules with as little side effects as possible.