Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions ai_content_strategy.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ content_strategy:
version: VERSION
css:
theme:
css/content-strategy.css: {}
css/components/base.css: {}
css/components/cards.css: {}
css/components/table.css: {}
css/components/checkbox.css: {}
css/components/links.css: {}
css/components/delete.css: {}
css/components/editable.css: {}
css/components/icons.css: {}
js:
js/content-ideas.js: {}
js/content-strategy-utils.js: {}
js/content-strategy-generate.js: {}
js/content-strategy-editable.js: {}
js/content-strategy-delete.js: {}
js/content-strategy-checkbox.js: {}
js/content-strategy-links.js: {}
js/content-strategy-export.js: {}
dependencies:
- core/drupal
- core/jquery
- core/once
- core/drupal.ajax
- core/drupal.message
- core/drupal.message
55 changes: 52 additions & 3 deletions ai_content_strategy.module
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function ai_content_strategy_get_button_texts() {
foreach ($categories as $category) {
$category_id = $category->id();
$button_texts['generate'][$category_id] = t('Generate AI recommendations');
$button_texts['generate_more'][$category_id] = t('Add more AI @type', ['@type' => t('ideas')]);
$button_texts['add_more'][$category_id] = t('Add more AI recommendations');
$button_texts['generate_more'][$category_id] = t('Generate more AI @type', ['@type' => t('ideas')]);
$button_texts['add_more'][$category_id] = t('Generate more AI recommendations');
}
}

Expand All @@ -66,6 +66,48 @@ function ai_content_strategy_theme() {
'button_text' => [],
],
],
'ai_content_strategy_icon' => [
'variables' => [
'name' => NULL,
'class' => NULL,
'size' => NULL,
],
'template' => 'components/icon',
],
'ai_content_strategy_link_display' => [
'variables' => [
'link' => NULL,
'section' => NULL,
'uuid' => NULL,
'idea_uuid' => NULL,
],
'template' => 'components/link-display',
],
'ai_content_strategy_link_add_button' => [
'variables' => [
'section' => NULL,
'uuid' => NULL,
'idea_uuid' => NULL,
],
'template' => 'components/link-add-button',
],
'ai_content_strategy_link_input' => [
'variables' => [
'current_link' => '',
],
'template' => 'components/link-input',
],
'ai_content_strategy_idea_row' => [
'variables' => [
'section' => NULL,
'uuid' => NULL,
'idea_uuid' => NULL,
'idea_text' => NULL,
'idea_implemented' => FALSE,
'idea_link' => '',
],
'template' => 'components/idea-row',
],
];
}

Expand Down Expand Up @@ -102,8 +144,15 @@ function ai_content_strategy_preprocess_ai_content_strategy_recommendations(&$va
}
}

// Add to JavaScript settings.
// Add JavaScript settings (icons now use CSS mask-image).
$variables['#attached']['drupalSettings']['aiContentStrategy'] = [
'buttonText' => $variables['button_text'],
'translations' => [
'addLink' => t('+ Add link'),
'editLink' => t('Edit link'),
'save' => t('Save'),
'cancel' => t('Cancel'),
'enterUrl' => t('Enter URL...'),
],
];
}
49 changes: 47 additions & 2 deletions ai_content_strategy.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ai_content_strategy.recommendations.generate:
_admin_route: TRUE

ai_content_strategy.generate_more:
path: '/admin/reports/ai/content-strategy/generate-more/{section}/{title}'
path: '/admin/reports/ai/content-strategy/generate-more/{section}/{uuid}'
defaults:
_controller: '\Drupal\ai_content_strategy\Controller\ContentStrategyController::generateMore'
_title: 'Generate More Ideas'
Expand All @@ -27,7 +27,7 @@ ai_content_strategy.generate_more:
parameters:
section:
type: string
title:
uuid:
type: string

ai_content_strategy.add_more_recommendations:
Expand All @@ -40,6 +40,51 @@ ai_content_strategy.add_more_recommendations:
options:
_admin_route: TRUE

ai_content_strategy.delete_card:
path: '/admin/reports/ai/content-strategy/delete-card/{section}/{uuid}'
defaults:
_controller: '\Drupal\ai_content_strategy\Controller\ContentStrategyController::deleteCard'
_title: 'Delete Card'
requirements:
_permission: 'access ai content strategy'
options:
parameters:
section:
type: string
uuid:
type: string

ai_content_strategy.delete_idea:
path: '/admin/reports/ai/content-strategy/delete-idea/{section}/{uuid}/{idea_uuid}'
defaults:
_controller: '\Drupal\ai_content_strategy\Controller\ContentStrategyController::deleteIdea'
_title: 'Delete Content Idea'
requirements:
_permission: 'access ai content strategy'
options:
parameters:
section:
type: string
uuid:
type: string
idea_uuid:
type: string

ai_content_strategy.save_card:
path: '/admin/reports/ai/content-strategy/save-card/{section}/{uuid}'
defaults:
_controller: '\Drupal\ai_content_strategy\Controller\ContentStrategyController::saveCard'
_title: 'Save Card'
requirements:
_permission: 'access ai content strategy'
methods: [POST]
options:
parameters:
section:
type: string
uuid:
type: string

ai_content_strategy.settings:
path: '/admin/config/ai/content-strategy/settings'
defaults:
Expand Down
12 changes: 12 additions & 0 deletions ai_content_strategy.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ services:
parent: logger.channel_base
arguments: ['ai_content_strategy']

ai_content_strategy.recommendation_storage:
class: Drupal\ai_content_strategy\Service\RecommendationStorageService
arguments: ['@keyvalue', '@datetime.time', '@uuid']

ai_content_strategy.idea_row_builder:
class: Drupal\ai_content_strategy\Service\IdeaRowBuilder
arguments: ['@renderer']

ai_content_strategy.ajax_response_builder:
class: Drupal\ai_content_strategy\Service\AjaxResponseBuilder
arguments: ['@date.formatter']

ai_content_strategy.category_schema_builder:
class: Drupal\ai_content_strategy\Service\CategorySchemaBuilder
arguments: ['@entity_type.manager', '@cache.default']
Expand Down
62 changes: 62 additions & 0 deletions css/components/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @file
* Base layout styles for AI Content Strategy.
*/

/* Main Container */
.content-strategy-recommendations {
max-width: 1200px;
margin: 2em auto;
padding: 0 1em;
}

.content-strategy-description {
margin-bottom: 2em;
font-size: 1.1em;
color: #666;
}

/* Status Area */
.content-strategy-status {
display: flex;
flex-wrap: wrap;
gap: 2rem;
padding: 1rem;
background: #f8f9fa;
border: 1px solid #e5e7eb;
border-radius: 6px;
margin-bottom: 1.5rem;
}

.status-item {
display: flex;
align-items: baseline;
gap: 0.5rem;
font-size: 0.95em;
}

.status-item strong {
color: #374151;
font-weight: 600;
}

.status-item:not(strong) {
color: #6b7280;
}

/* Actions */
.content-strategy-actions {
display: flex;
gap: 1rem;
align-items: center;
margin-bottom: 2rem;
}

/* Empty State */
.empty-recommendations {
text-align: center;
padding: 3rem;
background: #f9fafb;
border-radius: 8px;
color: #6b7280;
}
59 changes: 25 additions & 34 deletions css/content-strategy.css → css/components/cards.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
/* Main Container */
.content-strategy-recommendations {
max-width: 1200px;
margin: 2em auto;
padding: 0 1em;
}

.content-strategy-description {
margin-bottom: 2em;
font-size: 1.1em;
color: #666;
}

/* Actions */
.content-strategy-actions {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 2rem;
}

.last-run-time {
color: #666;
font-size: 0.9em;
}
/**
* @file
* Recommendation card styles for AI Content Strategy.
*/

/* Recommendations Grid */
.recommendation-items {
Expand All @@ -47,11 +26,32 @@
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.recommendation-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
margin-bottom: 0.5rem;
}

.recommendation-header h4 {
flex: 1;
margin: 0;
}

.recommendation-item p {
margin-bottom: 1rem;
color: #4a4a4a;
}

/* Recommendation Actions */
.recommendation-actions {
display: flex;
align-items: center;
gap: 0.5rem;
margin-top: 1rem;
}

/* Priority Badges */
.priority-badge {
display: inline-block;
Expand Down Expand Up @@ -80,12 +80,3 @@
color: #16a34a;
border: 1px solid #dcfce7;
}

/* Empty State */
.empty-recommendations {
text-align: center;
padding: 3rem;
background: #f9fafb;
border-radius: 8px;
color: #6b7280;
}
61 changes: 61 additions & 0 deletions css/components/checkbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @file
* Checkbox styles for AI Content Strategy implemented status.
*/

/* Idea Checkbox */
.idea-checkbox {
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
}

.idea-checkbox input[type="checkbox"] {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}

.idea-checkbox-visual {
display: inline-block;
width: 25px;
height: 25px;
border: 2px solid #d1d5db;
border-radius: 4px;
background-color: #fff;
transition: all 0.15s ease;
position: relative;
}

.idea-checkbox-visual::after {
content: '';
position: absolute;
display: none;
left: 8px;
top: 3px;
width: 6px;
height: 12px;
border: solid #fff;
border-width: 0 2.5px 2.5px 0;
transform: rotate(45deg);
}

.idea-checkbox input[type="checkbox"]:checked + .idea-checkbox-visual {
background-color: #16a34a;
border-color: #16a34a;
}

.idea-checkbox input[type="checkbox"]:checked + .idea-checkbox-visual::after {
display: block;
}

.idea-checkbox:hover .idea-checkbox-visual {
border-color: #16a34a;
}

.idea-checkbox input[type="checkbox"]:focus + .idea-checkbox-visual {
outline: 2px solid #16a34a;
outline-offset: 2px;
}
Loading