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

Sveltekit typescript component bug #17566

Closed
gzimbron opened this issue Feb 24, 2022 · 3 comments
Closed

Sveltekit typescript component bug #17566

gzimbron opened this issue Feb 24, 2022 · 3 comments

Comments

@gzimbron
Copy link

gzimbron commented Feb 24, 2022

Describe the bug
Autogeneration of properties,events and slots doenst work when I user: "export let varName: string;"

Icon.stories.svelte:

<script>
  import Icon from '$components/Icon.svelte';
  import { Meta, Story, Template } from '@storybook/addon-svelte-csf';
</script>

<Meta component={Icon} />

<Template let:args>
  <Icon {...args} />
</Template>

<Story
  name="Person"
  args={{
    icon: 'person',
  }}
/>
<Story
  name="Arrow Left"
  args={{
    icon: 'arrow_left',
  }}
/>

Autogeneration working Component :
Icon.svelte

<script lang="ts">
  import { createEventDispatcher } from 'svelte';

  export let icon = '';
  export let size = '';
  export let color = '';
  export let cursor = '';
  export let bold = false;

  const dispatch = createEventDispatcher();

  const click = () => {
    dispatch('click');
  };
</script>

<span
  class:material-icons={icon}
  style:cursor
  style:color
  style:font-weight={bold ? 'bold' : 'normal'}
  style:--icon-size={size}
  on:click={click}
>
  {icon}
</span>

<style>
  /* @import 'https://fonts.googleapis.com/icon?family=Material+Icons'; */

  @font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url('/MaterialIcons-Regular.ttf') format('truetype');
  }

  .material-icons {
    width: var(--icon-size);
    height: var(--icon-size);
    font-size: var(--icon-size);
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;

    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;

    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;

    /* Support for IE. */
    font-feature-settings: 'liga';
  }
</style>


result:
image

Autogeneration NOT working Component:
Icon.svelte

<script lang="ts">
  import { createEventDispatcher } from 'svelte';

  export let icon: string;
  export let size = '';
  export let color = '';
  export let cursor = '';
  export let bold = false;

  const dispatch = createEventDispatcher();

  const click = () => {
    dispatch('click');
  };
</script>

<span
  class:material-icons={icon}
  style:cursor
  style:color
  style:font-weight={bold ? 'bold' : 'normal'}
  style:--icon-size={size}
  on:click={click}
>
  {icon}
</span>

<style>
  /* @import 'https://fonts.googleapis.com/icon?family=Material+Icons'; */

  @font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url('/MaterialIcons-Regular.ttf') format('truetype');
  }

  .material-icons {
    width: var(--icon-size);
    height: var(--icon-size);
    font-size: var(--icon-size);
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;

    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;

    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;

    /* Support for IE. */
    font-feature-settings: 'liga';
  }
</style>

result:
image

@analubarreto
Copy link

+1 I have a similar issue I'm using the latest prerelese version.

@j3rem1e
Copy link
Contributor

j3rem1e commented Apr 4, 2022

Storybook uses sveltedoc-parser for extracting component docs and properties.
It doesn't support typescript now : alexprey/sveltedoc-parser#34

@IanVS
Copy link
Member

IanVS commented Jun 2, 2022

Hi, we can track this issue in #15891.

@IanVS IanVS closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants