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

Uses CSS module instead of Stitches for Loader component #2178

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

infomiho
Copy link
Contributor

Loader shouldn't depend on stitches being available since it's installed only when auth is used.

Moves Loader to use CSS Modules instead.

@@ -0,0 +1,37 @@
.loader {
color: var(--loader-color, #1a202c);
Copy link
Contributor Author

@infomiho infomiho Jul 12, 2024

Choose a reason for hiding this comment

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

Wrote it like this to enable users to adjust the loader color with CSS vars. It's undocumented but we can tell users that info if they ask.

Copy link
Member

Choose a reason for hiding this comment

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

So this is still local CSS, is it? Not global, right? Because of the ".module.css"? WHo is enabling this, Vite, or are we using something special?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Vite supports CSS modules out of the box: https://vitejs.dev/config/shared-options.html#css-modules

Signed-off-by: Mihovil Ilakovac <[email protected]>
Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

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

Left a couple of comments but approved! Btw i believe i left somewhere in the codebase a comment/TODO saying that we will have this issue with stitches and loader - can you please check it and remove it if you find it? If not then it was probably just in that post-PR review I did.

@@ -0,0 +1,37 @@
.loader {
color: var(--loader-color, #1a202c);
Copy link
Member

Choose a reason for hiding this comment

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

So this is still local CSS, is it? Not global, right? Because of the ".module.css"? WHo is enabling this, Vite, or are we using something special?

export function Loader() {
const loaderClassName = ['loader', styles.loader].join(' ')
Copy link
Member

Choose a reason for hiding this comment

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

I would maybe just inline this, but do as you like.

Copy link
Member

Choose a reason for hiding this comment

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

Btw why do you also need to set 'loader' class here? I would imagine only styles.loader is enough?

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 would maybe just inline this, but do as you like.

I prefer this 🤷

I would imagine only styles.loader is enough?

I wanted to give users a stable class name (styles.loader gives you a mangled name) if they wanted to style the loader in some way.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, shouldn't we name it sometihng like wasp-loader? Because this is now global CSS class if I am right -> calling it just loader seems problematic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most people use Tailwind these days or one of the CSS-in-JS options, so I don't think there will be a lot of interference with built in classes. If it happens to happen, let's change it then.

Copy link
Member

Choose a reason for hiding this comment

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

So you are saying that our global CSS hopefully wont cause any issues because others might not use global CSS themselves? That is ok, but we can't count on that. Also, as a library/framework, we should at least try to not affect their global space if we can. I think we should do this now, it is an easy change and is a good practice and we know it has a potential to cause problems down the road: it would be downright sloppy to leave this as it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can add the wasp- prefix in a new PR.

@infomiho infomiho merged commit dddccca into main Jul 15, 2024
6 checks passed
@infomiho infomiho deleted the miho-fixes-loader branch July 15, 2024 12:07
@infomiho
Copy link
Contributor Author

@Martinsos the comment about Stitches and loader is in your post-PR review, not in an issue, so there was nothing to delete.

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.

None yet

2 participants