All Projects → trendyminds → molecule

trendyminds / molecule

Licence: MIT license
⚛️ Grab Twig components, CSS and JS files outside the primary template folder

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to molecule

visor
🕶 A simple admin overlay to get to the relevant areas of the Craft CMS control panel.
Stars: ✭ 25 (+25%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
tablemaker
A user-definable table field type for Craft CMS
Stars: ✭ 39 (+95%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (-10%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
craft3-collections
Clean up those complex templates with Laravel Collections
Stars: ✭ 24 (+20%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
craft-entry-instructions
A simple fieldtype to add instructions.
Stars: ✭ 16 (-20%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
Seo
SEO utilities including a unique field type, sitemap & redirect manager
Stars: ✭ 210 (+950%)
Mutual labels:  craft, craftcms, craft3
Craftcms Docker
Craft3/Craft2 CMS Docker base (Nginx, PHP-FPM 8, PostgreSQL/MariaDB, Redis)
Stars: ✭ 99 (+395%)
Mutual labels:  craft, craftcms, craft3
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (+30%)
Mutual labels:  craft, craftcms, craftcms-plugin
Buttonbox
A collection of utility field types for Craft
Stars: ✭ 94 (+370%)
Mutual labels:  craft, craftcms, craft3
Inlin-Craft
Plugin for inlining files in templates.
Stars: ✭ 64 (+220%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft-react
Client and Server-side React rendering for CraftCMS
Stars: ✭ 40 (+100%)
Mutual labels:  craftcms, craftcms-plugin, craft3
Simplemap
A beautifully simple map field type for Craft CMS.
Stars: ✭ 136 (+580%)
Mutual labels:  craft, craftcms, craft3
Craft Preparse Field
Field type that parses twig when an element is saved.
Stars: ✭ 103 (+415%)
Mutual labels:  craft, craftcms, craft3
craft3-fallback-site
Failing requests in a multi-site install can fall back to other sites, to prevent 404 errors from missing or disabled entries.
Stars: ✭ 14 (-30%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft-json-snippets
Helps make CraftCMS models in .json
Stars: ✭ 17 (-15%)
Mutual labels:  craft, craftcms, craftcms-plugin
padstone
Padstone is a Craft CMS starter kit with a curated configuration, Boilerplate templates, and handpicked plugins.
Stars: ✭ 18 (-10%)
Mutual labels:  craft, craftcms, craft3
craft-entriessubset
Craft field type plugin that extends the core Entries field type to give extra settings
Stars: ✭ 27 (+35%)
Mutual labels:  craft, craftcms, craftcms-plugin
Craft Async Queue
Async Queue Handler for Craft 3
Stars: ✭ 80 (+300%)
Mutual labels:  craft, craftcms, craft3
tags
A tag manager for Craft 3
Stars: ✭ 23 (+15%)
Mutual labels:  craftcms, craftcms-plugin, craft3
overflow.craft-plugin
A plain text Craft field type, with a soft or hard character limit.
Stars: ✭ 13 (-35%)
Mutual labels:  craft, craftcms, craftcms-plugin

Molecule logo Molecule

Your component structure and Craft CMS in harmony

Why Molecule?

Molecule allows you to grab Twig components from outside the template folder. This is useful if you want to keep your Twig partials, CSS, React/Vue files, etc in a single component folder. Now all of your components are nicely organized in individual folder structures!

├── components/
│   ├── ButtonPrimary/
│   │   ├── index.css
│   │   ├── index.jsx
│   │   ├── index.twig
│   │   └── README.md
│   ├── Gallery/
│   ├── Hero/
│   └── VideoEmbed/
└── public/
    ├── cpresources/
    ├── index.php
    └── .htaccess

Example use

Setup your ButtonPrimary/index.twig partial:

<a href="{{url}}"{% if newWindow is defined and newWindow %} target="_blank"{% endif %}>
  {{label}}
</a>

Then include in your Twig templates using the following syntax:

{{craft.molecule.get("ButtonPrimary", {
    url: "https://google.com",
    label: "Visit Google.com",
    newWindow: true
  })
}}

You can even include components in other components!

/components/Hero/index.twig

<div class="Hero">
  <img src="myImage.jpg" alt="A short description">

  {{craft.molecule.get("ButtonPrimary", {
      url: "#",
      label: "Learn more"
    })
  }}
</div>

Icon Components

If you have an Icon/ component there's an additional craft.molecule.icon() helper you can use to output the SVG directly into your templates.

├── components/
│   ├── Icon/
│   │   ├── images/
│   │   │    ├── arrow.svg
│   │   │    ├── play-button.svg
│   │   │    └── twitter.svg
│   │   ├── index.css
│   │   └── index.jsx
│   ├── Gallery/
└── public/
    ├── cpresources/
    ├── index.php
    └── .htaccess
{{craft.molecule.icon("twitter", { class: "custom_class" })}}

will compile to:

<span class="Icon Icon--twitter custom_class">
  <!-- SVG contents of twitter.svg -->
</span>

Testimonials

Matt Rothenberg @mattrothenberg

@aaronbushnell @CraftCMS I went all in 😜.

Feels so nice to be able to "compose" components in a React-y way, too. https://twitter.com/mattrothenberg/status/1094693570177654784/photo/1

AspectRatioBox component from Matt Rothenberg

Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require trendyminds/molecule
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Molecule.

  4. Configure the path to your components directory within Molecule's settings

Credits

Icon by Aaron HumphreysDribbble post

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].