https://github.com/andersundsehr/storybook
The one and only Storybook Renderer for TYPO3 Fluid components
https://github.com/andersundsehr/storybook
component components fluid storybook typo3
Last synced: 4 months ago
JSON representation
The one and only Storybook Renderer for TYPO3 Fluid components
- Host: GitHub
- URL: https://github.com/andersundsehr/storybook
- Owner: andersundsehr
- License: gpl-2.0
- Created: 2025-07-07T09:46:36.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-10-20T06:54:25.000Z (8 months ago)
- Last Synced: 2025-10-20T08:59:31.291Z (8 months ago)
- Topics: component, components, fluid, storybook, typo3
- Language: PHP
- Homepage:
- Size: 3.06 MB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `EXT:storybook`





[Getting Started](https://docs.typo3.org/permalink/andersundsehr-storybook:start)
The TYPO3 extension [storybook](https://storybook.js.org/) integrates Storybook into TYPO3 projects.
With the open-source tool Storybook, developers can develop and test UI components in isolation.
It provides an environment where components can be visually displayed and interactively tested.
The extension facilitates the development of TYPO3 frontend components by enabling seamless integration of Storybook into TYPO3.
### Features:
- render [TYPO3 Fluid components](https://docs.typo3.org/permalink/fluid:components) in Storybook
- configure stories inside storybook with the standard [Storybook's CSF format](https://storybook.js.org/docs/api/csf)
- **automatically generates controls** for your components [arguments](https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-argument) and [slots](https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-slot)
- **Interactivity** via [Storybook's Controls](https://storybook.js.org/docs/essentials/controls), allowing you to change component properties in real-time
- shows [Fluid **code snippets**](https://storybook.js.org/docs/writing-docs/code-panel) for each component, allowing you to copy the code directly from Storybook
- wide range of [Storybook's addons](https://storybook.js.org/addons) are available to enhance the development experience, such as accessibility checks, design systems, and more
## Installation: How to install the extension? (Composer, manual, dependencies)
The extension can be installed via Composer:
```bash
composer require andersundsehr/storybook --dev
```
it is recommended to install storybook into your projects package.json file as well:
```bash
# !!! make sure to install the same version as the extension !!!
npm install @andersundsehr/storybook-typo3 --save-dev
# or
yarn add @andersundsehr/storybook-typo3 --dev
```
set framework in your `.storybook/main.ts` file to `@andersundsehr/storybook-typo3` as shown below.
After that you can run storybook with:
```bash
# run in dev mode:
./node_modules/.bin/storybook dev -p 6006
# or build it for production:
./node_modules/.bin/storybook build
# preview the production build:
npx http-server ./storybook-static
```
> Also See [full installation steps](https://docs.typo3.org/permalink/andersundsehr-storybook:installation) in the Getting Started Guide.
## Configuration:
### Inside TYPO3:
To be able to render your own Fluid components in Storybook,
you need to configure your own [ComponentCollection](https://docs.typo3.org/permalink/fluid:components)
and register the global fluid namespace in your `ext_localconf.php` file:
```php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['my'] = Vendor\MyExtension\ComponentCollection::class;
```
### Inside Storybook:
You need your own `.storybook/main.ts` file in your project, which should look like this:
```typescript
import type { StorybookConfig } from '@andersundsehr/storybook-typo3';
const config: StorybookConfig = {
framework: '@andersundsehr/storybook-typo3', // required
stories: [
"../src/**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))",
],
core: {
disableTelemetry: true,
},
env: (envs) => {
return {
STORYBOOK_TYPO3_ENDPOINT: 'http://localhost/_storybook/',
STORYBOOK_TYPO3_WATCH_ONLY_STORIES: '0', // set to '1' If you already use vite in your TYPO3 with HMR
// do not set your api key here! https://www.deployhq.com/blog/protecting-your-api-keys-a-quick-guide
...envs, // envs given to storybook have precedence
};
},
};
export default config;
```
## Usage: How to use the extension? (Examples, screenshots, typical use cases)
With a story file like this:
````typescript
import { type Meta, type StoryObj, fetchComponent } from '@andersundsehr/storybook-typo3';
export default {
component: await fetchComponent('de:card'),
} satisfies Meta;
export const Pirate: StoryObj = {
args: {
title: 'Yar Pirate Ipsum',
text: "Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm. Pinnace holystone mizzenmast quarter crow's nest nipperkin grog yardarm hempen halter furl. Swab barque interloper chantey doubloon starboard grog black jack gangway rutters.",
link: 'https://www.andersundsehr.com',
},
};
````
and a Fluid component like this:
```html
.card {
display: block;
padding: 1rem;
border: 1px solid #ccc;
border-radius: 4px;
text-decoration: none;
color: inherit;
}
.card__title {
font-size: 1.5rem;
margin-bottom: 0.5rem;
}
.card__text {
font-size: 1rem;
margin-bottom: 1rem;
}
.card__moreButton {
display: inline-block;
padding: 0.5rem 1rem;
background-color: #007bff;
color: white;
border-radius: 4px;
text-decoration: none;
}
```
you get a Storybook interface that allows you to interactively test your component, like this:

You can Select the site and the language in the top right corner of the Storybook interface:


## Documentation: Where to find more information? (Links, references, tutorials)
https://docs.typo3.org/permalink/andersundsehr-storybook:start
- docs TODO link to hosted Storybook instance
- docs TODO link to playwright report?
## Development: Notes for developers (e.g., code structure, important classes, extensibility)
The Storybook framework is located in the `the-npm-package` folder inside the extension.
It provides a custom framework for Storybook, which allows you to render TYPO3 Fluid components in Storybook.
It is implemented in TypeScript and is designed to be used with Storybook's Component Story Format (CSF).
The TYPO3 extension `storybook` uses a [Middleware](./Classes/Middleware/StorybookMiddleware.php) to handle requests to the Storybook endpoint.
It has [Actions](./Classes/Action/) to give Storybook the necessary information.
It renders the Fluid components using the corresponding ComponentCollection that must be registered in TYPO3
via `$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']`.
### Development helpers:
the test setup is a nice location to get started with developing the extension.
it also has a [dummy project](./.Build/dummy-project/) that can be used to test the extension in a real TYPO3 environment.
## Tests: How to run tests? Are there test data?
Currently there are only integration tests with [Playwright](./.Build/dummy-project/tests/)
to run the tests you can use the following command:
```bash
cd .Build/
bash test.sh executeAll
```
If you want to make changes to the extension, and than run the tests again you should do this:
```bash
cd .Build/
bash test.sh composerInstall
bash test.sh storybookBuild
bash test.sh watchMode
# in different terminal:
cd .Build/
bash test.sh playwright:ui # (X11 forwarding required)
```
## Troubleshooting: Known issues, troubleshooting, FAQ
## Changelog: Important changes and versions
until now there are no breaking changes, but the extension is still in development.
## License and Authors: License type, contributors, contact information
This extension is licensed under the [GPL-2.0-or-later](https://spdx.org/licenses/GPL-2.0-or-later.html) license.
# with ♥️ from anders und sehr GmbH
> If something did not work 😮
> or you appreciate this Extension 🥰 let us know.
> We are always looking for great people to join our team!
> https://www.andersundsehr.com/karriere/