![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@geekie/css
Advanced tools
@geekie/css
A simple CSS-in-JS solution that extracts CSS files.
This library was created at Geekie when we started porting parts of our RN app to a web version. We evaluated most existing libraries and none would accomplish all our requirements:
A simple example of the API:
import { StyleSheet, css } from "@geekie/css";
const styles = StyleSheet.create({
header: {
fontSize: 18,
fontWeight: "bold"
},
bordered: {
border: "1px solid #000"
}
});
function Header({ children }) {
return (
<span className={css(styles.header, styles.bordered)}>{children}</span>
);
}
When used with our Webpack plugin, the StyleSheet.create()
call will be replaced by a simple object, where the keys are kept and each value is a string of [atomic classnames] separated by an space. Each classname correspond to a single style defined in the object passed to StyleSheet.create
. See the following output for an illustration:
import { css } from "@geekie/css";
// these classnames are just an example
const styles = {
header: "gkcss0_a4bcdef gkcss1_b9cdk4l",
bordered: "gkcss2_a84ifj"
};
function Header({ children }) {
return (
<span className={css(styles.header, styles.bordered)}>{children}</span>
);
}
And the css()
function will select one classname from each "type", to prevent non-deterministic behavior caused by the order of CSS rules order.
In the cases where the styles can't be computed statically, the StyleSheet.create()
will simply return the first argument, and when the css()
function receives an object as argument, it will fallback to add class dynamically, very similar to the [glamor] (and others) behavior. An example:
css(
// assume these are the output of a `StyleSheet.create()` call
"gkcss0_a4bcdef gkcss1_b9cdk4l",
"gkcss0_g83nvn",
// these are dynamic styles
{ color: "red" },
{ fontFamily: "Verdana", color: "black" }
);
The call above will return:
"gkcss0_g83nvn gkcss1_b9cdk4l css-839fn39"
And a corresponding CSS rule will be created:
.css-839fn39 {
font-family: Verdana;
color: black;
}
In order to benefit from the build time CSS compilation, you need to use the companion loader and plugin. Example:
// webpack.config.js
const GkCssPlugin = require("@geekie/css/webpack");
module.exports = {
module: {
rules: [
{
test: /\.js$/,
use: [
// we recommend adding the loader as the last loader
{
loader: GkCssPlugin.loader,
options: {
globals: {
// include any globals that may affect the CSS styles
// so they can be evaluated statically
__DEV__: process.env.NODE_ENV !== "production"
}
}
}
]
}
]
},
plugins: [
// define the filename of the compiled CSS
new GkCssPlugin("style.css")
]
};
border
vs border-left
)FAQs
A simple CSS-in-JS solution that extracts to CSS files
The npm package @geekie/css receives a total of 2 weekly downloads. As such, @geekie/css popularity was classified as not popular.
We found that @geekie/css 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.