Giter VIP home page Giter VIP logo

Comments (10)

cblavier avatar cblavier commented on May 14, 2024 1

Hey @glennr 👋 I'd love to have your opinion on this:

https://github.com/phenixdigital/phx_live_storybook/blob/17-css-conflicts-in-variations-020/guides/sandboxing.md

from phoenix_storybook.

cblavier avatar cblavier commented on May 14, 2024 1

But our preflighted font class remains overridden

Unfortunately, I think that when providing your components styles to the storybook, you'll have to apply some styles on .lsb-sandbox yourself. There is no way your component can inherit styles from the HTML or body elements.

I will make the documentation more explicit.

I took a crack at the iframe option, but its falling over on the Story :ids?

Sorry about that, it's a bug!
Playground inits its attributes from your first story in the entry file. It looks like your first story is a StoryGroup, I will handle that and write a proper test.

from phoenix_storybook.

cblavier avatar cblavier commented on May 14, 2024

Hi Glenn, It seems to be a bug indeed!

I'm using a prefixed version of Tailwind (with the lsb- prefix) to prevent a CSS clash between the storybook and app's components, but I didn't realize that it wouldn't work with preflight styling (in both ways).

I think I will have to explore the iframe way, thanks for the insight.

For now (as the code base is still early and evolving fast), the best help you can provide me with is thorough and detailed feedback! Please go on :)

from phoenix_storybook.

cblavier avatar cblavier commented on May 14, 2024

I'm starting a new branch today, experimenting with iframes.
I'll keep you posted!

from phoenix_storybook.

glennr avatar glennr commented on May 14, 2024

Hi @cblavier

I like the iframe escape hatch. I couldn't get it working on your branch though?

Regarding this statement in your branch:

So unless your components use lsb- prefixed classes there should be no styling leak from the storybook to your components.

Yes and no. If, like me, your components also rely on styling from Tailwind preflights, then you're gonna have problems. Am I missing something?

I'm not sure how to work around problem #2 here. I glanced at the TW docs to see if there was an alternative way to configure my component fonts such that my Tailwind preflight config wouldn't conflict with phx_live_storybook's (or vice versa). No obvious solution yet.

from phoenix_storybook.

glennr avatar glennr commented on May 14, 2024

(Btw the %StoryGroup{} you added post 0.2.0 cleans things up really nicely)

from phoenix_storybook.

cblavier avatar cblavier commented on May 14, 2024

I like the iframe escape hatch. I couldn't get it working on your branch though?

It is available on my branch now: stories rendering is almost fine, but the playground iframe rendering is not fully working yet.
To enable it, add def container, do: :iframe to your component entry file.

Yes and no. If, like me, your components also rely on styling from Tailwind preflights, then you're gonna have problems. Am I missing something?

I'm using a custom Tailwind preflight, that will only preflight elements with lsb class. Since all elements in the storybook (from body to the smallest span have the lsb class) they should be quite protected because this preflight has a higher specificity.

from phoenix_storybook.

glennr avatar glennr commented on May 14, 2024

I grabbed c4600a5

I see your sandboxing (.lsb-sandbox) starting to improve things:

image

But our preflighted font class remains overridden

image

I took a crack at the iframe option, but its falling over on the Story :ids?

image

Stacktrace:

Request: GET /storybook/iframe/components/button?story_id=colors                                                                             
** (exit) an exception was raised:                                                                                                           
    ** (RuntimeError) unknown story :colors for module BrmblWeb.Storybook.Components.Button                                                  
        (brmbl 0.1.0) lib/brmbl_web/storybook.ex:3: BrmblWeb.Storybook.render_story/2                                                        
        (phx_live_storybook 0.3.0) lib/phx_live_storybook/live/entry/component_iframe_live.ex:53: anonymous fn/2 in PhxLiveStorybook.Componen
tIframeLive.render/1                                                                                                                         
        (phoenix_live_view 0.17.11) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7                                      
<SNIP>
[error] #PID<0.3198.0> running BrmblWeb.Endpoint (connection #PID<0.3171.0>, stream id 2) terminated

from phoenix_storybook.

glennr avatar glennr commented on May 14, 2024

but the playground iframe rendering is not fully working yet

oops - missed that :-)

from phoenix_storybook.

glennr avatar glennr commented on May 14, 2024

@cblavier I think the key step was the utilities layer for .lsb-sandbox which I missed in my custom.css:

// Existing config
@layer base {
  @font-face {
    font-family: 'Biryani';
    ...

// Live Storybook
@layer utilities {
  /* this style will be generated as .lsb-sandbox * { ... } */
  * {
    font-family: 'Nunito Sans';
  }
}

from phoenix_storybook.

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.