-
Notifications
You must be signed in to change notification settings - Fork 4
Add Storybook support #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When using ui-core as a dependency for a storybook, vite complains about when imports are not on top of the file.
I’m not sure if it’s a good idea to put these into |
On the other hand, it would be nice to merge the change in |
I moved all the storybook stuff into its own directory with separate My code formatter reformatted elm.json but no real changes were made. Should we agree on a common formatting config for the javascript stuff? |
// Automatically creates stories from .elm files | ||
config.plugins.push(StorybookElmPlugin()); | ||
return mergeConfig(config, { | ||
server: { fs: { allow: [".."] } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows vite to load the required fonts. Any further configuration to the build process goes here
{ | ||
"type": "application", | ||
"source-directories": [ | ||
"../src", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allows us to use ui-core without elm-git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that components in elm-storybook
directory are not used. What are those for?
storybook/src/Storybook/Story.elm
Outdated
stateless options = | ||
Browser.element | ||
{ init = \() -> ( (), Cmd.none ) | ||
, update = \msg model -> ( model, Cmd.none ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's nice to keep logAction
here so that actions appear on the storybook UI.
https://github.com/yoching/unison-ui-core-storybook/blob/main/src/Storybook/Story.elm#L18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it again. I needed to add the keyword port
to the module declaration to make it work
storybook/src/Storybook/Story.elm
Outdated
sandbox options = | ||
Browser.element | ||
{ init = \() -> ( options.init, Cmd.none ) | ||
, update = \msg model -> ( options.update msg model, Cmd.none ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being super slow on this. Really awesome work! 🎉
Would it be possible to use webpack instead of vite here? We use webpack everywhere else, and I'm not sure I'm ready to take to time to switch.
}, | ||
"test-dependencies": { | ||
"elm-explorations/test": "1.2.0 <= v < 2.0.0" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we "unformat" this file? Elm manages it and will re-format on the next elm install
I believe, which will add a bit of commit noise
@import "./ui/animations.css"; | ||
@import "./ui/components.css"; | ||
@import "./ui/page-layout.css"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #57
paramKey: "elm-source", | ||
render: ({ active, key }) => { | ||
return (active) | ||
? React.createElement(StoryPanel, { className: "banana", key, api }, null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats "banana"
for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a closer look at what parts of the code are holdovers from the example
} | ||
} | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to run prettier
on the js files.
|
||
col : List (Attribute msg) -> List (Html msg) -> Html msg | ||
col attrs children = | ||
Html.div (Html.Attributes.class "col" :: attrs) children |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is useful enough to be added to either a new UI.Layout
module or just as a function on the UI
module.
It's certainly possible. The example we used as reference uses the vite builder for storybook, see here |
I tried webpack first but didn't find a way to make it work. |
Closing this since we got the webpack version merged. Thank you so much both! |
When using ui-core as a dependency for a storybook, vite does not load the styles unless all import declarations are on top.