-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8e16e5d
Showing
13 changed files
with
4,467 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"pluginName":"Classnames","pluginDescription":"Classnames plugin for Craft CMS","pluginVersion":"1.0.0","pluginAuthorName":"Jeremy Frank","pluginVendorName":"viget","pluginAuthorUrl":"https://www.viget.com/","pluginAuthorGithub":"vigetlabs","codeComments":"","pluginComponents":["twigextensions"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"} |
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,32 @@ | ||
# CRAFT ENVIRONMENT | ||
.env.php | ||
.env.sh | ||
.env | ||
|
||
# COMPOSER | ||
/vendor | ||
|
||
# BUILD FILES | ||
/bower_components/* | ||
/node_modules/* | ||
/build/* | ||
/yarn-error.log | ||
|
||
# MISC FILES | ||
.cache | ||
.DS_Store | ||
.idea | ||
.project | ||
.settings | ||
*.esproj | ||
*.sublime-workspace | ||
*.sublime-project | ||
*.tmproj | ||
*.tmproject | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
config.codekit3 | ||
prepros-6.config |
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 @@ | ||
# Classnames Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## 1.0.0 - 2019-09-16 | ||
### Added | ||
- Initial release |
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 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Viget Labs | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,65 @@ | ||
# Classnames plugin for Craft CMS 3.x | ||
|
||
Classnames is a simple Twig function for conditionally joining css class names together in Twig templates, in a way that makes them much more readable. It's like Jed Watson's [Classnames](https://github.com/JedWatson/classnames) but for Twig in Craft. | ||
|
||
## 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 viget/craft-classnames | ||
|
||
3. Install the plugin via `./craft install/plugin classnames` via the CLI, or in the Control Panel, go to Settings → Plugins and click the “Install” button for Classnames. | ||
|
||
## Using Classnames | ||
|
||
A real world example: | ||
|
||
```twig | ||
<button | ||
class="{{ classNames({ | ||
'group relative z-0 hover:z-1': true, | ||
'px-24 py-12': true, | ||
'font-bold text-14 text-dark-gray': true, | ||
'inline-flex items-center justify-between': props.arrow, | ||
'inline-block': not props.arrow, | ||
'w-full text-center': props.full | ||
}) }}" | ||
> | ||
{{ props.text }} | ||
</button> | ||
``` | ||
|
||
Other examples: | ||
|
||
```twig | ||
{{ classNames('foo', 'bar') }} {# 'foo bar' #} | ||
{{ classNames('foo', { 'bar': true }) }} {# 'foo bar' #} | ||
{{ classNames({ 'foo-bar': true }) }} {# 'foo-bar' #} | ||
{{ classNames({ 'foo-bar': false }) }} {# '' #} | ||
{{ classNames({ 'foo': true }, { 'bar': true }) }} {# 'foo bar' #} | ||
{{ classNames({ 'foo': true, 'bar': true }) }} {# 'foo bar' #} | ||
``` | ||
|
||
There is even a shorthand `cx` version available: | ||
|
||
```twig | ||
{{ cx('foo', { 'bar': true }) }} {# 'foo bar' #} | ||
``` | ||
|
||
*** | ||
|
||
<a href="http://code.viget.com"> | ||
<img src="http://code.viget.com/github-banner.png" alt="Code At Viget"> | ||
</a> | ||
|
||
Visit [code.viget.com](http://code.viget.com) to see more projects from [Viget](https://viget.com). |
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,41 @@ | ||
{ | ||
"name": "viget/craft-classnames", | ||
"description": "Classnames plugin for Craft CMS", | ||
"type": "craft-plugin", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"craft", | ||
"cms", | ||
"craftcms", | ||
"craft-plugin", | ||
"classnames" | ||
], | ||
"support": { | ||
"docs": "https://github.com/vigetlabs/craft-classnames/blob/master/README.md", | ||
"issues": "https://github.com/vigetlabs/craft-classnames/issues" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Jeremy Frank", | ||
"homepage": "https://www.viget.com/" | ||
} | ||
], | ||
"require": { | ||
"craftcms/cms": "^3.0.0-RC1", | ||
"newridetech/php-classnames": "^1.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"viget\\classnames\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"name": "Classnames", | ||
"handle": "classnames", | ||
"hasCpSettings": false, | ||
"hasCpSection": false, | ||
"changelogUrl": "https://raw.githubusercontent.com/vigetlabs/craft-classnames/master/CHANGELOG.md", | ||
"class": "viget\\classnames\\Classnames" | ||
} | ||
} |
Oops, something went wrong.