-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(css): use postcss #7
feat(css): use postcss #7
Conversation
AugustinMauroy
commented
Jun 27, 2024
- Allow nested selector
- remove deprecation warn
@@ -60,6 +60,7 @@ describe('css-module loader', { concurrency: true }, () => { | |||
Qux: 'Qux', | |||
Zed: 'Zed', | |||
img: 'img', | |||
nested: 'nested', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could have something like this to represent the nested :
{
"Foo": "Foo",
"Bar": "Bar",
"Qux": "Qux",
"Zed": "Zed",
"img": "img",
"nested": {
"something": "something"
}
}
but it would change the spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an additive change (nesting wasn't supported before), so that's fine. I think your proposal in the comment (something.nested
) is better as it avoids a risk of collision 🙂
I think the README would need to be updated (and if so, before cutting a release). I can do subsequently if you don't want to handle in this PR, but I can't til I'm back from Helsinki next week (same for cutting the release).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to experiment with the loader with react typescript and tailwind to find out which is the best behaviour to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here example of dum component:
import { useState } from 'react';
import styles from './basic.module.css';
import type { FC } from 'react';
const Basic: FC = () => {
const [show, setShow] = useState(false);
return (
<div className={styles.container}>
<button
className={styles.button}
onClick={() => setShow(!show)}
>Toggle</button>
{show && <p>Content</p>}
</div>
);
};
export default Basic;
here the test suite:
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { render, screen, act } from "@testing-library/react";
import Basic from "./basic.tsx";
describe("Basic", () => {
it("should render", () => {
const { container } = render(<Basic />);
assert.ok(container);
container.remove();
});
it("should toggle content", () => {
const { unmount } = render(<Basic />);
const button = screen.getByRole("button");
const content = screen.queryByText("Content");
assert.ok(button);
assert.strictEqual(content, null);
act(() => {
button.click();
});
assert.ok(screen.queryByText("Content"));
unmount();
});
it("should have correct class names", () => {
render(<Basic />);
const container = screen.getByRole("button").parentElement;
if (!container) {
throw new Error("Container not found");
}
assert.strictEqual(container.className, "container");
const button = container.querySelector("button");
if (!button) {
throw new Error("Button not found");
}
assert.strictEqual(button.className, "button");
});
});
This is currently failing. That's why I think having nested keys in a js object seems more appropriate.
I'm well aware that nobody in their right mind would do such a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With lasted commit this test pass
@@ -60,6 +60,7 @@ describe('css-module loader', { concurrency: true }, () => { | |||
Qux: 'Qux', | |||
Zed: 'Zed', | |||
img: 'img', | |||
nested: 'nested', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an additive change (nesting wasn't supported before), so that's fine. I think your proposal in the comment (something.nested
) is better as it avoids a risk of collision 🙂
I think the README would need to be updated (and if so, before cutting a release). I can do subsequently if you don't want to handle in this PR, but I can't til I'm back from Helsinki next week (same for cutting the release).
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w00t! thank you!