Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Component inheritance #378

@pournasserian

Description

@pournasserian

While developing a component library, there are some properties and functionalities which are shared between many components.

Here are some examples:

  • class
  • if
  • on:click
  • id
  • etc.

Read this Svelte Issue first.

<script lang="ts">
    import type { ComponentProps } from 'svelte';
    interface $$Props extends  ComponentProps<Button> {}
</script>


<Button whateverButtonProp={...} {...$$restProps} on:click on:any-action-you-wanna-forward>
	<slot />
</Button>

There are some options:

  • Using above code
  • Using/refactoring external library here
  • Using context
  • Developing a custom preprocessor
  • Using Svelte native: here is a draft: Repl
  • Using Svelte native: here is a draft: Repl
  • Using Svelte native: here is a draft: Repl
  • Using Svelte native: here is a draft: Repl

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions