Skip to content

Commit

Permalink
Merge pull request #28359 from storybookjs/revert-28355-revert-28351-…
Browse files Browse the repository at this point in the history
…transform-docs-latest

Docs: Revert "Docs: Revert "Docs: Update docs structure & format (latest)""
  • Loading branch information
kylegach authored Jun 28, 2024
2 parents 958e86c + e2b9be0 commit 29b9db7
Show file tree
Hide file tree
Showing 3,230 changed files with 67,727 additions and 74,789 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
Binary file added docs/_assets/essentials/addon-themes-example.gif
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 4 additions & 0 deletions docs/_snippets/add-localize-package-to-polyfills.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```ts filename="src/polyfills.ts" renderer="angular" language="ts"
import '@angular/localize/init';
```

94 changes: 94 additions & 0 deletions docs/_snippets/addon-actions-action-function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
```ts filename="Button.stories.ts" renderer="angular" language="ts"
import type { Meta } from '@storybook/angular';
import { action } from '@storybook/addon-actions';

import Button from './button.component';

const meta: Meta<Button> {
component: Button,
args: {
// 👇 Create an action that appears when the onClick event is fired
onClick: action('on-click'),
},
};

export default meta;
```

```js filename="Button.stories.js" renderer="common" language="js"
import { action } from '@storybook/addon-actions';

import Button from './Button';

export default {
component: Button,
args: {
// 👇 Create an action that appears when the onClick event is fired
onClick: action('on-click'),
},
};
```

```ts filename="Button.stories.ts" renderer="common" language="ts-4-9"
// Replace your-framework with the name of your framework
import type { Meta } from '@storybook/your-framework';
import { action } from '@storybook/addon-actions';

import Button from './Button';

const meta {
component: Button,
args: {
// 👇 Create an action that appears when the onClick event is fired
onClick: action('on-click'),
},
} satisfies Meta<typeof Button>;

export default meta;
```

```ts filename="Button.stories.ts" renderer="common" language="ts"
// Replace your-framework with the name of your framework
import type { Meta } from '@storybook/your-framework';
import { action } from '@storybook/addon-actions';

import Button from './Button';

const meta: Meta<typeof Button> {
component: Button,
args: {
// 👇 Create an action that appears when the onClick event is fired
onClick: action('on-click'),
},
};

export default meta;
```

```ts filename="Button.stories.js" renderer="web-components" language="js"
import { action } from '@storybook/addon-actions';

export default {
component: 'demo-button',
args: {
// 👇 Create an action that appears when the onClick event is fired
onClick: action('on-click'),
},
};
```

```ts filename="Button.stories.ts" renderer="web-components" language="ts"
import type { Meta } from '@storybook/angular';
import { action } from '@storybook/addon-actions';

const meta: Meta {
component: 'demo-button',
args: {
// 👇 Create an action that appears when the onClick event is fired
onClick: action('on-click'),
},
};

export default meta;
```

41 changes: 41 additions & 0 deletions docs/_snippets/addon-consume-and-update-globaltype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
```js filename="your-addon-register-file.js" renderer="common" language="js"
import React, { useCallback } from 'react';

import { FORCE_RE_RENDER } from '@storybook/core-events';
import { useGlobals } from '@storybook/manager-api';

import { IconButton } from '@storybook/components';
import { OutlineIcon } from '@storybook/icons';

import { addons } from '@storybook/preview-api';

const ExampleToolbar = () => {
const [globals, updateGlobals] = useGlobals();

const isActive = globals['my-param-key'] || false;

// Function that will update the global value and trigger a UI refresh.
const refreshAndUpdateGlobal = () => {
// Updates Storybook global value
updateGlobals({
['my-param-key']: !isActive,
}),
// Invokes Storybook's addon API method (with the FORCE_RE_RENDER) event to trigger a UI refresh
addons.getChannel().emit(FORCE_RE_RENDER);
};

const toggleOutline = useCallback(() => refreshAndUpdateGlobal(), [isActive]);

return (
<IconButton
key="Example"
active={isActive}
title="Show a Storybook toolbar"
onClick={toggleOutline}
>
<OutlineIcon />
</IconButton>
);
};
```

41 changes: 41 additions & 0 deletions docs/_snippets/addon-consume-globaltype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
```js filename="your-addon-register-file.js" renderer="common" language="js"
import React from 'react';

import { useGlobals } from '@storybook/manager-api';

import { AddonPanel, Placeholder, Separator, Source, Spaced, Title } from '@storybook/components';

import { MyThemes } from '../my-theme-folder/my-theme-file';

// Function to obtain the intended theme
const getTheme = (themeName) => {
return MyThemes[themeName];
};

const ThemePanel = (props) => {
const [{ theme: themeName }] = useGlobals();

const selectedTheme = getTheme(themeName);

return (
<AddonPanel {...props}>
{selectedTheme ? (
<Spaced row={3} outer={1}>
<Title>{selectedTheme.name}</Title>
<p>The full theme object</p>
<Source
code={JSON.stringify(selectedTheme, null, 2)}
language="js"
copyable
padded
showLineNumbers
/>
</Spaced>
) : (
<Placeholder>No theme selected</Placeholder>
)}
</AddonPanel>
);
};
```

Loading

0 comments on commit 29b9db7

Please sign in to comment.