The Liberty theme is designed to help front-end developers creating custom themes to get up and running quickly with modern front-end technologies.
What makes the Liberty project unique is that it provides a custom command for Drupal Console so that a custom theme can be generated on the command line.
With Drupal Console and Liberty theme installed, you can type drupal generate:libtheme, and Console will ask you for the name of your theme, the machine name for the theme, and the description line for your theme and will then generate all the files needed for the custom theme. That includes default Sass partials, package definitions for npm and Bower, and lint config files. The Liberty theme itself contains the skeleton files used in the theme generation process, as well as custom Command and Generator classes for Drupal Console.
I have worked with the Drupal Console team to provide patches that allow for Command and Generator classes defined within a theme to be registered with Drupal Console. This is a significant advance for theme development, as previously contrib themes provided for subtheme/custom theme generation in the following ways:
- STARTERKIT folder: A theme could contain a folder labeled something like STARTERKIT, which needed to be copied manually to a particular location, with folders, files and functions manually renamed to a new custom theme name. This method works but is time-consuming, and it can be easy to miss renaming something within the theme, leading to errors.
- Drush command: While seemingly similar to what Liberty theme is doing with Drupal Console, most Drush commands for theme generation do essentially the same thing as option one. Drush copies over all the files into a new folder, but then uses grep to search through folder, file names and function names to do find-and-replace with the new theme name. The code for this is difficult to read, and again, potentially could result in errors.
- Yeoman: A common scaffolding tool in front-end development, Yeoman also can be used for theme generation. However, with Yeoman the skeleton files for a generated theme are generally in a github repo, rather than being defined within the theme itself. This requires maintaining code in multiple location, and it also makes it more challenging to review files used for theme generation if you are evaluating a theme.
By providing custom theme generation classes to Drupal Console, the skeleton files can be kept in the same drupal.org repo for the theme. Best of all, rather than doing grep to change values like the theme name, files which have values that need to vary are saved as Twig files, with Twig syntax used for the logic and variable replacement used in the creation of the final file that will be saved in the custom theme. The logic used to name folders and the files itself is handled within the Generator class.
The end result is that after typing a command in the CLI, a front-end developer has a modern setup for a theme. Dependencies are pulled in for task-running and Sass through npm and Bower. A sensible structure is in place for Sass partials, and Sass compiling and other tasks are handled through Grunt.
Future iterations of the theme could allow a front-end developer to choose to use Gulp instead of Grunt as a build tool, or to use Singularity instead of Susy as a grid framework. For now, Liberty theme as is provides a solid starting point for projects and is already in use on some D8 enterprise development projects. Liberty's front-end setup is based on Lullabot's Windup theme, which has been used on numerous front-end development projects. Liberty makes some slightly different setup choices to provide examples for how the theme could provide separate library CSS files while using the same functions, variables and mixins as would be used in global styles.
Liberty project page: https://www.drupal.org/sandbox/mdrummond/2636658
Liberty git clone command: git clone --branch 8.x-1.x https://git.drupal.org/sandbox/mdrummond/2636658.git liberty
Required Drupal version: Drupal 8
Comments
Comment #2
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
tlattimore commentedThanks so much for submitting this, mdrummond.
Couple minor comments thus for
LibertyThemeGenerator.phpLine
14there is an empty docblock.The array declared on lines
56through77have inconsistent indentation from the rest of the file. I think it should be4 spaceswhere there is only 2 (or none)?Minor comments for
LibertyThemeCommand.phpEmpty docblock on line
30Inconsistent indentation with the array defined on line
270through291. I think it should be4 spaceswhere there is only 2 (or none)?Comment #4
benellefimostfa commentedPlease fix your git command to git clone --branch 8.x-1.x https://git.drupal.org/sandbox/mdrummond/2636658.git liberty
Automatic review
http://pareview.sh/pareview/httpgitdrupalorgsandboxmdrummond2636658git
ps: it should be 2 spaces.
Comment #5
rainbowarrayComment #6
rainbowarrayThanks for the feedback, tlattimore and benellefimostfa. I've made corrections based on the suggestions. The remaining automatic review comments don't seem to be applicable. The extra characters per line comments are either content in a Markdown table or URLs that should be okay to go beyond 80 characters. The remainder of the automatic feedback doesn't seem to be applicable, but if I'm missing something, please feel free to clarify.
Comment #7
rainbowarrayComment #8
rainbowarrayComment #9
rainbowarrayComment #10
davidhernandezI started going through this superficially. Didn't see anything yet, but I think we are good to give Marc vetted access regardless. Marc is one of the Drupal 8 core component maintainers, and following this post https://groups.drupal.org/node/449378 the Git admins seem to be good giving all the core maintainers access. They've already been vetted.
Comment #11
jthorson commentedApproving based on evidence through multiple contributions to Drupal Core and status as a Drupal Core component maintainer.
Comment #12
rainbowarrayThanks so much! This has now been promoted to a full project!
Comment #13
almaudoh commentedGreat project!