Sha256: 388f2c3b902836ad3cc1f44a92161aa7fdac600ac9dfa70840a6158d6a76feab
Contents?: true
Size: 771 Bytes
Versions: 39
Compression:
Stored size: 771 Bytes
Contents
import { Controller } from '@hotwired/stimulus' export default class extends Controller { static targets = ['content', 'moreContentButton', 'lessContentButton'] static values = { alwaysShow: Boolean } connect() { if (this.alwaysShowValue) return // Ignore checking when alwaysShow is true this.checkContentHeight() } checkContentHeight() { const contentHeight = this.contentTarget.scrollHeight if (contentHeight > 50) { this.moreContentButtonTarget.classList.remove('hidden') } } toggleContent() { this.contentTarget.classList.toggle('hidden') this.toggleButtons() } toggleButtons() { this.moreContentButtonTarget.classList.toggle('hidden') this.lessContentButtonTarget.classList.toggle('hidden') } }
Version data entries
39 entries across 39 versions & 1 rubygems