storybookjs / addon-cssresources Goto Github PK
View Code? Open in Web Editor NEWA storybook addon to switch between css resources at runtime for your story
License: MIT License
A storybook addon to switch between css resources at runtime for your story
License: MIT License
Is it possible to have the cssresource
use a class
instead of an id
?
I want to use storybooks to test if className
prop is being passed and properly applied to a component by toggling the style that is being applied via a class css selector.
The code below works, but I find it uncomfortable to use the id
property in this way.
export default {
title: 'React Trix Editor',
component: ReactTrixRTEInput,
parameters: {
cssresources: [
{
id: ".tx-rte-with-border",
code: `<style>.tx-rte-with-border { border: 2px solid blue; }</style>`,
picked: false
}
]
},
decorators: [withCssResources]
};
And, it also looks off (#.<classname>
) when rendered
I was expecting to be able to use something like the following: (note class
instead of id
)
export default {
title: 'React Trix Editor',
component: ReactTrixRTEInput,
parameters: {
cssresources: [
{
class: "tx-rte-with-border",
code: `<style>.tx-rte-with-border { border: 2px solid blue; }</style>`,
picked: false
}
]
},
decorators: [withCssResources]
};
I'm sorry if this is somewhere in the documentation and I missed it, happy to read it if I'm pointed to it.
I get the following error message in the browser console, when checking the checkbox for a css resource:
vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:80555 Warning: A component is changing an uncontrolled input of type checkbox to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components
in input (created by CssResourcePanel)
in label (created by CssResourcePanel)
in div (created by CssResourcePanel)
in div (created by CssResourcePanel)
in CssResourcePanel
in div (created by Context.Consumer)
in Styled(div)
in div (created by Context.Consumer)
in Styled(div)
in Unknown
in Unknown
in Unknown
in Unknown (created by ManagerConsumer)
in ManagerConsumer (created by Panel)
in Panel (created by Layout)
in div (created by Context.Consumer)
in Styled(div) (created by Panel)
in Panel (created by Layout)
in div (created by Context.Consumer)
in Styled(div) (created by Main)
in div (created by Context.Consumer)
in Styled(div) (created by Main)
in Main (created by Layout)
in Layout (created by Context.Consumer)
in WithTheme(Layout)
in Unknown
in div (created by Context.Consumer)
in Styled(div)
in Unknown
in Unknown (created by SizeMeRenderer(Component))
in SizeMeReferenceWrapper (created by SizeMeRenderer(Component))
in SizeMeRenderer(Component) (created by SizeMe(Component))
in SizeMe(Component)
in ThemeProvider
in Unknown (created by ManagerConsumer)
in ManagerConsumer (created by Manager)
in EffectOnMount (created by Manager)
in Manager (created by Context.Consumer)
in Location (created by QueryLocation)
in QueryLocation (created by Root)
in LocationProvider (created by Root)
in HelmetProvider (created by Root)
in Root
printWarning @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:80555
error @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:80527
updateWrapper @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:82337
updateProperties @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:86727
commitUpdate @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:88020
commitWork @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:101013
commitMutationEffects @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:103243
callCallback @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:80655
invokeGuardedCallbackDev @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:80704
invokeGuardedCallback @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:80759
commitRootImpl @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:102976
unstable_runWithPriority @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:112238
runWithPriority$1 @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:91506
commitRoot @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:102848
finishSyncRender @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:102274
performSyncWorkOnRoot @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:102260
(anonymous) @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:91556
unstable_runWithPriority @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:112238
runWithPriority$1 @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:91506
flushSyncCallbackQueueImpl @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:91551
flushSyncCallbackQueue @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:91539
flushPendingDiscreteUpdates @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:102314
flushDiscreteUpdates @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:102294
finishEventHandler @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:81231
batchedEventUpdates @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:81265
dispatchEventForLegacyPluginEventSystem @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:84035
attemptToDispatchEvent @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:84734
dispatchEvent @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:84656
unstable_runWithPriority @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:112238
runWithPriority$1 @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:91506
discreteUpdates$1 @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:102354
discreteUpdates @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:81273
dispatchDiscreteEvent @ vendors-node_modules_storybook_addon-actions_dist_esm_register_js-node_modules_storybook_addo-a589d9.manager.bundle.js:84635
Show 3 more frames
Error should not occur
Please note that screenshots will vanish after 6 months (~19.04.2022)
n/a
I'm using 'CSS Resources' to switch between different (global) CSS files.
This has been set-up in the preview.js
and is working as expected.
There is one issue I can't solve:
The CSS file from the 'CSS Resources' addon is loaded after the story specific CSS.
This results in story specific styling being overwritten by the global CSS.
Example:
cssresources
is loading bootstrap.css
.
Button.stories.js
is loading its own CSS file Button.css
to overwrite specific styles.
Due to the order of the CSS files being loaded in the DOM this isn't working.
Is there a way to control the order of the CSS files? So the story specific CSS always loads after global / cssresources CSS files? Thanks!
Information:
@storybook/react
version 6.2.9
@storybook/addon-cssresources
version 6.2.9
this would be very nice , thanks in advance!
It isn't clear how to add the CSS resources to the entire component. The decorators
on the component, with the same parameters as on per-story basis, results in an empty tab.
It's also unclear how, on the contrary, to make the CSS Resources tab hidden on stories that don't use the decorator.
Opening this issue so we can address the upcoming changes on how addons are built/updated for the upcoming 7.0 release. If anyone is interested in making the changes required and continuing to support and maintain the addon, let us know so that we're aware and help/guide the community moving forward. To help with this process, we've built an abridged guide here, and should any questions or issues, please reach out to us in the prerelease channel in our Discord Server.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.