Skip to content

Commit

Permalink
fix: revert collapsible
Browse files Browse the repository at this point in the history
  • Loading branch information
meenahoda authored and Meena Brend committed Aug 22, 2022
1 parent 4600ec6 commit 922256d
Showing 1 changed file with 10 additions and 40 deletions.
50 changes: 10 additions & 40 deletions lib/builders/Collapsible.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
const ComponentBuilder = require('./../utils/Component-builder')
const { COLORS, TEXT_WHITE } = require('./../utils/color-reference')
const applyTooltip = require('./../utils/apply-tooltip')

module.exports = function (definition, options) {
const { title, subtitle, badge, badgeColor, showWhen, tooltip } = definition
const { title, subtitle, badge, badgeColor, showWhen } = definition

const builder = new ComponentBuilder(definition, { disableShowWhen: true })

const expansionItem = builder.addTag('q-expansion-item', { includeClosingTag: false })

if (typeof showWhen === 'string' && showWhen.length > 0) {
expansionItem.addChildTag('v-if', showWhen)
}

expansionItem
.addAttribute('expand-icon', 'keyboard_arrow_right')
.addAttribute('expanded-icon', 'keyboard_arrow_down')
.addAttribute('switch-toggle-side', null)

const templateHeader = expansionItem.addChildTag('template')
templateHeader.addAttribute('v-slot:header', null)

const itemSection = templateHeader.addChildTag('q-item-section')
const itemLabel = itemSection.addChildTag('q-item-label')

if (typeof title === 'string' && title.length > 0) {
itemLabel.content(title)
}
let template = `<q-expansion-item ${showWhen ? `v-if="${showWhen}"` : ''} expand-icon="keyboard_arrow_right" expanded-icon="keyboard_arrow_down" switch-toggle-side>`
template += '<template v-slot:header>'
template += '<q-item-section>'
template += `<q-item-label>${title}</q-item-label>`

if (badge) {
let color = 'primary'
Expand All @@ -39,30 +19,20 @@ module.exports = function (definition, options) {
}
}

const badgeLabel = itemSection.addChildTag('q-item-label')
const badgeElement = badgeLabel.addChildTag('q-badge')
badgeElement
.addAttribute('color', color)
.addAttribute('text-color', textColor)
.content(badge)
template += `<q-item-label><q-badge color="${color}" text-color="${textColor}">${badge}</q-badge></q-item-label>`
}

if (subtitle) {
const subtitles = Array.isArray(subtitle) ? subtitle : [subtitle]

subtitles.forEach(st => {
itemSection
.addChildTag('q-item-label')
.addAttribute('caption', null)
.content(st)
template += `<q-item-label caption>${st}</q-item-label>`
})
}

const card = expansionItem
.addChildTag('q-card', { includeClosingTag: false })
.addAttribute('class', 'collapsible-container')
template += '</q-item-section>'

card.addChildTag('q-card-section', { includeClosingTag: false })
template += '</template><q-card class="collapsible-container"><q-card-section>'

return builder.compile()
return template
}

0 comments on commit 922256d

Please sign in to comment.