-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added TailwindCSS-based scaffold to the create:theme command
- Loading branch information
1 parent
20ac7f6
commit 3862bf2
Showing
34 changed files
with
293 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# {{code}} Winter CMS Theme | ||
|
||
This theme uses [Winter Mix](https://wintercms.com/docs/console/asset-compilation) for asset compilation. It also uses [Tailwind CSS](https://tailwindcss.com/). | ||
|
||
## Getting Started | ||
|
||
1. Run [`artisan mix:install`](https://wintercms.com/docs/console/asset-compilation#mix-install) and agree when asked to modify the `package.json` file for your project in order to register & install this theme's dependencies. | ||
2. Run [`artisan mix:compile -p theme-{{code}} --production`](https://wintercms.com/docs/console/asset-compilation#mix-compile) to compile the asset files for this theme. | ||
3. Optionally, run [`artisan mix:watch theme-{{code}}`](https://wintercms.com/docs/console/asset-compilation#mix-watch) while actively working on the theme to have the assets automatically recompiled in the background for you every time you make a change. |
3 changes: 3 additions & 0 deletions
3
modules/cms/console/scaffold/theme/tailwind/assets/src/css/base.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
3 changes: 3 additions & 0 deletions
3
modules/cms/console/scaffold/theme/tailwind/assets/src/css/custom.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** | ||
* Custom CSS for theme goes here | ||
*/ |
2 changes: 2 additions & 0 deletions
2
modules/cms/console/scaffold/theme/tailwind/assets/src/css/theme.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import 'base.css'; | ||
@import 'custom.css'; |
33 changes: 33 additions & 0 deletions
33
modules/cms/console/scaffold/theme/tailwind/assets/src/js/theme.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Application | ||
*/ | ||
(function($) { | ||
"use strict"; | ||
|
||
jQuery(document).ready(function($) { | ||
/*------------------------------- | ||
WINTER CMS FLASH MESSAGE HANDLING | ||
---------------------------------*/ | ||
$(document).on('ajaxSetup', function(event, context) { | ||
// Enable AJAX handling of Flash messages on all AJAX requests | ||
context.options.flash = true; | ||
|
||
// Enable the StripeLoadIndicator on all AJAX requests | ||
context.options.loading = $.oc.stripeLoadIndicator; | ||
|
||
// Handle Flash Messages | ||
context.options.handleFlashMessage = function(message, type) { | ||
$.oc.flashMsg({ text: message, class: type }); | ||
}; | ||
|
||
// Handle Error Messages | ||
context.options.handleErrorMessage = function(message) { | ||
$.oc.flashMsg({ text: message, class: 'error' }); | ||
}; | ||
}); | ||
}); | ||
}(jQuery)); | ||
|
||
if (typeof(gtag) !== 'function') { | ||
gtag = function() { console.log('GoogleAnalytics not present.'); } | ||
} |
9 changes: 9 additions & 0 deletions
9
modules/cms/console/scaffold/theme/tailwind/lang/en/lang.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
return [ | ||
'options' => [ | ||
'googleanalytics_id' => 'Google Analytics ID', | ||
'color_primary' => 'Primary Color', | ||
'color_secondary' => 'secondary Color', | ||
], | ||
]; |
8 changes: 8 additions & 0 deletions
8
modules/cms/console/scaffold/theme/tailwind/layouts/default.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
description = "Default layout" | ||
default = true | ||
== | ||
{% partial "site/header" %} | ||
|
||
{% page %} | ||
|
||
{% partial "site/footer" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "{{code}}", | ||
"private": true, | ||
"version": "1.0.0", | ||
"devDependencies": { | ||
"postcss": "~8.4.x", | ||
"postcss-import": "~14.1.x", | ||
"tailwindcss": "~3.0.x" | ||
}, | ||
"dependencies": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
title = "Page not found (404)" | ||
url = "/404" | ||
layout = "default" | ||
== | ||
<div> | ||
<h1>Page not found</h1> | ||
<p>We're sorry, but the page you requested cannot be found.</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
title = "Error page (500)" | ||
url = "/error" | ||
layout = "default" | ||
== | ||
<div> | ||
<h1>Error</h1> | ||
<p>We're sorry, but something went wrong and the page cannot be displayed.</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
title = "Home" | ||
url = "/" | ||
layout = "default" | ||
== | ||
<div class="container mx-auto"> | ||
<h1><span class="text-primary">Home</span> <span class="text-secondary">Page</span></h1> | ||
</div> |
11 changes: 11 additions & 0 deletions
11
modules/cms/console/scaffold/theme/tailwind/partials/meta/seo.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% if this.theme.googleanalytics_id is not empty %} | ||
<!-- Global site tag (gtag.js) - Google Analytics --> | ||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ this.theme.googleanalytics_id }}"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
|
||
gtag('config', '{{ this.theme.googleanalytics_id }}'); | ||
</script> | ||
{% endif %} |
26 changes: 26 additions & 0 deletions
26
modules/cms/console/scaffold/theme/tailwind/partials/meta/styles.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
== | ||
<?php | ||
use Cms\Classes\Asset; | ||
use Cms\Classes\Theme; | ||
function onStart() { | ||
// Cache bust the main styles file | ||
$styles = (new Asset(Theme::getActiveTheme()))->find('dist/css/theme.css'); | ||
if ($styles) { | ||
$this['lastmodified'] = $styles->mtime; | ||
} else { | ||
throw new \Exception("Asset files were not detected, try running artisan mix:install && artisan mix:compile -p theme-{{code}}"); | ||
} | ||
} | ||
?> | ||
== | ||
<link rel="stylesheet" href="{{ 'assets/dist/css/theme.css' | theme }}?v={{ lastmodified }}"> | ||
|
||
<style> | ||
:root { | ||
--primary: {{ this.theme.color_primary }}; | ||
--secondary: {{ this.theme.color_secondary }}; | ||
} | ||
</style> | ||
|
||
{% styles %} | ||
{% placeholder head %} |
21 changes: 21 additions & 0 deletions
21
modules/cms/console/scaffold/theme/tailwind/partials/site/footer.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- Scripts --> | ||
|
||
{# jQuery AJAX Framework #} | ||
<script src="{{ [ | ||
'@jquery', | ||
'@framework', | ||
'@framework.extras', | ||
] | theme }}"></script> | ||
|
||
{# Mix extracted assets #} | ||
<script src="{{ 'assets/dist/js/theme.js' | theme }}"></script> | ||
|
||
{% scripts %} | ||
|
||
{% flash %} | ||
<p data-control="flash-message" data-interval="7" class="flashmessage {{ type }}"> | ||
{{ message }} | ||
</p> | ||
{% endflash %} | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
modules/cms/console/scaffold/theme/tailwind/partials/site/header.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>{% placeholder page_title default %}{{ this.page.title }}{% endplaceholder %}</title> | ||
{% partial "meta/styles" %} | ||
{% partial "meta/seo" %} | ||
<meta name="generator" content="Winter CMS"> | ||
</head> | ||
{% set pageId = this.page.id %} | ||
{% set pageTitle = this.page.title %} | ||
{% if pageId is empty %} | ||
{% set pageId = page.id %} | ||
{% endif %} | ||
{% if pageTitle is empty %} | ||
{% set pageTitle = page.title %} | ||
{% endif %} | ||
<body class="page-{{ pageId }} layout-{{ this.layout.id }}"> |
17 changes: 17 additions & 0 deletions
17
modules/cms/console/scaffold/theme/tailwind/tailwind.config.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
content: [ | ||
'./theme.yaml', | ||
'./**/*.htm', | ||
'./assets/src/js/**/*.{js,vue}' | ||
], | ||
theme: { | ||
extend: { | ||
colors: { | ||
primary: 'var(--primary)', | ||
secondary: 'var(--secondary)', | ||
}, | ||
}, | ||
}, | ||
plugins: [ | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "{{code}}" | ||
description: "No description provided yet..." | ||
author: "Winter CMS Scaffold" | ||
homepage: "https://example.com" | ||
code: "{{code}}" | ||
form: | ||
fields: | ||
googleanalytics_id: | ||
label: themes.{{code}}::lang.options.googleanalytics_id | ||
type: text | ||
span: full | ||
color_primary: | ||
label: themes.{{code}}::lang.options.color_primary | ||
type: colorpicker | ||
span: left | ||
default: "#103141" | ||
color_secondary: | ||
label: themes.{{code}}::lang.options.color_secondary | ||
type: colorpicker | ||
span: right | ||
default: "#2DA7C7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0: 'Initial version' |
15 changes: 15 additions & 0 deletions
15
modules/cms/console/scaffold/theme/tailwind/winter.mix.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const mix = require('laravel-mix'); | ||
|
||
mix | ||
.setPublicPath(__dirname) | ||
|
||
// Render Tailwind style | ||
.postCss('assets/src/css/theme.css', 'assets/dist/css/theme.css', [ | ||
require('postcss-import'), | ||
require('tailwindcss'), | ||
require('tailwindcss/nesting'), | ||
require('autoprefixer'), | ||
]) | ||
|
||
// Compile JS | ||
.js('assets/src/js/theme.js', 'assets/dist/js/theme.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters