-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
Change helpText from prop to slot in NameAndDescInputModalForm #1858
Comments
I would like to work on it, if it is still open. @rajatvijay could you please assign this to me? |
@KAIMonmoy Thanks! Feel free to start work on this ticket and submit a PR when you're ready. We are non longer marking external contributors as officially "assigned" to tickets though because it's been challenging managing the people who don't follow through. |
Thank you for your response, @seancolsen. I'll start working on this ticket. |
Hey @seancolsen , Because when we're passing helpText as a prop we can conditionally render the Alert Component in File: But when we are passing helpText as a slot, we'll have to update the code in File: - {#if helpText}
- <Alert appearance="info">
- <slot slot="content">{helpText}</slot>
- </Alert>
- {/if}
+ {#if $$slots.helpText}
+ <Alert appearance="info">
+ <slot name="helpText" slot="content" />
+ </Alert>
+ {/if} But now in order to make it work properply we'll have to change the code in File: saveButtonLabel={schema ? 'Save' : 'Create New Schema'}
- helpText={schema ? '' : createSchemaHelpText}
>
+ {#if !schema}
+ <svelte:fragment slot="helpText">{createSchemaHelpText}</svelte:fragment>
+ {/if} But the problem is we cannot have a I can think of two solutions to overcome this issue. (1) Taking the Alert component to File - // mathesar_ui/src/components/NameAndDescInputModalForm.svelte
- {#if helpText}
- <Alert appearance="info">
- <slot slot="content">{helpText}</slot>
- </Alert>
- {/if}
+ {#if $$slots.helpText}
+ <Alert appearance="info">
+ <slot name="helpText" slot="content" />
+ </Alert>
+ {/if} // mathesar_ui/src/pages/database/AddEditSchemaModal.svelte
- import type { ModalController } from '@mathesar-component-library';
+ import { Alert, ModalController } from '@mathesar-component-library';
...
saveButtonLabel={schema ? 'Save' : 'Create New Schema'}
- helpText={schema ? '' : createSchemaHelpText}
>
...
{#if schema}
Rename <Identifier>{initialName}</Identifier> Schema
{:else}
Create Schema
+ <Alert appearance="info" slot="helpText">
+ <span slot="content">{createSchemaHelpText}</span>
+ </Alert>
{/if} (2) We can extract out Alert along with the helpText slot and make it into a component called NameAndDescInputModalFormHelp text. And use that in place of the Alert component in File - Let me know which one you prefer. And also if you think I am missing something or there are other ways to solve this problem, please share those with me. |
Ugh. You've run into sveltejs/svelte#5604. I've hit this before and it's annoying. Here's the way I'd like to fix this...
That should do the trick. You shouldn't need to mess with the position of the light bulb in |
@seancolsen I have opened a PR-1903. That should close fix/close this issue. Thanks for all the help. |
helpText
would work better as a slot than as a prop. I see in the parent component you're passing a huge string into this prop. If you use a slot, you'll be able to move that text out of a string and put it directly into the template. This also makes it possible to put formatting in the help text.File:
mathesar_ui/src/components/NameAndDescInputModalForm.svelte
Originally posted by @seancolsen in #1793 (comment)
The text was updated successfully, but these errors were encountered: