Coder Social home page Coder Social logo

ben-rogerson / craft-storybook-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from craftcms/craft

52.0 52.0 5.0 990 KB

๐Ÿฃ Everything you need to create a beautiful living style guide with Twig components.

License: The Unlicense

PHP 27.41% Batchfile 1.61% HTML 38.51% JavaScript 17.64% Shell 2.99% SCSS 7.06% Twig 4.77%
boilerplate craft storybook storybook-ui twig

craft-storybook-starter's People

Contributors

angrybrad avatar ben-rogerson avatar benjamindavid avatar brandonkelly avatar carlcs avatar cromwellryan avatar dependabot-preview[bot] avatar geenious avatar jasonmccallister avatar jnowland avatar mildlygeeky avatar mtnorthrop avatar tam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

craft-storybook-starter's Issues

Suggestion - Instructions for implementing in existing projects

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.

Is it possible to create stories of a matrix

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!

Twig 'include' in variable throws "Unable to find template file"

Unable to find template file

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
  • stories/b.stories.js
  • templates/components/a.twig
  • templates/components/b.twig

Works with Storybook but not with Craft

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

Works with Craft but not with Storybook

templates/components/a.twig

A

{% set content %}
{% include "./b.twig" %}
{% endset %}

{{ content }}

Output in Storybook:

Unable to find template file ./b.twig

Workaround with macro

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.