generated from silverstripe/silverstripe-module
-
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 e5f3a55
Showing
17 changed files
with
348 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,20 @@ | ||
# For more information about the properties used in this file, | ||
# please see the EditorConfig documentation: | ||
# https://editorconfig.org/ | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,js,json,css,scss}] | ||
indent_size = 2 | ||
|
||
[composer.json] | ||
indent_size = 4 |
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,5 @@ | ||
/tests export-ignore | ||
/client/src export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.github export-ignore |
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 @@ | ||
# CI | ||
|
||
The `ci.yml` file uses [`silverstripe/gha-ci`](https://github.com/silverstripe/gha-ci/) which does its best to identify which types of tests need to be run for your project, against which version of `silverstripe/installer`, with which PHP versions. | ||
|
||
If you find it isn't quite getting it right, there are configuration options available for you to define exactly what jobs you want to be run. See the readme of the gha-ci repository for more information. | ||
|
||
It is recommended that you make this run on a cron, referred to in GitHub Actions as a "schedule". See [the GitHub Actions documentation](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule) for details. | ||
|
||
Make sure to remove this readme in your actual module! |
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 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci: | ||
name: CI | ||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 |
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 @@ | ||
node_modules/ | ||
/vendor/ | ||
.DS_Store | ||
composer.lock | ||
*.js.map | ||
*.css.map | ||
yarn-error.log |
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 @@ | ||
# Contributing | ||
|
||
- Maintenance on this module is a shared effort of those who use it | ||
- To contribute improvements to the code, ensure you raise a pull request and discuss with the module maintainers | ||
- Please follow the Silverstripe CMS [code contribution guidelines](https://docs.silverstripe.org/en/contributing/code/) and [Module Standard](https://docs.silverstripe.org/en/developer_guides/extending/modules/#module-standard) | ||
- Supply documentation that follows the [GitHub Flavored Markdown](https://help.github.com/articles/markdown-basics/) conventions | ||
- When having discussions about this module in issues or pull request please adhere to the [Silverstripe CMS Community Code of Conduct](https://docs.silverstripe.org/en/project_governance/code_of_conduct/) | ||
|
||
## Contributor license agreement | ||
|
||
By supplying code to this module in patches, tickets and pull requests, you agree to assign copyright | ||
of that code to MODULE_COPYRIGHT_HOLDER_HERE., on the condition that these code changes are released under the | ||
same BSD license as the original module. We ask for this so that the ownership in the license is clear | ||
and unambiguous. By releasing this code under a permissive license such as BSD, this copyright assignment | ||
won't prevent you from using the code in any way you see fit. |
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 @@ | ||
Copyright (c) Dynamic, Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,61 @@ | ||
# Silverstripe Elemental Card | ||
|
||
A simple Bootstrap-style Card for Silverstripe Elemental. Intended for use with Elemental Grid. | ||
|
||
![CI](https://github.com/dynamic/silverstripe-elemental-card/workflows/CI/badge.svg) | ||
[![codecov](https://codecov.io/gh/dynamic/silverstripe-elemental-card/branch/master/graph/badge.svg)](https://codecov.io/gh/dynamic/silverstripe-elemental-card) | ||
|
||
[![Latest Stable Version](https://poser.pugx.org/dynamic/silverstripe-elemental-card/v/stable)](https://packagist.org/packages/dynamic/silverstripe-elemental-card) | ||
[![Total Downloads](https://poser.pugx.org/dynamic/silverstripe-elemental-card/downloads)](https://packagist.org/packages/dynamic/silverstripe-elemental-card) | ||
[![Latest Unstable Version](https://poser.pugx.org/dynamic/silverstripe-elemental-card/v/unstable)](https://packagist.org/packages/dynamic/silverstripe-elemental-card) | ||
[![License](https://poser.pugx.org/dynamic/silverstripe-elemental-card/license)](https://packagist.org/packages/dynamic/silverstripe-elemental-card) | ||
|
||
## Requirements | ||
|
||
* dnadesign/silverstripe-elemental: ^5.0 | ||
* silverstripe/linkfield: ^3 | ||
|
||
## Installation | ||
|
||
`composer require dynamic/silverstripe-elemental-card` | ||
|
||
## License | ||
|
||
See [License](LICENSE.md) | ||
|
||
## Usage | ||
|
||
A simple Bootstrap-style Card for Silverstripe Elemental. Intended for use with Elemental Grid. | ||
|
||
### Template Notes | ||
|
||
The default templates are based off [Bootstrap 5](https://getbootstrap.com/) card component. | ||
|
||
## Getting more elements | ||
|
||
See [Elemental modules by Dynamic](https://github.com/orgs/dynamic/repositories?q=elemental&type=all&language=&sort=) | ||
|
||
## Configuration | ||
|
||
See [SilverStripe Elemental Configuration](https://github.com/silverstripe/silverstripe-elemental#configuration) | ||
|
||
## Maintainers | ||
|
||
* [Dynamic](https://www.dynamicagency.com) (<[email protected]>) | ||
|
||
## Bugtracker | ||
Bugs are tracked in the issues section of this repository. Before submitting an issue please read over | ||
existing issues to ensure yours is unique. | ||
|
||
If the issue does look like a new bug: | ||
|
||
- Create a new issue | ||
- Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots | ||
and screencasts can help here. | ||
- Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, | ||
Operating System, any installed SilverStripe modules. | ||
|
||
Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker. | ||
|
||
## Development and contribution | ||
If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers. |
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,4 @@ | ||
<?php | ||
|
||
// You need this file if you don't have anything in the _config folder. If that folder exists | ||
// and is not empty then you can delete this file. |
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 @@ | ||
# see https://docs.silverstripe.org/en/developer_guides/configuration/configuration/ |
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": "dynamic/silverstripe-elemental-card", | ||
"description": "A simple Bootstrap-style Card for Silverstripe Elemental. Intended for use with Elemental Grid.", | ||
"license": "BSD-3-Clause", | ||
"type": "silverstripe-vendormodule", | ||
"keywords": [ | ||
"silverstripe", | ||
"CMS" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Dynamic", | ||
"email": "[email protected]", | ||
"homepage": "https://www.dynamicagency.com" | ||
} | ||
], | ||
"require": { | ||
"dnadesign/silverstripe-elemental": "^5", | ||
"silverstripe/linkfield": "^3.0", | ||
"silverstripe/recipe-cms": "^5.0" | ||
}, | ||
"require-dev": { | ||
"silverstripe/recipe-testing": "^3" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"Dynamic\\Elements\\Card\\": "src/", | ||
"Dynamic\\Elements\\Card\\Tests\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"composer/installers": true, | ||
"silverstripe/recipe-plugin": true, | ||
"silverstripe/vendor-plugin": true | ||
}, | ||
"process-timeout": 600 | ||
} | ||
} |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="Silverstripe"> | ||
<description>CodeSniffer ruleset for Silverstripe coding conventions.</description> | ||
|
||
<file>src</file> | ||
<file>tests</file> | ||
|
||
<!-- base rules are PSR-12 --> | ||
<rule ref="PSR12" > | ||
<!-- You may need to use this exclusion if you override some core methods --> | ||
<!--<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />--> | ||
</rule> | ||
</ruleset> |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Default"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,105 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\Card\Elements; | ||
|
||
use SilverStripe\Forms\HTMLEditor\HtmlEditorField; | ||
use SilverStripe\Assets\Image; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\LinkField\ORM\DBLink; | ||
use SilverStripe\ORM\FieldType\DBField; | ||
use DNADesign\Elemental\Models\BaseElement; | ||
|
||
/** | ||
* Class \LakeshoreProductions\Element\Card | ||
* | ||
* @property bool $Animate | ||
* @property string $Animation | ||
* @property string $Duration | ||
* @property string $Delay | ||
* @property string $Easing | ||
* @property string $CardLink | ||
* @property int $CardImageID | ||
* @method Image CardImage() | ||
* @mixin AOSExtension | ||
*/ | ||
class ElementCard extends BaseElement | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private static string $table_name = 'ElementCard'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static string $singular_name = 'Card'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static string $plural_name = 'Cards'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static string $description = 'A card element'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static string $icon = 'font-icon-block-content'; | ||
|
||
/** | ||
* @var array|string[] | ||
*/ | ||
private static array $db = [ | ||
'Content' => 'HTMLText', | ||
'ElementLink' => DBLink::class, | ||
]; | ||
|
||
/** | ||
* @var array|string[] | ||
*/ | ||
private static array $has_one = [ | ||
'Image' => Image::class, | ||
]; | ||
|
||
/** | ||
* @var array|string[] | ||
*/ | ||
private static array $owns = [ | ||
'Image', | ||
]; | ||
|
||
/** | ||
* @return FieldList | ||
*/ | ||
public function getCMSFields(): FieldList | ||
{ | ||
$this->beforeUpdateCMSFields(function (FieldList $fields) { | ||
$fields->dataFieldByName('Image') | ||
->setFolderName('Uploads/Elements/Card'); | ||
|
||
$fields->insertBefore('Content', $fields->dataFieldByName('Image')); | ||
$fields->insertBefore('Content', $fields->dataFieldByName('ElementLink')); | ||
}); | ||
|
||
return parent::getCMSFields(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSummary(): string | ||
{ | ||
return DBField::create_field('HTMLText', $this->HTML)->Summary(20); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType(): string | ||
{ | ||
return _t(__CLASS__ . '.BlockType', 'Card'); | ||
} | ||
} |
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,14 @@ | ||
<div class="element__card"> | ||
<div class="card h-100"> | ||
<% if $Image %> | ||
<% if $ElementLink %><a href="$ElementLink.LinkURL" title="Go to $ElementLink.Title.ATT"><% end_if %> | ||
<img src="$Image.FocusFill(500,330).URL" class="card-img-top" alt="$Image.Title.ATT"> | ||
<% if $ElementLink %></a><% end_if %> | ||
<% end_if %> | ||
<div class="card-body"> | ||
<% if $Title && $ShowTitle %><$TitleTag class="element__title $TitleSizeClass">$Title</$TitleTag><% end_if %> | ||
<% if $Content %><div class="card-text">$Content</div><% end_if %> | ||
<% if $ElementLink %><p>$ElementLink</p><% end_if %> | ||
</div> | ||
</div> | ||
</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,19 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\Card\Elements\Test; | ||
|
||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Dev\SapphireTest; | ||
use Dynamic\Elements\Card\Elements\ElementCard; | ||
|
||
class ElementCardTest extends SapphireTest | ||
{ | ||
protected static $fixture_file = 'card.yml'; | ||
|
||
public function testGetCMSFields() | ||
{ | ||
$object = $this->objFromFixture(ElementCard::class, 'one'); | ||
$fields = $object->getCMSFields(); | ||
$this->assertInstanceOf(FieldList::class, $fields); | ||
} | ||
} |
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 @@ | ||
Dynamic\Elements\Card\Elements\ElementCard: | ||
one: | ||
Title: "Card Block" |