Skip to content

Commit 4d70292

Browse files
committed
Implement collapsible card functionality for project addition and usage instructions
1 parent 35540f6 commit 4d70292

3 files changed

Lines changed: 71 additions & 7 deletions

File tree

assets/css/admin.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,41 @@
4747
font-size: 16px;
4848
}
4949

50+
/* Collapsible Card Styles */
51+
.gtws-collapsible-card .gtws-card-header {
52+
cursor: pointer;
53+
display: flex;
54+
align-items: center;
55+
gap: 10px;
56+
margin-bottom: 0;
57+
padding: 10px 15px;
58+
margin: -25px -25px 20px -25px;
59+
background: #f6f7f7;
60+
border-bottom: 1px solid #ccd0d4;
61+
transition: background 0.2s;
62+
user-select: none;
63+
}
64+
65+
.gtws-collapsible-card .gtws-card-header:hover {
66+
background: #e9ecef;
67+
}
68+
69+
.gtws-toggle-icon {
70+
transition: transform 0.3s ease;
71+
font-size: 18px;
72+
width: 18px;
73+
height: 18px;
74+
color: #2271b1;
75+
}
76+
77+
.gtws-collapsible-card .gtws-card-header.active .gtws-toggle-icon {
78+
transform: rotate(90deg);
79+
}
80+
81+
.gtws-card-content {
82+
padding-top: 10px;
83+
}
84+
5085
/* Form Styles */
5186
.gtws-form {
5287
max-width: 800px;

assets/js/admin.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66
'use strict';
77

88
$(document).ready(function() {
9-
9+
10+
// Collapsible Card Toggle
11+
$('.gtws-card-header[data-toggle="collapse"]').on('click', function() {
12+
const $header = $(this);
13+
const $content = $header.next('.gtws-card-content');
14+
15+
// Toggle active class on header
16+
$header.toggleClass('active');
17+
18+
// Slide toggle content
19+
$content.slideToggle(300);
20+
});
21+
1022
// Add Project Form Submit
1123
$('#gtws-add-project-form').on('submit', function(e) {
1224
e.preventDefault();
@@ -36,7 +48,15 @@
3648
$form[0].reset();
3749
$('#branch').val('main');
3850
$('#branch-list').empty();
39-
51+
52+
// Collapse the "Add New Project" section before reload
53+
const $addProjectCard = $form.closest('.gtws-collapsible-card');
54+
const $header = $addProjectCard.find('.gtws-card-header');
55+
const $content = $addProjectCard.find('.gtws-card-content');
56+
57+
$header.removeClass('active');
58+
$content.slideUp(300);
59+
4060
// Reload page after short delay to show new project
4161
setTimeout(function() {
4262
location.reload();

github-to-wordpress-sync.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,12 @@ public function render_admin_page() {
780780

781781
<div class="gtws-container">
782782
<!-- Add New Project Section -->
783-
<div class="gtws-card">
784-
<h2><?php _e('Add New Project', 'snn'); ?></h2>
785-
783+
<div class="gtws-card gtws-collapsible-card">
784+
<h2 class="gtws-card-header" data-toggle="collapse">
785+
<span class="gtws-toggle-icon dashicons dashicons-arrow-right"></span>
786+
<?php _e('Add New Project', 'snn'); ?>
787+
</h2>
788+
<div class="gtws-card-content" style="display: none;">
786789
<form id="gtws-add-project-form" class="gtws-form">
787790
<div class="gtws-form-group">
788791
<label for="github_url">
@@ -857,6 +860,7 @@ public function render_admin_page() {
857860
<?php _e('Add Project', 'snn'); ?>
858861
</button>
859862
</form>
863+
</div>
860864
</div>
861865

862866
<!-- Projects List -->
@@ -974,8 +978,12 @@ class="button button-link-delete gtws-delete-project"
974978
</div>
975979

976980
<!-- Info Section -->
977-
<div class="gtws-card gtws-info-card">
978-
<h3><?php _e('How to Use', 'snn'); ?></h3>
981+
<div class="gtws-card gtws-info-card gtws-collapsible-card">
982+
<h3 class="gtws-card-header" data-toggle="collapse">
983+
<span class="gtws-toggle-icon dashicons dashicons-arrow-right"></span>
984+
<?php _e('How to Use', 'snn'); ?>
985+
</h3>
986+
<div class="gtws-card-content" style="display: none;">
979987
<ol>
980988
<li><?php _e('Add your GitHub repository URL (e.g., https://github.com/username/repo)', 'snn'); ?></li>
981989
<li><?php _e('Select whether it\'s a theme or plugin', 'snn'); ?></li>
@@ -991,6 +999,7 @@ class="button button-link-delete gtws-delete-project"
991999
<strong><?php _e('Important:', 'snn'); ?></strong>
9921000
<?php _e('Syncing will overwrite local changes. Make sure to commit your work to GitHub first!', 'snn'); ?>
9931001
</div>
1002+
</div>
9941003
</div>
9951004
</div>
9961005
</div>

0 commit comments

Comments
 (0)