ben-rogerson / craft-storybook-starter Goto Github PK
View Code? Open in Web Editor NEWThis project forked from craftcms/craft
๐ฃ Everything you need to create a beautiful living style guide with Twig components.
License: The Unlicense
This project forked from craftcms/craft
๐ฃ Everything you need to create a beautiful living style guide with Twig components.
License: The Unlicense
Hey Ben!
This looks absolutely rad. Going to start playing with this later today.
Do you think it would be worthwhile to include instructions on how to integrate this into an existing Craft project, instead of how to spin it up with a new install? I have a few ongoing projects I'd love to drop this into, but I'm a little fuzzy about what files I need and where.
Thanks again for this awesome project.
This repo is a lifesaver, thanks!
I have a template that includes a matrix, which works fine on my site, but I can't figure out how to organize the matrix data for the story.
Here's a dumbed down version of the twig file:
<section>
{% set charactersByDay = castInOrder.charactersByDay.all() %}
{% if charactersByDay|length %}
{% for character in charactersByDay %}
{% if character.characterName is not empty %}
{{character.characterName}}
{% endif %}
{% endfor %}
{% endif %}
</section>
This is the story, which doesn't work. :)
export const withCharacters = () => container(
component({
castInOrder: {
charactersByDay: [{
characterName: 'asdf'
}],
}
})
)
Thanks!
I came across this error while experimenting with your awesome craft/storybook setup. I already found a workaround: I use Twig macro.
Craft uses /templates
as base dir for twig-template-files so I use .
as base path for my twig-files in /templates/**/*.twig
. But I guess webpack does not think like that so we got a problem here...
If you have any further questions, just comment below, thanks in advance!
After git clone
I added the following files:
stories/a.stories.js
// Import: Twig
import component from 'components/a.twig';
// Component name
export default { title: 'Test/A' };
export const Simple = () => {
return component();
};
stories/b.stories.js
// Import: Twig
import component from 'components/b.twig';
// Component name
export default { title: 'Test/B' };
export const Simple = () => {
return component();
};
templates/components/a.twig
A
{% set content %}
{% include "templates/components/b.twig" %}
{% endset %}
{{ content }}
templates/components/b.twig
B
Output in Storybook:
A B
templates/components/a.twig
A
{% set content %}
{% include "./b.twig" %}
{% endset %}
{{ content }}
Output in Storybook:
Unable to find template file ./b.twig
templates/components/a.twig
A
{% import "./b.twig" as b %}
{% set content %}
{{ b.render() }}
{% endset %}
{{ content }}
templates/components/b.twig
{% macro render() %}
B
{% endmacro %}
Output in Storybook:
A B
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.