Socket
Book a DemoInstallSign in
Socket

merge-style-modules

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge-style-modules

A package that merge style modules

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Welcome to merge-style-modules 👋

Version Documentation Maintenance License: ISC Twitter: edusantosbrito

A package that merge style modules

Install

yarn add merge-style-modules

How to use

Sometimes you want to use more than one file with SASS/CSS modules like that:

/* @styles/default.modules.scss */

.container {
  background-color: red;
}
/* @styles/component.modules.scss */

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}
import defaultStyle from "@styles/default.modules.scss";
import componentStyle from "@styles/component.modules.scss";
import { useMemo } from "react";

const Component = () => {
  // You can't just merge these objects because of property conflicts
  const styles = useMemo(() => ({ ...defaultStyle, ...componentStyle }), []);

  return <div className={styles.container}>test</div>;
};

So I've created this package :)

Now you just have to do that:

import defaultStyle from "@styles/default.modules.scss";
import componentStyle from "@styles/component.modules.scss";
import { mergeStyles } from "merge-style-modules";
import { useMemo } from "react";

const Component = () => {
  const styles = useMemo(() => mergeStyles(defaultStyle, componentStyle), []);
  return <div className={styles.container}>test</div>;
};

Author

👤 edusantosbrito

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 edusantosbrito.
This project is ISC licensed.

This README was generated with ❤️ by readme-md-generator

Keywords

style

FAQs

Package last updated on 22 Dec 2020

Did you know?

Socket

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.

Install

Related posts