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

Svelte 5 runes mode compatibility #2312

Open
2 of 14 tasks
HummingMind opened this issue Jul 12, 2024 · 10 comments
Open
2 of 14 tasks

Svelte 5 runes mode compatibility #2312

HummingMind opened this issue Jul 12, 2024 · 10 comments
Labels
💡 idea New ideas

Comments

@HummingMind
Copy link

Package

  • lucide
  • lucide-angular
  • lucide-flutter
  • lucide-preact
  • lucide-react
  • lucide-react-native
  • lucide-solid
  • lucide-svelte
  • lucide-vue
  • lucide-vue-next
  • Figma plugin
  • all JS packages
  • site

Description

A .next version of lucide-svelte is needed that adds compatibility with runes mode for Svelte 5 RC (and soon Svelte 5 final).
The current version does not work, as it uses $$props instead of the new $porps() rune.

Thank you!

Use cases

Needed for Svelte 5 RC support of runes mode

Checklist

  • I have searched the existing issues to make sure this bug has not already been reported.
@HummingMind HummingMind added the 💡 idea New ideas label Jul 12, 2024
@ericfennis
Copy link
Member

@HummingMind But lucide-svelte should work with Svelte 5. But still uses the old syntax. We can't just switch to the new syntax yet, because we have to deal with backward compatibility.

@HummingMind
Copy link
Author

HummingMind commented Jul 22, 2024

@ericfennis understandable. It would need to be a new major version, which is why I suggested a ".next" version. Could be published side-by-side with the current version. 🍺

If it is not time yet, I get it. 👍🏻

@Shyrogan
Copy link

Moving towards Svelte 5 would also be a great option to implement some features, see #1302 for example.

If you need someone to write the code for it, I would love to do it. Just want to make sure those changes would be merged if someone writes the code for it.

@alissa-tung
Copy link

some like

<script lang="ts">
  import defaultAttributes from './defaultAttributes';
  import type { IconNode } from './types';
  import type { SvelteHTMLElements } from 'svelte/elements';

  const {
    class: className,
    children,

    name = undefined,
    color = 'currentColor',
    size = 24,
    strokeWidth = 2,
    absoluteStrokeWidth = false,
    iconNode = [],

    ...props
  }: SvelteHTMLElements['svg'] & {
    name: string | undefined;
    color: string;
    size: number | string;
    strokeWidth: number | string;
    absoluteStrokeWidth: boolean;
    iconNode: IconNode;
  } = $props();

  const mergeClasses = <ClassType = string | undefined | null,>(...classes: ClassType[]) =>
    classes
      .filter((className, index, array) => {
        return Boolean(className) && array.indexOf(className) === index;
      })
      .join(' ');
</script>

<svg
  {...defaultAttributes}
  {...props}
  width={size}
  height={size}
  stroke={color}
  stroke-width={absoluteStrokeWidth ? (Number(strokeWidth) * 24) / Number(size) : strokeWidth}
  class={mergeClasses('lucide-icon', 'lucide', name ? `lucide-${name}` : '', className)}
>
  {#each iconNode as [tag, attrs]}
    <svelte:element
      this={tag}
      {...attrs}
    />
  {/each}
  {@render children?.()}
</svg>

should work

@Shyrogan
Copy link

https://github.com/lucide-icons/lucide/pull/2380/files

Should fix what I mentioned. Thank you @alissa-tung, I don't see any improvements to make, let's hope it gets merged :)

@alissa-tung
Copy link

https://github.com/lucide-icons/lucide/pull/2380/files

Should fix what I mentioned. Thank you @alissa-tung, I don't see any improvements to make, let's hope it gets merged :)

I think that would be great, but since I am new to JavaScript, I think I can not even handle my own pull request. I opened it hope someone can notice that there should happen something for Svelte 5 version, and if someone can take over this PR I thing would be much helpful

@bobvork
Copy link

bobvork commented Aug 19, 2024

Please note that svelte:component has been deprecated as of 5.0.0-next.217: https://github.com/sveltejs/svelte/releases/tag/svelte%405.0.0-next.217. It should work for now, but might be worth looking into the new syntax, as found in the preview docs here: https://svelte-5-preview.vercel.app/docs/breaking-changes#breaking-changes-in-runes-mode-svelte-component-is-no-longer-necessary

@kirso
Copy link

kirso commented Sep 19, 2024

Also type compatibility:

import type { Component } from 'svelte';
import { Globe, Map, CheckCircle, FileText, Clock, Users, Search } from 'lucide-svelte';
import type { Icon } from 'lucide-svelte';
export const Icons: Component<Icon> = {
	Globe,
	Map,
	CheckCircle,
	FileText,
	Clock,
	Users,
	Search
};

export { Globe, Map, CheckCircle, FileText, Clock, Users, Search };

Throws:
Object literal may only specify known properties, and 'Globe' does not exist in type 'Component<Icon, {}, string>'.ts(2353)

@cowboycodr
Copy link

#2312 (comment)
Typing seems to be the biggest issue currently.

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

No branches or pull requests

7 participants