758 questions
0
votes
1
answer
72
views
Save data submitted from a Form into a Store in Sveltekit
So I've got the following component working so far records/new/+page.svelte:
<script>
import RecordForm from "../../../components/forms/RecordForm.svelte";
import TrackForm ...
0
votes
1
answer
61
views
Get submitted button's name in Sveltekit actions
I've got a form with 2 buttons:
<form method="POST" class="pt-10">
<div class="flex flex-row pt-10">
<button type="submit" name="...
0
votes
0
answers
44
views
Unable to use firebase in svelte
I am trying to add some code to previous github repo but while using firebase after creating a page in src/routes folder I am unable to use it. Do I have to use firebase compat? As that also didn't ...
0
votes
1
answer
148
views
Sveltekit reuse form as a modal within another form
I've got the following route:
- routes
- artists
- [slug]
- new
- +page.server.js
- +page.svelte
where new/+page.svelte is the following:
<script>
import ...
0
votes
1
answer
352
views
Redirect using server hooks not working in SvelteKit
I am creating an application in sveltekit, trying to protect my routes through the use of hooks or middleware, but when I am logged in and try to enter an unprotected route, I want to redirect to the /...
0
votes
0
answers
190
views
Some help figuring out why +page.server.js load functions are not firing
I recently decided to localize my site using the sveltekit-i18n library, following this example. The problem is that in it the handle hook seems to mess with the load functions when redirecting using ...
0
votes
1
answer
56
views
Why <slot item={child} /> is needed for the nested object to be displayed if <slot item={item} /> is present?
This question is in reference to
Pass in a slot to a recursive component
REPL
App.svelte
<script>
import Tree from './Tree.svelte';
const items = [
{
type: 'person', ...
0
votes
1
answer
348
views
Svelte change bind:value in keydown event
I want to add spaces in a card ID input field automatically as the user is typing it. Here is my setup:
<input placeholder="e.g. 5200 1234 5678 9012 3456" bind:value={inputAC}
...
0
votes
0
answers
56
views
Tagging M4A Files
I have a m4a file. How can I assign tags to it in the browser using javascript? It has mp4a.40.5 codec. I'm using [email protected] with [email protected]
Tried writing tags to it using browser-id3-writer ...
0
votes
0
answers
150
views
How to set up a svelte-carousel in modal pop-up
Sorry for the newbie question: I have a svelte website that was built for me, and I'm trying to tweak it to include a carousel in a modal pop-up. So my knowledge is limited and I am trying to get by.
...
0
votes
1
answer
259
views
Why won't my Svelte dropdown close when the dropdown is open, but I click on the Dropdown Box?
What Works
Hi, I have an issue with my custom HTML dropdown made in Svelte. I'm a React engineer and new to svelte due to this company code that this small portion was written in just because previous ...
0
votes
1
answer
217
views
Accessing not defined property on svelte component should raise TypeScript type error
When using Svelte with TypeScript, I expected that accessing a property on a component that has not been defined to result in a type error. It results in the property being typed as any instead.
I ...
1
vote
1
answer
131
views
Svelte3: A modal at docroot with dynamic content
I am trying to implement a modal dialog box somewhat typical, but with a few prerequisites that I don't see how to implement the svelte way:
It needs to sit at docroot (and be free of parents ...
0
votes
1
answer
27
views
targeting a specific element in iteration using js and svelte
I love and use svelte in everything but this a new issue that I've never encountered before and I'm unable to figure a solution.
I'm using svelte to iterate over an array :
<section>
<h5&...
1
vote
0
answers
137
views
Jest encountered an unexpected token during upgrade Svelte v3 to v4
I'm stucked during the upgrade of svelte v3 to v4 using the official guide. My tests are failing and I've tried multiple ways to fix it but nothing worked here for me. Here some details about my ...
2
votes
1
answer
61
views
How to disambiguate svelte components?
I have the following typescript type:
type ItemTypes = (GameItem & { id: undefined }) | (CurrencyItem & { id: string });
The GameItem is an object that doesn't have the "id" ...
0
votes
2
answers
1k
views
Sveltekit: display alert message after redirecting
I'm working on a project using Sveltekit for the frontend. To display on screen alert messages I had created the following.
In +layout.svelte (the main layout file) I have:
<!-- Main content -->
...
0
votes
1
answer
157
views
Tweened component prop
I have this CircularProgressBar.svelte component and I want to animate when the percentage changes.
This is how CircularProgressBar.svelte is defined:
<script>
import { onMount } from "...
3
votes
2
answers
293
views
I don't understand what Svelte docs is trying to say about reactive statements
I have taken this from Svelte docs
It is important to note that the reactive blocks are ordered via simple static analysis at compile time, and all the compiler looks at are the variables that are ...
0
votes
2
answers
381
views
Apply transition to change of position
I was following the Svelte tutorial, more specifically the part about REST params, I tried to animate the whole thing; however, I only succeeded into animating what is inside the each block.
I wanted ...
0
votes
1
answer
619
views
SvelteKit authentication issues with persistency
Issue Description:
I'm building a web application using Svelte and Node.js.
The application has user authentication using JWT tokens, and you store these tokens and user information in cookies.
The ...
1
vote
1
answer
696
views
Svelte running preview build can't load local json files
I have a svelte app I've been working on for some time and I'm ready to deploy it to the hosting service I have. When I create the build using npm run build there are no errors. Then when I preview ...
0
votes
0
answers
140
views
How to derive a store that contains a list of stores in svelte
I have a store that contains a list of derived stores in svelte. (I know this might not be the best but humor me). How can I create a store that gives the inner values? I came up with this function:
...
0
votes
0
answers
132
views
Svelte and TypeScript how to package a reusable store?
I am new to using Svelte stores. I want to write one and use it in a package I am making. The reason for a store is that it contains state that I want accessible across a few different components. ...
1
vote
0
answers
389
views
Change CSS in Svelte
Good morning,
I'm doing slim for the first time on a small personal project and I'm having some difficulties, if you can help me :-)
I have a logo, I want to modify its CSS, once modified in the ...
0
votes
1
answer
2k
views
How to create a HotKey / HotKeys component(s) for Svelte Kit, Svelte, and TailwindCSS?
How to create a HotKey / HotKeys component(s) for Svelte Kit, Svelte, and TailwindCSS?
I am trying to create a HotKey component for Svelte Kit using TailwindCSS for styling. My aim is to capture ...
2
votes
0
answers
337
views
'Property doesn't exist' error with imported module in Svelte
I want to use big.js or decimal.js to perform accurate calculations of decimal numbers in my basic Svelte app. To test it, I have imported the module in my App.svelte file:
import Decimal from ".....
3
votes
1
answer
2k
views
Sveltekit is not intercepting fetch call in handleFetch hook
I recently discovered the handleFetch hook in Sveltekit. Now I'm trying to use it to intercept calls to my backend (written in Go) but doesn't seem to work (unless I'm missing something).
The ...
2
votes
1
answer
1k
views
How to correctly infer Svelte props type?
I have a svelte component (SvelteKit Project) - let's call it MyComponent. It accepts two props.
What would be the correct way to do it with TypeScript?
Option 1: Type-cast the $$props
<script lang=...
2
votes
2
answers
159
views
Make two variables reactive both ways
I want to make two variables reactive both ways. That means, if i change, lets say variable a, then i want variable b to change specified by some defined function, and if i change variable b, then i ...
1
vote
2
answers
315
views
Is there a good way to style HTML elements and re-expose all of their events in a Svelte component?
How would I go about styling HTML elements and re-exposing all of their events in a Svelte component? (essentially, I'm looking for the Svelte way to do styled-components)
For example, I'm trying to ...
0
votes
2
answers
1k
views
Having a svelte store per component instance while able to access it globaly
So I have this parent component containing multiple children components like so:
<script>
import { derived, writable } from 'svelte/store';
import {childStore } from 'child.svelte';
export ...
1
vote
1
answer
1k
views
Returning Svelte components with Sveltekit server load function
I'm new to Sveltekit, and having issues trying to return Svelte components from the server.
I'm migrating settings for a nav menu in Sveltekit from a client-side .svelte component to a server load() ...
0
votes
1
answer
850
views
onMount called after function call from parent component
I have the following minimal example:
Component A:
<script lang="ts">
import {tick} from 'svelte';
import LocationSelector from './LocationSelector.svelte';
let ...
1
vote
1
answer
271
views
Svelte two way Store Binding in wrong order
The value of a Svelte store is overwritten with 'null' by the bound Select component from Svelte-Select Library.
Writable store: const export store = writable("startingValue")
Component ...
9
votes
1
answer
2k
views
How to compile Svelte 3 components into IIFE's that can be used in vanilla js
I am making a web component in Vanilla JS that use a hidden select in the background and a div and ul>li in front. It became a bit complex with fetching data from an api, ect, so I transitioned to ...
0
votes
2
answers
64
views
How to show header for grouped names in Svelte?
I'm currently using Svelte to show a list of names and I want to show a headline every time the name in the list changes, so the user has a clear view of the grouped names.
In this example I'm using ...
0
votes
2
answers
3k
views
Sveltekit not placing form value on input field (using use:enhance)
I'm facing a kind of weird situation. I've got the following form:
<script>
import RecordForm from "../../../components/forms/RecordForm.svelte";
/* data returned from load ...
3
votes
2
answers
2k
views
SvelteKit iFrame load event not firing
I have an iframe which is loading a local index.html file and it does loads the page without any problems, but what I want is to capture an onload event of the iframe and it is not doing so. Here is ...
0
votes
1
answer
240
views
Svelte "router.reload" does not update data every time
In Svelte (using Laravel 9, Svelte via Inertia), I have built a component "BookmarkButton.svelte".
In this component, I am executing a function "handleBookmark" when the button is ...
1
vote
1
answer
556
views
Prevent Svelte from adding random classes
I have a shadow-root component and I simply don't want svelte-kit to add those random classes to that specific element or its child elements. It would be nice if there was something in the settings ...
1
vote
1
answer
1k
views
Editing a form with SvelteKit
I've got an Artist page in SvelteKit. Its route looks like the following:
routes
artists
[slug]
+page.server.js
+page.svelte
new
+page.server.js
...
0
votes
1
answer
303
views
How can I get a value from a named action into localStorage
I have a basic login form that triggers a named action on submit. The code in the +page.server.js file is fetching a bearer token from a web API, which is working fine. I'm currently writing the ...
1
vote
1
answer
647
views
Is there a way to only scaleX with svelte transition?
So I want to create a transition when my element will be out. I want the transition to only scaleX (from 1 to 0), because I know that in svelt there is a scale transition but it scales the element in ...
1
vote
1
answer
1k
views
svelte kit routing and naming covention problem
when i create a new svelte kit project the default file is +page.svelte if i change the name it wont render and if i try to link to other svelte file it wont work
<script>
import { goto } from ...
1
vote
2
answers
2k
views
Cannot access localstorage from sveltekit hook
I've got a function that verifies whether an user is logged in or not:
export const isUserLoggedIn = () => {
let dmcAuthToken = localStorage.getItem(AUTH_TOKEN_KEY);
return dmcAuthToken ? ...
0
votes
1
answer
125
views
Svelte #each over array of constants how?
Making first steps with Svelte and already loving it , noob question but I guess Svelte can not track such an update?
What would be Svelte way of writing this?
Uncommenting 2 would work, but even ...
0
votes
2
answers
69
views
Strange behavior with binding from store
I have some data points, which should be presented in a card grid.
Whenever I hover over one of the cards, I update a value in a svelte store.
This value should be used elsewhere (it's the id of the ...
1
vote
1
answer
737
views
Why does adding an if block prevent Svelte transitions from playing?
I'm working on some code where I fetch some items in onMount then render them. I don't want to play a ton of transitions for the big batch of fetched items. However, I do want to play transitions when ...
1
vote
1
answer
392
views
How to bind compiled result of string to component in Svelte
I am trying to write a component which has a source string property. Then, users can set the source and my component compiles and renders the source.
Both SPA and SSR should be supported for compiling ...