
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
page-sections
Advanced tools
A simple section solution for your single page or landing page. Vanilla js, no framework dependencies, small footprint.
A simple section solution for your single page or landing page. Vanilla js, no framework dependencies, small footprint.
npm install --save page-sections
As the support for web components is currently still pretty spotty, you probably want to load a polyfill before loading the web component.
I recommend the webcomponentsjs. To make sure the webcomponent is only loaded once the polyfill is done (when using the webcomponents-loader.js
) you will want to wait for the WebComponentsReady
event before loading the web component. This event is always fired, even in browser that fully support web components.
<script type="text/javascript" async>
window.addEventListener('WebComponentsReady', function () {
let script = document.createElement('script')
script.setAttribute('src', '../dist/page-sections.js')
document.head.appendChild(script)
})
</script>
Add one or multiple <page-sections></page-sections>
elements to your page. Within you can add as many <page-section></page-section>
elements, as you want.
<page-sections>
<page-section class="anyClass">
<div class="red">Your red copy.</div>
</page-section>
<page-section>
<div class="truth">Web components are awesome.</div>
</page-section>
<div class="blue">Divs will be ignored</div>
<page-section>
<div class="wow">This is so simple.</div>
</page-section>
</page-sections>
The page-section
element is a flexbox container with a flex-direction: column
. If you want to have items side by side you should add a wrapping container around those items.
<page-section>
<div class="grid">
<div class="column-5">Column 1</div>
<div class="column-5">Column 2</div>
</div>
</page-section>
<page-section>
The requiredVisible
attribute is a value between 0
and 1
representing the percentage that is required to be within the viewport for a page-section to be considered visible
. If not set it will default to 0.6
.
The centered
attribute makes the content of a page-section
horizontally and vertically centered. The centering is flexbox
based so you can overwrite this behaviour if you only want the content to be centered in one direction.
If the fullscreen
attribute is set on a page-section
, it fills at least the entire height of the viewport (min-height: 100vh
).
This attribute makes the content of a page-section
not extend past the specified max-width
. Any value that works for max-width
will be accepted.
This attribute makes the content of a page-section
extend at least to the specified min-width
. Any value that works for min-width
will be accepted.
This attribute makes the content of a page-section
have a specified width
. Any value that works for width
will be accepted.
When the page-section
is in view according to the requiredVisible
attribute the active
attribute will be added to the page-section
element. Once it is not in view anymore it will be removed again.
Once the page-section
has been in view once, the activated
attribute is added to the page-section
element.
<page-section>
The activated
event is fired when the page-section
is in view according to the requiredVisible
attribute.
The deactivated
event is fired when the page-section
leaves the view according to the requiredVisible
attribute.
<page-sections>
containerThe activated
event is fired when the page-sections
container is partly visible.
The deactivated
event is fired when the page-sections
container has completely left the viewport.
The page-section
has an inner element to allow your content to be centered.
<page-section>
<!-- Shadow -->
<div id="content">
<slot><!-- Your content is added here --></slot>
</div>
<!-- Shadow -->
</page-section>
In some cases it might be necessary to define a height or width for this element. To this end you have the following css custom properties available.
width: var(--page-section-width, auto);
height: var(--page-section-height, auto);
min-width: var(--page-section-min-width, auto);
min-height: var(--page-section-min-height, auto);
max-width: var(--page-section-max-width, auto);
max-height: var(--page-section-max-height, auto);
If you wanted your element to be at least 400px
wide, you could do the following:
<style media="screen">
.min-400{
--page-section-min-width: 400px;
}
</style>
<page-section class="min-400">
Your content.
</page-section>
FAQs
A simple section solution for your single page or landing page. Vanilla js, no framework dependencies, small footprint.
We found that page-sections 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.