-
-
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
fa4bcb0
commit a8540fb
Showing
19 changed files
with
561 additions
and
34 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
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
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
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,17 @@ | ||
<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} /> |
7 changes: 7 additions & 0 deletions
7
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: 25 additions & 0 deletions
25
mathesar_ui/src/component-library/string-or-component/StringOrComponentTyped.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,25 @@ | ||
<!-- | ||
@component | ||
This component replaces `StringOrComponent` (which is deprecated) | ||
--> | ||
<script lang="ts"> | ||
import type { SvelteComponent } from 'svelte'; | ||
import type { ComponentWithProps } from '@mathesar-component-library-dir/types'; | ||
import Render from '../render/Render.svelte'; | ||
type T = $$Generic<SvelteComponent>; | ||
export let arg: string | string[] | ComponentWithProps<T>; | ||
</script> | ||
|
||
{#if typeof arg === 'string'} | ||
{arg} | ||
{:else if Array.isArray(arg)} | ||
{#each arg as paragraph} | ||
<p>{paragraph}</p> | ||
{/each} | ||
{:else} | ||
<Render componentWithProps={arg} /> | ||
{/if} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<span class="field-help"><slot /></span> | ||
|
||
<style> | ||
.field-help { | ||
display: block; | ||
font-size: var(--text-size-small); | ||
color: var(--color-text-muted); | ||
margin-top: 0.5rem; | ||
} | ||
</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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<script lang="ts"> | ||
/** When the form is wider than this, it will display in a grid. When it's | ||
* narrower, it will display vertically */ | ||
export let breakpointPx = 400; | ||
let width: number; | ||
</script> | ||
|
||
<div | ||
class="grid-form" | ||
bind:clientWidth={width} | ||
class:grid={width > breakpointPx} | ||
> | ||
<slot /> | ||
</div> | ||
|
||
<style> | ||
.grid-form:not(.grid) > :global(* + *) { | ||
margin-top: 1rem; | ||
} | ||
.grid-form:not(.grid) > :global(.divider + .divider) { | ||
display: none; | ||
} | ||
.grid-form:not(.grid) > :global(:nth-child(even)) { | ||
margin-left: 1rem; | ||
margin-bottom: 2rem; | ||
} | ||
.grid-form.grid { | ||
display: grid; | ||
grid-template-columns: fit-content(30%) 1fr; | ||
gap: 1.5rem 0; | ||
} | ||
.grid-form.grid > :global(:nth-child(odd)) { | ||
text-align: right; | ||
padding-right: 1rem; | ||
} | ||
</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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="divider" /> | ||
<div class="divider" /> | ||
|
||
<style> | ||
.divider { | ||
height: 0; | ||
border-top: solid 1px var(--slate-300); | ||
} | ||
</style> |
28 changes: 28 additions & 0 deletions
28
mathesar_ui/src/components/grid-form/GridFormLabelRow.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,28 @@ | ||
<script lang="ts"> | ||
import { | ||
Label, | ||
LabelController, | ||
setLabelControllerInContext, | ||
} from '@mathesar-component-library'; | ||
const labelController = new LabelController(); | ||
setLabelControllerInContext(labelController); | ||
export let label: string; | ||
</script> | ||
|
||
<div class="label-cell"> | ||
<Label controller={labelController}> | ||
{label} | ||
</Label> | ||
</div> | ||
|
||
<div class="input-cell"> | ||
<slot /> | ||
</div> | ||
|
||
<style> | ||
.label-cell { | ||
padding-top: 0.5rem; | ||
} | ||
</style> |
Oops, something went wrong.