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

Class isn't passed to Svelte island #5397

Closed
1 task
LukaHarambasic opened this issue Nov 14, 2022 · 5 comments
Closed
1 task

Class isn't passed to Svelte island #5397

LukaHarambasic opened this issue Nov 14, 2022 · 5 comments

Comments

@LukaHarambasic
Copy link

What version of astro are you using?

1.6.7

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

The issue #5029 isn't solved as far as I can tell. I also checked if it was included in a release: https://github.com/withastro/astro/releases/tag/%40astrojs%2Fsvelte%401.0.2 & I'm using that version of @astrojs/svelte.

If I add a class to a Svelte island, I would expect it to be added to the parent element in the component, but this doesn't work right now.

image

Link to Minimal Reproducible Example

LukaHarambasic/harambasic.de@a792bbf

Participation

  • I am willing to submit a pull request for this issue.
@matthewp
Copy link
Contributor

The <astro-island> is just used for loading, not for styling. It can't be styled in fact, it's display: contents so it doesn't exist from a styling standpoint.

If you want to add in the passed in class you can do so yourself, by getting the class that comes in as a prop and then passing that into your <button>

@LukaHarambasic
Copy link
Author

Thanks! Learned something new regarding display: contents.
Could you give me an example regarding handling the class in svelte? If I wanna access the prop class I get an error that I can't use class, so of course, I could use another term, but that would not be that nice. It also doesn't help as the parent astro page has scoped styles - it should stay like this. Is there something like Vues :deep selector? (https://www.npmjs.com/package/postcss-deep-scopable)

@matthewp
Copy link
Contributor

I'm not an expert on Svelte but I believe this will work:

let className;
export { className as class };

@matthewp
Copy link
Contributor

Ah, here's a good blogpost on the topic by our very own @tony-sull https://navillus.dev/blog/svelte-class-props

@LukaHarambasic
Copy link
Author

Awesome, thank you!

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

No branches or pull requests

2 participants