Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
fluid-resize-react
Advanced tools
Provide a simple way to scale props to fill a container using binary search. Useful for scaling text sizes to fit a container.
npm install --save fluid-resize-react
function App() {
const renderer = current => (
<span style={{ fontSize: `${current}px` }}>
Lorem ipsum dolor sit amet sed adipiscitur sit adipiscitur a very big
heading that im writing
</span>
);
const style = {
overflow: "hidden",
outline: "1px solid red",
whiteSpace: "nowrap"
};
return (
<div className="App">
<FixedSize style={{ ...style, width: 500, height: 50 }}>
{renderer}
</FixedSize>
<FixedHeight style={{ ...style, height: 100 }}>{renderer}</FixedHeight>
<FixedWidth style={{ ...style, width: 500 }}>{renderer}</FixedWidth>
<FixedWidth style={{ ...style, width: 300 }}>{renderer}</FixedWidth>
<FixedWidth style={{ ...style, width: 200 }}>{renderer}</FixedWidth>
</div>
);
}
Pass a render function to a component as child. The component will call the render function passing the current iteration size as parameter.
You can also provide max value, min value and max iterations as props:
function App() {
const renderer = current => (
<span style={{ fontSize: `${current}px` }}>Test</span>
);
const style = {
overflow: "hidden",
whiteSpace: "nowrap"
};
return (
<div className="App">
<FixedWidth maxSteps={10} min={10} max={12} style={{ ...style }}>
{renderer}
</FixedWidth>
</div>
);
}
This components can be used for text as well for any other usages:
function App() {
const renderer = current => (
<div style={{ display: "flex" }}>
{new Array(Math.floor(current)).fill(0).map(_ => (
<div
style={{
margin: 3,
height: "20px",
width: "20px",
backgroundColor: "blue"
}}
/>
))}
</div>
);
return (
<div className="App">
<FixedWidth
min={1}
max={30}
style={{
overflow: "hidden",
whiteSpace: "nowrap"
}}
>
{renderer}
</FixedWidth>
</div>
);
}
MIT © giulioz
FAQs
Scale props to fill a container using binary search
The npm package fluid-resize-react receives a total of 4 weekly downloads. As such, fluid-resize-react popularity was classified as not popular.
We found that fluid-resize-react 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.