Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
gm-collapse
Advanced tools
Collapse component without any deps.
简体中文 | English
npm install gm-collapse -S
# Or use yarn
yarn add gm-collapse
Or just use <script>
tag:
<link rel="stylesheet" href="path/to/gm-collapse.min.css" />
<script src="path/to/gm-collapse.min.js"></script>
To get dist js and css files, please visit Releases Page or use CDN like jsDelivr
.
Firstly, you must have a DOM structure like:
<!-- The container of whole component -->
<div class="gm-collapse-container">
<!-- Collapse item -->
<div class="gm-collapse-item">
<!-- Header -->
<div class="gm-collapse-header">
<!-- Title -->
<div class="gm-collapse-title">some title...</div>
<!-- Right icon -->
<i class="gm-collapse-icon"></i>
</div>
<!-- Body of item, it will hide when item is collapsed -->
<div class="gm-collapse-body">
<!-- Content area -->
<div class="gm-collapse-content">some content...</div>
</div>
</div>
<!-- This item is collapsed by default -->
<div class="gm-collapse-item collapsed">
<div class="gm-collapse-header">
<div class="gm-collapse-title">some title...</div>
<i class="gm-collapse-icon"></i>
</div>
<div class="gm-collapse-body">
<div class="gm-collapse-content">some content...</div>
</div>
</div>
</div>
All the collapse item is not collapsed by default, if you want collapsed item, add className collapsed
to the right .gm-collapse-item
element.
If you use import/require
:
import Gmcollapse from 'gm-collapse'
import 'gm-collapse/gm-collapse.min.css'
// Create an collapse instance with selector of container
// which has a className of `gm-collapse-container`
const instance = Gmcollapse(selector)
// Collapse the first item
instance.collapse(0)
// Uncollapse all
instance.uncollapseAll()
If you use <script/>
tag to import, Gmcollapse
will be mounted on window
.
Don't forget to import css file.
Create a new collapse instance with selector
selector
{ string }Selector of container, a string.
It will return an collapse instance, the relationship between them is:
instance.__proto__ = Gmcollapse.prototype
So that instance could use all of prototype methods on Gmcollapse
.
Instance will have those properties:
Gmcollapse {
container // container HTMLElement
}
The
this
below means the instance created byGmcollapse()
.
The container of whole collapse component.
Get collapse item and body element of this item.
index
{ number }Serial number of collapse you want get.
return
{ IObj }Return a object which has property collapseItem
and body
, the interface is showing below:
interface IObj {
body: HTMLElement
collapseItem: HTMLELement
}
Get all collapse items by element.querySelectorAll()
.
return
{ NodeList }Return all collapse items.
Check if this item is collapsed.
index
{ number }Serial number of collapse item you want get.
return
{ Boolean }The result of whether it's collapsed or not.
Collapse a item, if it's already collapsed, then do nothing.
index
{ number }Serial number of collapse item you want get.
return
{ GmCollapse }Return the instance itself.
Collapse all the items, if a item is already collapsed, then do nothing to it.
return
{ GmCollapse }Return the instance itself.
Unollapse a item, if it's not collapsed, then do nothing.
index
{ number }Serial number of collapse item you want get.
return
{ GmCollapse }Return the instance itself.
Uncollapse all the items, if a item is not collapsed, then do nothing to it.
return
{ GmCollapse }Return the instance itself.
Toggle a item to collapsed or not.
index
{ number }Serial number of collapse item you want get.
return
{ GmCollapse }Return the instance itself.
Toggle all the items.
return
{ GmCollapse }Return the instance itself.
MIT
FAQs
Collapse component without any deps
The npm package gm-collapse receives a total of 0 weekly downloads. As such, gm-collapse popularity was classified as not popular.
We found that gm-collapse demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.