andahendriksen
andahendriksen
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
Cool! Thanks for the link to nitro! I'm taking a bit of a different approach though, building a stupid webbuilder for people that don't know what columns or paddings are haha
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
Yes, especially for me as a much more visual frontend/ux designer. I'm not good at "seeing" the logical way to code. Guess I'll have to hire an Italian chef in the future to clean up all the spaghetti code I've made haha
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
lol that is so much cleaner! Knew there would be a simpler way haha thank you so much for your help, really appreciate it! 😎
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
element_indexes is to tell how deep in the element tree I'm going. It can be:
[4, 2, 8]
[4, 2, 8]
or
[1, 4, 9, 3, 2, 5, 2, 1]
[1, 4, 9, 3, 2, 5, 2, 1]
But I don't know which one it will be. So fo each of the indexes in the element_indexes I'll go deeper. Does that make sense?
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
Hahaha you saw that! 😄 Thx
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
I got it to work! But I don't know if there's a better way to do it? I've come up with this:
function findElementToUpdate(
element: Element,
element_indexes: number[],
index_level: number,
element_to_update?: Element,
content_to_update?: Content,
content_index?: number
) {
const has_next_index = element_indexes.length !== index_level

if (has_next_index) {
const next_index = element_indexes[index_level]

return findElementToUpdate(
element.elements[next_index],
element_indexes,
index_level + 1,
element_to_update,
content_to_update)
}

if (content_to_update) {
element.content[content_index] = {
...element.content[content_index],
...content_to_update
}
}

if (element_to_update) {
element = {
...element,
...element_to_update
}
}
}

export function setPageStoreElement(
element_indexes: number[],
element_to_update?: Element,
content_to_update?: Content,
content_index?: number
) {
setPageStore(produce((pageStore) => {
findElementToUpdate(
pageStore.page.elements[element_indexes[0]],
element_indexes,
1,
element_to_update,
content_to_update,
content_index)
}))
}
function findElementToUpdate(
element: Element,
element_indexes: number[],
index_level: number,
element_to_update?: Element,
content_to_update?: Content,
content_index?: number
) {
const has_next_index = element_indexes.length !== index_level

if (has_next_index) {
const next_index = element_indexes[index_level]

return findElementToUpdate(
element.elements[next_index],
element_indexes,
index_level + 1,
element_to_update,
content_to_update)
}

if (content_to_update) {
element.content[content_index] = {
...element.content[content_index],
...content_to_update
}
}

if (element_to_update) {
element = {
...element,
...element_to_update
}
}
}

export function setPageStoreElement(
element_indexes: number[],
element_to_update?: Element,
content_to_update?: Content,
content_index?: number
) {
setPageStore(produce((pageStore) => {
findElementToUpdate(
pageStore.page.elements[element_indexes[0]],
element_indexes,
1,
element_to_update,
content_to_update,
content_index)
}))
}
And then to update the content in child elements:
const content_to_update = { html: '<h1>Hello World</h1>' }
setPageStoreElement([4, 2, 8], null, content_to_update, 0)
const content_to_update = { html: '<h1>Hello World</h1>' }
setPageStoreElement([4, 2, 8], null, content_to_update, 0)
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
Thanks for the example! Will play around with it a bit and see if I can get it to work for my case!
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
Thanks for the produce suggestion, I've never heard about that! But I'm unable to find an example of using it with a loop. Do you have an example?
31 replies
SSolidJS
Created by andahendriksen on 9/19/2024 in #support
Push params to url without page scrolling to top
Awesomeness! That's super easy haha thank you so much
4 replies
SSolidJS
Created by andahendriksen on 9/19/2024 in #support
Push params to url without page scrolling to top
I thought it might have been the popup that made the page scroll, but removing the popup still makes the page scroll to the top. I can see though that when the url changes, the page does not run again.
4 replies
SSolidJS
Created by KokoNeot on 6/17/2024 in #support
routing based on subdomain
Did you find a solution? I want to show user profiles on username.domain.com instead of domain.com/username
3 replies
SSolidJS
Created by andahendriksen on 3/18/2024 in #support
Bundle lazy load
No description
8 replies
SSolidJS
Created by andahendriksen on 3/18/2024 in #support
Bundle lazy load
No description
8 replies
SSolidJS
Created by andahendriksen on 3/18/2024 in #support
Bundle lazy load
What do you mean by call them in the /admin load function?
8 replies
DTDrizzle Team
Created by Martin on 2/12/2024 in #help
Anyone able to connect to Digital Ocean managed Postgres with postgres.js using Drizzle?
I would love to know the same! Did you find a solution?
2 replies