Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Embarrassingly simple css for React
yarn add kremling
import React from "react";
import { Scoped, always, maybe, toggle } from "kremling";
const css = `
& .card {
display: flex;
color: #BADA55;
}
& .fear {
background-color: red;
}
& .fight {
font-weight: bold;
}
& .flight {
font-style: italic;
}
`;
class KremlingKrew extends React.Component {
state = { gotBananas: true };
render() {
return (
<div>
<Scoped css={css}>
<div className="card">King K. Rool</div>
<div className={always("card").maybe("fear", this.state.gotBananas)}>
<span className={toggle("flight", "fight", this.state.gotBananas)}>
DK
</span>
</div>
</Scoped>
<div className="card">
{/** no styles applied because out of scope **/}
Clump & Crunch
</div>
</div>
);
}
}
<Scoped />
A React Component which requires a css
or postcss
prop.
The CSS rules defined in either of these properties will be available only to children
of the rendered Scoped
Component.
css
prop {string}Scoped CSS rules. All selectors must begin with an &
. See above example.
namespace
prop {string} OptionalDefine a custom namespace for scoping your CSS.
postcss
prop {object}An object containing pre-processed css styles and an optional namespace.
Check out the kremling-loader
to learn how to use this.
always
always(String)
or a(String)
- Always return the string passes.
maybe
maybe(String, Boolean)
or m(String, Boolean)
- Conditionally return the String depending on if the second parameter is truthy.
toggle
toggle(String, String, Boolean)
or t(String, String, Boolean)
- Returns the first String if the third parameter is truthy or the second String if the third parameter is falsy.
If you're using at least enzyme@3.3.0, you can do wrapper.find('.myKlass')
and it will work just fine, even if you are using always().maybe()
inside of the className prop. Enzyme will be able to select the css classes, as of this commit
that was released in enzyme@3.3.0
If you are using snapshots, I would recommend not snapshotting the entire css string passed to the Scoped component. So if you are rendering <Scoped css={aLongCssString}><div /></Scoped>
, I would recommend
doing expect(wrapper.find('div').toMatchSnapshot()
instead of expect(wrapper).toMatchSnapshot()
so that your snapshots aren't gigantic and less useful. Additionally, in order to make sure that css classes that use
always()
, maybe()
, or toggle()
are serialized correctly, you should install jest-string-object-serializer and then add that to your snapshotSerializers config
FAQs
Embarrassingly simple css for React
The npm package kremling receives a total of 0 weekly downloads. As such, kremling popularity was classified as not popular.
We found that kremling demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.