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

fix(classNames context): general improvements #771

Merged
merged 13 commits into from
Apr 7, 2023

Conversation

danilowoz
Copy link
Member

@danilowoz danilowoz commented Feb 27, 2023

  • Make an identifier mandatory;
  • Drop code-hike dependency;
  • Drop THEME_PREFIX need to every className;

Closes #714

@vercel
Copy link

vercel bot commented Feb 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sandpack-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 7, 2023 2:35pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 27, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5d4a324:

Sandbox Source
Sandpack Configuration
sandpack-run-stale-value Configuration

@Jokcy
Copy link
Contributor

Jokcy commented Feb 28, 2023

Greate! Just have time to work with this issue and see your PR, the API looks similar as I imagine, can't wait for the new release.

@danilowoz
Copy link
Member Author

danilowoz commented Feb 28, 2023

Hey @Jokcy, thanks! Do you have any feedback? Not absolute sure about the API, but at least it is very strict and it was able to find many places where Sandpack was missing classNames.

// I specially didn't like of this pattern
classNames("sandpack-class-1", [
  classNames("sandpack-class-2"),
  classNames("sandpack-class-3"),
  "another-class",
  "another-class-2",
]

@Jokcy
Copy link
Contributor

Jokcy commented Mar 1, 2023

Hi @danilowoz , I used to try to keep the traditional classNames usage and just implement useClassNames hook for classes need prefix and class name map, like this:

import { classNames } from "../utils/classNames";
import { useClassNames} from "../utils/useClassNames";

const classNamesWithPrefix = useClassNames()

<div className={classNames(
    classNamesWithPrefix('sandpack-class-1', ...classNeedPrefix),
    buttonClassName,
    ...classesWithoutPrefix)}>
</div>

The only difference is it try to fit the api of classnames or clsx package.

But since we implement classNames ourself instead of import another package, I suppose it's not a big deal.

@Jokcy
Copy link
Contributor

Jokcy commented Mar 12, 2023

@danilowoz Any plan to merge this PR?

@danilowoz
Copy link
Member Author

As I will be off for a couple of weeks, I don't want to introduce any disruptive change. Let's get this done as soon as I am back.

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.

Fully support customize style by classes options
2 participants