Skip to content
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

[docs] All the docs actual content #390

Draft
wants to merge 88 commits into
base: master
Choose a base branch
from

Conversation

brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 added the docs Improvements or additions to the documentation label Mar 14, 2025
@brijeshb42 brijeshb42 changed the title V1/docs content [docs] All the docs actual content Mar 14, 2025
@brijeshb42 brijeshb42 force-pushed the v1/docs-content branch 5 times, most recently from c1cb8af to 0ba13a9 Compare March 14, 2025 14:35
}
```

In the above example, the color of the text will be `blue` in both the cases because the final generated css will have the styles in the same order -
Copy link
Member

Choose a reason for hiding this comment

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

Gotta love stylex for fixing this. It's so counterintuitive that just swapping the position of two global variables affects the behavior of where they are applied. I mean, imagine the following two snippets print a different result.

const a = 5;
const b = 7;
console.log(a / b);
// ---
const b = 7;
const a = 5;
console.log(a / b);

Copy link
Contributor Author

@brijeshb42 brijeshb42 Mar 17, 2025

Choose a reason for hiding this comment

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

IMO, the correct analogy (in CSS context) here will be

const a = 5;
const b = 7;
console.log(a / b);
// vs
console.log(b / a);

Both have different outputs with same order of variable declaration.

Besides, the selling point of stylex is the same as tailwind (when used with something like tailwind-merge), which is atomic css.
This is the main reason due to which, with a runtime check in place, they are able to dedupe the class names based on the property they are targetting and only keep the last class name of a property. So essentially, it applies only one classname for a particular property.

OTOH, Pigment's output is the same as when you'd write CSS modules.

Copy link
Member

@Janpot Janpot Mar 17, 2025

Choose a reason for hiding this comment

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

Both have different outputs with same order of variable declaration.

Exactly, in javascript, the order at call site is important, not at declaration site.

OTOH, Pigment's output is the same as when you'd write CSS modules.

Indeed, that's what's counterintuitive, I'm writing javascript, but I have to keep CSS semantics in mind. The real danger comes when utilities are defined in other files and composed. Now you don't have a module-local record of the order of declaration. You can't even reliably influence it as it may already have been imported somewhere else in a different order.

Besides, the selling point of stylex is the same as tailwind (when used with something like tailwind-merge), which is atomic css.

Sure this is done under the hood with atomic CSS and a lightweight runtime, but I don't think that matters. It's not at all its selling point to me, I don't care how they solve this problem, I care that the semantics match the environment I'm writing in, which is javascript, not css.

The above example can be extended to imported styles or styled components as well.

```tsx title="Button.jsx"
import { css } from '@pigment-css/react-new';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import { css } from '@pigment-css/react-new';
import { styled } from '@pigment-css/react-new';

and then pass in the Pigment CSS configuration options (if any).

2. After this, import the `@pigment-css/react-new/styles.css` file in the main entry point file of the app. Make sure that this file is only imported once in the app otherwise you will end up with duplicate styles in the final bundle.
This import will be responsible for adding the Pigment CSS layer order as well as injecting the css tokens configured in the [theming](/features/theming) section.
Copy link
Member

@Janpot Janpot Mar 17, 2025

Choose a reason for hiding this comment

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

https://deploy-preview-390--pigment-css.netlify.app/features/theming 404s for me

edit: actually, every page under Theming 404s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, this PR is in draft mode right now. Not ready for review. I need review for this PR - #367

@brijeshb42 brijeshb42 force-pushed the v1/docs-content branch 6 times, most recently from 6d281b6 to 299fe69 Compare March 20, 2025 12:11
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 20, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 20, 2025
@brijeshb42 brijeshb42 force-pushed the v1/docs-content branch 2 times, most recently from cfee250 to e01b81e Compare March 23, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants