Comments (10)
Hey @glennr 👋 I'd love to have your opinion on this:
from phoenix_storybook.
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.
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.
I'm starting a new branch today, experimenting with iframes.
I'll keep you posted!
from phoenix_storybook.
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.
(Btw the %StoryGroup{}
you added post 0.2.0 cleans things up really nicely)
from phoenix_storybook.
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.
I grabbed c4600a5
I see your sandboxing (.lsb-sandbox) starting to improve things:
But our preflighted font class remains overridden
I took a crack at the iframe option, but its falling over on the Story :id
s?
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.
but the playground iframe rendering is not fully working yet
oops - missed that :-)
from phoenix_storybook.
@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)
- Fails to run `mix phx.gen.storybook` on phoenix `1.7.3` HOT 4
- Dialyzer is no longer working HOT 1
- Internal assets aren't being found even that they exist HOT 5
- Export formatter rules for `live_storybook/2` HOT 7
- Stories with large attributes fail to load HOT 3
- Hex release not independently compilable HOT 2
- Make CSRF token optional
- Generated stories have `Elixir.` prefix in aliases and for function components
- Compile failure with earmark 1.4.41 HOT 3
- `theme` Attribute does not render in the example code HOT 4
- Cannot get any of my own components to display properly in the stories view HOT 11
- Strange whitebar on chrome/safari since MacOS Sonoma update
- Inter font makes request to external source
- Add `defer` attribute to `<script>` tag HOT 1
- Global Color Change HOT 1
- Prefix event names in StoryLive
- Elixir warning for slice with negative steps
- allow passing additional options to story HOT 1
- Compatibility with Phoenix HTML 4.0.0
- error: undefined function (there is no such import) nofile:1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phoenix_storybook.