
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
bpk-react-utils
Advanced tools
Miscellaneous React based utilities for use in Backpack components.
npm install bpk-react-utils --save-dev
Render's children into a new component tree and appends it to document.body
. Useful for Modals, Popovers, Tooltips etc where
it's necessary in overcoming z-index issues when absolutely positioning elemtents.
import { Portal } from 'bpk-react-utils';
import BpkButton from 'bpk-component-button';
import { BpkCode } from 'bpk-component-code';
import React, { Component } from 'react';
class MyComponent extends Component {
constructor() {
super();
this.state = {
isOpen: false,
};
this.onOpen = this.onOpen.bind(this);
this.onClose = this.beforeClose.bind(this);
}
onOpen() {
this.setState({
isOpen: true,
});
}
onClose() {
this.setState({
isOpen: false,
});
}
render() {
return (
<div>
<BpkButton onClick={this.onOpen}>Open portal</BpkButton>
<Portal
isOpen={this.state.isOpen}
onClose={this.onClose}
>
<div>I'm now appended to <BpkCode>document.body</BpkCode></div>
</Portal>
</div>
);
}
}
Property | PropType | Required | Default Value |
---|---|---|---|
children | node | true | - |
isOpen | bool | true | - |
target | node | false | null |
onOpen | func | false | noop |
onRender | func | false | noop |
onClose | func | false | noop |
beforeClose | func | false | null |
A helpful utility which permits backwards compatibility with hard coded classes and css-modules.
import React from 'react';
import { cssModules } from 'bpk-react-utils';
import STYLES from './MyComponent.scss';
const getClassName = cssModules(STYLES);
const MyComponent = (props) => (
<div className={getClassName('MyComponent')}>
<div className={getClassName('MyComponent__inner')}>
{props.children}
</div>
</div>
);
With css modules:
<div class="_35WloynrPDta8fhSfoHEgE">
<div class="_1ghNYY7jOYzUneVCT4piQ9">
Some text.
</div>
</div>
Without css modules:
<div class="MyComponent">
<div class="MyComponent__inner">
Some text.
</div>
</div>
A wrapper around react-transition-group
which makes it easy to transition a
components initial mount. All you need to provide is two class names and a timeout.
import React from 'react';
import { TransitionInitialMount } from 'bpk-react-utils';
const MyComponent = (props) => (
<TransitionInitialMount
appearClassName="my-transition-class--appear"
appearActiveClassName="my-transition-class--appear-active"
transitionTimeout={300}
>
<div>Some text.</div>
</TransitionInitialMount>
);
@import '~bpk-mixins/index';
.my-transition-class {
transition: opacity $bpk-duration-sm ease-in-out;
opacity: 1;
&--appear {
opacity: 0;
}
&--appear-active {
opacity: 1;
}
}
Property | PropType | Required | Default Value |
---|---|---|---|
children | node | true | - |
appearClassName | string | true | - |
appearActiveClassName | string | true | - |
transitionTimeout | number | true | - |
FAQs
Utilities for Backpack's React components.
The npm package bpk-react-utils receives a total of 1,282 weekly downloads. As such, bpk-react-utils popularity was classified as popular.
We found that bpk-react-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.