Skip to content

v2.0.0: support CSS modules, use vitest + biome#18

Merged
phloe merged 4 commits intomasterfrom
css-modules
Feb 5, 2026
Merged

v2.0.0: support CSS modules, use vitest + biome#18
phloe merged 4 commits intomasterfrom
css-modules

Conversation

@phloe
Copy link
Contributor

@phloe phloe commented Jan 2, 2026

Api'et er skåret ind til benet a la det vi har brugt op til nu (bem.scoped, bem.single, osv er fjernet):

import bh from "@dr/bem-helper";

const bem = bh('block');

Før:

import bh from '@dr/bem-helper';

const bem = bh.scoped.bind(null, 'block');

CSS modules er understøttet via ekstra parameter:

import bh from "@dr/bem-helper";

import styles from "./MyComponent.module.scss";

const bem = bh('block', styles);

Der er opgraderet til vitest + biome.

@phloe phloe changed the title support CSS modules, use vitest + biome v2.0.0.: support CSS modules, use vitest + biome Jan 2, 2026
@phloe phloe changed the title v2.0.0.: support CSS modules, use vitest + biome v2.0.0: support CSS modules, use vitest + biome Jan 2, 2026
index.js Outdated
Comment on lines 33 to 35
if (typeof element !== "string" && !modifiers) {
[element, modifiers] = [modifiers, element];
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hvorfor egentlig bytte dem her? Skal element ikke bare eksplicit sættes til undefined, hvis det ikke er et string type argument? Og skal element ikke kun bruges som modifiers, hvis det er object type? Blot en tanke.

Suggested change
if (typeof element !== "string" && !modifiers) {
[element, modifiers] = [modifiers, element];
}
if (!modifiers
&& typeof element === "object"
&& element !== null
&& !Array.isArray(element)
) {
modifiers = element;
}
if (typeof element !== "string") {
element = undefined;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mjoh, det er lidt et spørgsmål om hvor meget man skal holde folk i hånden.

Jeg har ændret det til:

	if (element && typeof element !== "string") {
		if (typeof element === "object") {
			modifiers = element;
		}
		element = undefined;
	}

Comment on lines +33 to +37
if (element && typeof element !== "string") {
if (typeof element === "object") {
modifiers = element;
}
element = undefined;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@phloe phloe merged commit 376f594 into master Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants