Giter Club home page Giter Club logo

Comments (8)

jurb avatar jurb commented on May 18, 2024 1

Cool! Possibly related: if I console.log($width) in the chart components, I get 2 results, with the first number being a lot smaller than my container.

from layercake.

mhkeller avatar mhkeller commented on May 18, 2024 1

This is now in 3.0.0 https://github.com/mhkeller/layercake/releases/tag/v3.0.0

from layercake.

mhkeller avatar mhkeller commented on May 18, 2024

Ya I think having it either 1) only load things once the pages load or 2) load everything with per-determined dimensions is the way to go. It's related to this comment here about server-side rendering and the flash of unsized content not being ideal: #5 (comment)

I'll look into the best way to do this. It could be that it just looks for the window object. The trick will just be to make sure that it fails gracefully on first load and doesn't error.

from layercake.

mhkeller avatar mhkeller commented on May 18, 2024

I did some work on this and I think the best solution is to add a prop like ssr that defaults to false that turns off all server-side rendering by adding this conditional which is now in the ssr branch:

{#if (ssr === true || typeof window !== 'undefined')}
<div
class="layercake-container"
bind:clientWidth={containerWidth}
bind:clientHeight={containerHeight}
>
<slot></slot>
</div>
{/if}

it won't attempt to render any of the elements, which is nice because you won't have to put a bunch of conditional statements in each renderer to check to make sure variables have been calculated.

I've started building out server-side rendered examples on the ssr branch of the website repo and I did an export of the current site with the ssr branch so you can see how it works.

This would also close #5

from layercake.

mhkeller avatar mhkeller commented on May 18, 2024

@jurb Can you put an example together in the REPL of the charts you say aren't sizing properly?

from layercake.

jurb avatar jurb commented on May 18, 2024

@mhkeller Yes, I'll try to do so.

from layercake.

mhkeller avatar mhkeller commented on May 18, 2024

I'll merge this into master when I'm done building out the ssr examples to make sure that it works with all use cases built so far.

from layercake.

jurb avatar jurb commented on May 18, 2024

@jurb Can you put an example together in the REPL of the charts you say aren't sizing properly?

I'm sorry but I worked on a tight deadline for that project and can't manage to reconstruct the issue in the upcoming time. Once I have time I'll let you know.

Thanks for the great work!

from layercake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.