Skip to content

Commit

Permalink
fix(storybook): loads with page reload upon change
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioBecerra committed Dec 14, 2023
1 parent 4e2cfb9 commit 6d5d656
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const container = ({
<cds-skip-to-content href="#main-content"></cds-skip-to-content>
<div
id="main-content"
style="background: red;"
name="main-content"
data-floating-menu-container
role="${hasMainTag ? 'none' : 'main'}">
Expand Down
19 changes: 5 additions & 14 deletions web-components/packages/carbon-web-components/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@ import type { StorybookConfig } from '@storybook/web-components-vite';
import { mergeConfig } from 'vite';
import { litStyleLoader, litTemplateLoader } from '@mordech/vite-lit-loader';

import { join, dirname } from 'path';

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')));
}
const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
'@storybook/addon-links',
'@storybook/addon-essentials',
],
framework: {
name: getAbsolutePath('@storybook/web-components-vite'),
name: '@storybook/web-components-vite',
options: {},
},
async viteFinal(config) {
Expand All @@ -27,7 +18,7 @@ const config: StorybookConfig = {
// Add dependencies to pre-optimization
plugins: [litStyleLoader(), litTemplateLoader()],
optimizeDeps: {
include: ['storybook-dark-mode', '@storybook/web-components'],
include: ['@storybook/web-components'],
exclude: ['lit', 'lit-html']
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Preview, setCustomElementsManifest } from '@storybook/web-components';
import { setCustomElementsManifest } from '@storybook/web-components';
import customElements from '../custom-elements.json';
import container from './container';
import theme from './theme';


setCustomElementsManifest(customElements);

export const preview: Preview = {
parameters: {
controls: { expanded: true },
},
};
// export const Preview = {
// parameters: {
// controls: { expanded: true },
// },
// };

export const decorators = [
function decoratorContainer(story, context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class CDSButton extends HostListenerMixin(FocusMixin(LitElement)) {
</p>
`
: html`
<p>a</p>
<p>sss</p>
<a
id="button"
part="button"
Expand Down

0 comments on commit 6d5d656

Please sign in to comment.