-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3d0cee
commit c30b99f
Showing
7 changed files
with
67 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
mathesar_ui/src/component-library/margin-trim/MarginTrim.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- | ||
@component Trims the outer margins of its children. | ||
--> | ||
|
||
<div class="margin-trim"> | ||
<slot /> | ||
</div> | ||
|
||
<style> | ||
.margin-trim > :first-child { | ||
margin-top: 0; | ||
} | ||
.margin-trim > :last-child { | ||
margin-bottom: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
<script lang="ts"> | ||
import type { SvelteComponent } from 'svelte'; | ||
import type { ComponentWithProps } from '../types'; | ||
import RenderComponentWithProps from './RenderComponentWithProps.svelte'; | ||
import MarginTrim from '@mathesar-component-library-dir/margin-trim/MarginTrim.svelte'; | ||
import type { ComponentWithProps } from '@mathesar-component-library-dir/types'; | ||
type T = $$Generic<SvelteComponent>; | ||
export let componentWithProps: ComponentWithProps<T>; | ||
// I'm not sure how to fix the use of `any` here. Suggestions welcome! | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
$: component = componentWithProps.component as any; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
$: props = componentWithProps.props as any; | ||
export let arg: string | string[] | ComponentWithProps<T> | undefined = | ||
undefined; | ||
</script> | ||
|
||
<svelte:component this={component} {...props} /> | ||
{#if arg === undefined} | ||
{''} | ||
{:else if typeof arg === 'string'} | ||
{arg} | ||
{:else if Array.isArray(arg)} | ||
{#if arg.length === 0} | ||
{''} | ||
{:else if arg.length === 1} | ||
{arg[0]} | ||
{:else} | ||
<MarginTrim> | ||
{#each arg as paragraph} | ||
<p>{paragraph}</p> | ||
{/each} | ||
</MarginTrim> | ||
{/if} | ||
{:else} | ||
<RenderComponentWithProps componentWithProps={arg} /> | ||
{/if} |
21 changes: 21 additions & 0 deletions
21
mathesar_ui/src/component-library/render/RenderComponentWithProps.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- | ||
@component This component only exists to encapsulate usage of `any`. If we're | ||
able to remove usage of `any`, we could consider inlining this code instead. | ||
--> | ||
<script lang="ts"> | ||
import type { SvelteComponent } from 'svelte'; | ||
import type { ComponentWithProps } from '../types'; | ||
type T = $$Generic<SvelteComponent>; | ||
export let componentWithProps: ComponentWithProps<T>; | ||
// I'm not sure how to fix the use of `any` here. Suggestions welcome! | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
$: component = componentWithProps.component as any; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
$: props = componentWithProps.props as any; | ||
</script> | ||
|
||
<svelte:component this={component} {...props} /> |
5 changes: 2 additions & 3 deletions
5
mathesar_ui/src/component-library/string-or-component/StringOrComponent.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
mathesar_ui/src/component-library/string-or-component/StringOrComponentTyped.svelte
This file was deleted.
Oops, something went wrong.