Skip to content

Commit

Permalink
Merge pull request #15 from senkulabs/14-fix-linter-and-svelte-check-…
Browse files Browse the repository at this point in the history
…complains

Fix Complains from Linter and Svelte Check
  • Loading branch information
kresnasatya authored Nov 16, 2024
2 parents 04794a0 + f494e81 commit b7483f4
Show file tree
Hide file tree
Showing 31 changed files with 342 additions and 255 deletions.
3 changes: 2 additions & 1 deletion stubs/inertia-svelte-ts/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default ts.config(
},
{
rules: {
'no-undef': 'off'
'no-undef': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
}
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class: className,
...attrs
}: HTMLInputAttributes & {
checked?: boolean
checked?: boolean;
} = $props();
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class: className,
...attrs
}: HTMLButtonAttributes & {
children: Snippet
} = $props()
children: Snippet;
} = $props();
</script>

<button
Expand Down
50 changes: 25 additions & 25 deletions stubs/inertia-svelte-ts/resources/js/Components/Dropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
content,
contentClasses = 'py-1 bg-white dark:bg-gray-700',
trigger,
width = '48',
width = '48'
}: {
align?: 'left' | 'right'
content: Snippet
contentClasses?: string
trigger: Snippet
width?: '48'
} = $props()
align?: 'left' | 'right';
content: Snippet;
contentClasses?: string;
trigger: Snippet;
width?: '48';
} = $props();
let open = $state(false);
let widthClass = $derived({ '48': 'w-48' }[width]);
Expand All @@ -24,12 +24,12 @@
? 'ltr:origin-top-left rtl:origin-top-right start-0'
: align === 'right'
? 'ltr:origin-top-right rtl:origin-top-left end-0'
: 'origin-top',
)
: 'origin-top'
);
function closeOnEscape(e: KeyboardEvent) {
if (open && e.key === 'Escape') {
open = false
open = false;
}
}
Expand All @@ -39,11 +39,10 @@
easing?: (t: number) => number;
}
function enter(node: HTMLElement, {
delay = 0,
duration = 200,
easing = cubicOut
}: TransitionParams = {}): TransitionConfig {
function enter(
node: HTMLElement,
{ delay = 0, duration = 200, easing = cubicOut }: TransitionParams = {}
): TransitionConfig {
return {
delay,
duration,
Expand All @@ -52,14 +51,13 @@
opacity: ${t};
transform: scale(${0.95 + 0.05 * t});
`
}
};
}
function leave(node: HTMLElement, {
delay = 0,
duration = 75,
easing = cubicIn
}: TransitionParams = {}): TransitionConfig {
function leave(
node: HTMLElement,
{ delay = 0, duration = 75, easing = cubicIn }: TransitionParams = {}
): TransitionConfig {
return {
delay,
duration,
Expand All @@ -68,7 +66,7 @@
opacity: ${t};
transform: scale(${0.95 + 0.05 * t});
`
}
};
}
</script>

Expand All @@ -85,12 +83,14 @@
{#if open}
<div class="fixed inset-0 z-40" onclick={() => (open = false)}></div>
<div in:enter out:leave>
<div class="absolute z-50 mt-2 rounded-md shadow-lg {widthClass} {alignmentClasses}"
onclick={() => (open = false)}>
<div
class="absolute z-50 mt-2 rounded-md shadow-lg {widthClass} {alignmentClasses}"
onclick={() => (open = false)}
>
<div class="rounded-md ring-1 ring-black ring-opacity-5 {contentClasses}">
{@render content()}
</div>
</div>
</div>
{/if}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import { Link } from '@inertiajs/svelte';
import type { Method } from '@inertiajs/core';
let {
children,
href,
method,
as,
...attrs
}: {
children: Snippet
href: string
} = $props()
children: Snippet;
href: string;
method?: Method;
as?: keyof HTMLElementTagNameMap;
} = $props();
</script>

<Link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
message,
...attrs
}: HTMLAttributes<HTMLDivElement> & {
message?: string
} = $props()
message?: string;
} = $props();
</script>

{#if message}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
value,
...attrs
}: HTMLLabelAttributes & {
children?: Snippet
value?: string
} = $props()
children?: Snippet;
value?: string;
} = $props();
</script>

<label {...attrs} class="block text-sm font-medium text-gray-700 dark:text-gray-300 {className}">
Expand Down
66 changes: 38 additions & 28 deletions stubs/inertia-svelte-ts/resources/js/Components/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@
closeable = true,
maxWidth = '2xl',
onclose = () => {},
show = false,
show = false
}: {
children: Snippet
closeable?: boolean
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'
onclose?: () => void
show?: boolean
children: Snippet;
closeable?: boolean;
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
onclose?: () => void;
show?: boolean;
} = $props();
let maxWidthClass = $derived(
{
'sm': 'sm:max-w-sm',
'md': 'sm:max-w-md',
'lg': 'sm:max-w-lg',
'xl': 'sm:max-w-xl',
'2xl': 'sm:max-w-2xl',
}[maxWidth],
)
sm: 'sm:max-w-sm',
md: 'sm:max-w-md',
lg: 'sm:max-w-lg',
xl: 'sm:max-w-xl',
'2xl': 'sm:max-w-2xl'
}[maxWidth]
);
$effect(() => {
if (show) document.body.appendChild(dialog);
if (document) document.body.style.overflow = show ? 'hidden' : 'visible';
return () => {
if (document) document.body.style.overflow = 'visible';
}
})
};
});
function close() {
if (closeable) {
Expand All @@ -55,20 +55,30 @@
<svelte:window on:keydown={closeOnEscape} />

{#if show}
<div bind:this={dialog} style:display={show ? 'contents' : 'none'}>
<div class="fixed inset-0 z-50 px-4 py-6 overflow-y-auto sm:px-0" scroll-region>
<div in:fade={{ duration: 300, easing: cubicOut }} out:fade={{ duration: 200, easing: cubicIn }}>
<!-- svelte-ignore a11y_consider_explicit_label -->
<button class="fixed inset-0 transition-all transform-select-none" onclick={close}>
<div class="absolute inset-0 bg-gray-500 opacity-75 dark:bg-gray-900">&nbsp;</div>
</button>
</div>
<div bind:this={dialog} style:display={show ? 'contents' : 'none'}>
<div class="fixed inset-0 z-50 px-4 py-6 overflow-y-auto sm:px-0" scroll-region>
<div
in:fade={{ duration: 300, easing: cubicOut }}
out:fade={{ duration: 200, easing: cubicIn }}
>
<!-- svelte-ignore a11y_consider_explicit_label -->
<button class="fixed inset-0 transition-all transform-select-none" onclick={close}>
<div class="absolute inset-0 bg-gray-500 opacity-75 dark:bg-gray-900">
&nbsp;
</div>
</button>
</div>

<div in:fade={{ duration: 300, easing: cubicOut }} out:fade={{ duration: 200, easing: cubicIn }}>
<div class="mb-6 bg-white dark:bg-gray-800 rounded-lg overflow-hidden shadow-xl transform transition-all sm:w-full sm:mx-auto {maxWidthClass}">
{@render children()}
<div
in:fade={{ duration: 300, easing: cubicOut }}
out:fade={{ duration: 200, easing: cubicIn }}
>
<div
class="mb-6 bg-white dark:bg-gray-800 rounded-lg overflow-hidden shadow-xl transform transition-all sm:w-full sm:mx-auto {maxWidthClass}"
>
{@render children()}
</div>
</div>
</div>
</div>
</div>
{/if}
{/if}
19 changes: 13 additions & 6 deletions stubs/inertia-svelte-ts/resources/js/Components/NavLink.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import { Link } from '@inertiajs/svelte';
import type { Method } from '@inertiajs/core';
let {
active = false,
children,
href,
method,
as,
...attrs
}: {
active?: boolean
children: Snippet
href: string
} = $props()
active?: boolean;
children: Snippet;
href: string;
method?: Method;
as?: keyof HTMLElementTagNameMap;
} = $props();
</script>

<Link
{...attrs}
{href}
class={active ? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 dark:border-indigo-600 text-sm font-medium leading-5 text-gray-900 dark:text-gray-100 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300 dark:hover:border-gray-700 focus:outline-none focus:text-gray-700 dark:focus:text-gray-300 focus:border-gray-300 dark:focus:border-gray-700 transition duration-150 ease-in-out'}>
class={active
? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 dark:border-indigo-600 text-sm font-medium leading-5 text-gray-900 dark:text-gray-100 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300 dark:hover:border-gray-700 focus:outline-none focus:text-gray-700 dark:focus:text-gray-300 focus:border-gray-300 dark:focus:border-gray-700 transition duration-150 ease-in-out'}
>
{@render children()}
</Link>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class: className,
...attrs
}: HTMLButtonAttributes & {
children: Snippet
} = $props()
children: Snippet;
} = $props();
</script>

<button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import { Link } from '@inertiajs/svelte';
import type { Method } from '@inertiajs/core';
let {
active = false,
children,
href,
method,
as,
...attrs
}: {
active?: boolean
children: Snippet
href: string
} = $props()
active?: boolean;
children: Snippet;
href: string;
method?: Method;
as?: keyof HTMLElementTagNameMap;
} = $props();
</script>

<Link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
type = 'button',
...attrs
}: HTMLButtonAttributes & {
children: Snippet
type?: 'button' | 'submit' | 'reset'
} = $props()
children: Snippet;
type?: 'button' | 'submit' | 'reset';
} = $props();
</script>

<button
Expand Down
10 changes: 5 additions & 5 deletions stubs/inertia-svelte-ts/resources/js/Components/TextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
value = $bindable(),
...attrs
}: HTMLInputAttributes & {
value?: string
} = $props()
value?: string;
} = $props();
let input: HTMLInputElement;
export function focus() {
input?.focus()
input?.focus();
}
onMount(() => {
if (attrs.autofocus && input) {
input.focus()
input.focus();
}
})
});
</script>

<input
Expand Down
Loading

0 comments on commit b7483f4

Please sign in to comment.