Skip to content

[pigment-core] React implementation for the new Pigment CSS API #367

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 force-pushed the v1/react-package branch 2 times, most recently from 493fe2c to 534e9c4 Compare January 14, 2025 14:56
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 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 Jan 21, 2025
@brijeshb42 brijeshb42 force-pushed the v1/react-package branch 3 times, most recently from b6cb7ee to 9d6424d Compare January 21, 2025 04:51
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 21, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 21, 2025
@brijeshb42 brijeshb42 force-pushed the v1/react-package branch 6 times, most recently from 6e259a9 to a0d632c Compare February 3, 2025 05:47
@brijeshb42 brijeshb42 force-pushed the v1/react-package branch 5 times, most recently from f55bf27 to 7eecf99 Compare February 27, 2025 13:08
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 27, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 27, 2025
@brijeshb42 brijeshb42 marked this pull request as ready for review February 27, 2025 13:54
@brijeshb42 brijeshb42 requested a review from Janpot February 27, 2025 13:58
@brijeshb42 brijeshb42 changed the title v1/react package [pigment-core] React implementation for the new Pigment CSS API Feb 27, 2025
@@ -119,6 +119,99 @@ export type CssTailProcessorParams = BaseCssProcessorConstructorParams extends [
? T
: never;

function handleTemplateElementOrSimilar(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the test for the change in implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add the implementation for sx in a separate PR. At the current stage, the new package doesn't support sx prop.

@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
@@ -0,0 +1,152 @@
{
"name": "@pigment-css/react-new",
Copy link

Choose a reason for hiding this comment

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

Hey there. Thanks for your work. A question about this package name, are we going to remove the -new before it is released?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Its temporary right now. Before release, this'll become @pigment-css/react and old one will be renamed.

const { themeArgs = {}, pigmentFeatures: { useLayer = true } = {} } =
processor.options as TransformedInternalConfig;
// @ts-ignore @TODO - Fix this. No idea how to initialize a Tagged String array.
const templateStrs: string[] = [];
Copy link
Member

@Janpot Janpot Mar 24, 2025

Choose a reason for hiding this comment

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

const x: TemplateStringsArray = Object.assign([], { raw: [] })


isMaybeTransformedTemplateLiteral(values: ValueCache): boolean {
const [, firstArg, ...restArgs] = this.callParam;
if (!('kind' in firstArg) || firstArg.kind === ValueType.CONST) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think I've used the in operator in over a decade 😄
It's purely stylistic in this instance, .hasOwnProperty feels more predictable to me.

Copy link
Member

@siriwatknp siriwatknp Mar 28, 2025

Choose a reason for hiding this comment

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

I think in makes TS happy too, not sure about .hasOwnProperty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. in narrows the types to the expected ones.

@@ -0,0 +1,29 @@
# Pigment CSS
Copy link
Member

@Janpot Janpot Mar 24, 2025

Choose a reason for hiding this comment

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

Content like this would be useful on the docs. Like a landing page with a bit more information.

Copy link
Contributor Author

@brijeshb42 brijeshb42 Mar 28, 2025

Choose a reason for hiding this comment

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

Do you mean something in addition to the styling guide ?
Like something similar to the plugin doc.

@@ -157,7 +157,7 @@ function getCss(
delete style.defaultVariants;

const { result: baseObj, variables } = processStyle(style, { getVariableName });
const cssText = serializeStyles([baseObj as any]).styles;
const { styles: cssText } = serializeStyles([baseObj as any]);
Copy link
Member

Choose a reason for hiding this comment

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

Casting type to serializeStyles's input argument would be better than any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants