Skip to content

Commit

Permalink
Entry type colors and icons, but of course
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Mar 25, 2024
1 parent ef55504 commit bb43544
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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/).

## 2.0.0-beta.3 - 2024-03-25
### Improved
- Adds support for entry type icons and colors in Child Me! entry type disclosure menus

## 2.0.0-beta.2 - 2024-03-25
### Fixed
- Fixes an issue where clicking Child Me! disclosure menu buttons would select the element row
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mmikkel/child-me",
"description": "Easily create child elements",
"type": "craft-plugin",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 4 additions & 0 deletions src/ChildMe.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use craft\events\DefineAttributeHtmlEvent;
use craft\events\RegisterElementTableAttributesEvent;
use craft\events\TemplateEvent;
use craft\helpers\Cp;
use craft\helpers\Html;
use craft\helpers\UrlHelper;
use craft\models\EntryType;
use craft\models\Section;
Expand Down Expand Up @@ -193,6 +195,8 @@ private function _renderChildMeButtonForEntry(Entry $entry): string
'typeId' => $entryType->id,
]),
'label' => $entryType->name,
'icon' => !empty($entryType->icon) ? Cp::iconSvg($entryType->icon) : null,
'color' => !empty($entryType->color) ? $entryType->color : null,
];
}, $entryTypes);

Expand Down
28 changes: 23 additions & 5 deletions src/templates/childme-button.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@
>
<craft-tooltip>{{ 'New child'|t('app') }}</craft-tooltip>
</button>
<div id="childme-menu-{{ element.id }}" class="menu menu--disclosure">
<div id="childme-menu-{{ element.id }}" class="childme-menu menu menu--disclosure">
<ul>
{% for link in links %}
<li>
<a href="{{ link.url }}"
data-icon="plus"
>{{ link.label }}</a>
{% tag 'a' with {
href: link.url,
class: 'flex',
style: link.color|default ? {
'--custom-bg-color': link.color.cssVar(50)|default(false),
'--custom-text-color': link.color.cssVar(900)|default(false),
'--custom-sel-bg-color': link.color.cssVar(100)|default(false)
} : false
} %}
{% if link.icon %}
<span class="cp-icon small{{ link.color is defined ? " #{link.color.value}" }}">{{ link.icon|raw }}</span>
{% endif %}
{{ link.label }}
{% endtag %}
</li>
{% endfor %}
</ul>
Expand All @@ -39,11 +50,18 @@
color: var(--link-color);
background-color: transparent;
height: auto;
padding: 0;
padding: 6px;
}
.childme-button::before {
margin: 0 !important;
}
.childme-menu li a {
background-color: var(--custom-bg-color) !important;
color: var(--custom-text-color, var(--link-color)) !important;
}
.childme-menu li a:hover {
background-color: var(--custom-sel-bg-color, var(--custom-bg-color)) !important;
}
.modal .elements .tableview th[data-attribute="_childme_addChild"],
.modal .elements .tableview td[data-attr="_childme_addChild"] {
display: none !important;
Expand Down

0 comments on commit bb43544

Please sign in to comment.