Parcourir la source

add show containts but have error

Vitalik il y a 1 mois
Parent
commit
6bfb6bd254

+ 3 - 3
public/css/styles.css

@@ -283,7 +283,7 @@ h1, h2, h3, h4, h5, h6 {
   border: 1px solid var(--content-border-color);
 }
 .text table tbody tr:nth-child(even) {
-  background: rgba(var(--table-header-color-rgb, 42, 42, 42), 0.3);
+  background: rgba(var(--table-header-color-rgb, 42, 42, 42), 0.1);
 }
 .text table tbody td {
   padding: 12px;
@@ -547,6 +547,7 @@ h1, h2, h3, h4, h5, h6 {
   font-style: normal;
   font-weight: 400;
   line-height: 20px; /* 142.857% */
+  color: var(--body-bg-color);
 }
 @media (max-width: 768px) {
   .footer__text {
@@ -823,7 +824,7 @@ h1, h2, h3, h4, h5, h6 {
   aspect-ratio: 1/1;
   font-weight: 600;
   background-color: var(--accent-color);
-  color: var(--text-color);
+  color: var(--body-bg-color);
   flex-shrink: 0;
   border-radius: 50%;
 }
@@ -955,7 +956,6 @@ h1, h2, h3, h4, h5, h6 {
   transition: all 0.2s ease;
 }
 .toc__link:hover {
-  background-color: rgba(0, 0, 0, 0.03);
   color: var(--link-color);
 }
 .toc__list--nested > .toc__item > .toc__link {

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
public/css/styles.css.map


+ 1 - 1
resources/sass/base/_typography.scss

@@ -232,7 +232,7 @@ table{
 		 tr{
 			 border: 1px solid var(--content-border-color);
 			 &:nth-child(even){
-				 background: rgba(var(--table-header-color-rgb, 42, 42, 42), 0.3);
+				 background: rgba(var(--table-header-color-rgb, 42, 42, 42), 0.1);
 			 }
 		 }
 		 td{

+ 1 - 1
resources/sass/components/_faq.scss

@@ -87,7 +87,7 @@
         aspect-ratio: 1/1;
         font-weight: 600;
         background-color: var(--accent-color);
-        color: var(--text-color);
+        color: var(--body-bg-color);
         flex-shrink: 0;
         border-radius:50%;
         @include mobile{

+ 0 - 1
resources/sass/components/_toc.scss

@@ -108,7 +108,6 @@
         transition: all 0.2s ease;
 
         &:hover {
-            background-color: rgba(0, 0, 0, 0.03);
             color: var(--link-color);
         }
 

+ 1 - 0
resources/sass/layout/_footer.scss

@@ -26,6 +26,7 @@
         font-style: normal;
         font-weight: 400;
         line-height: 20px; /* 142.857% */
+        color:var(--body-bg-color);
         @include mobile{
             font-size:12px;
             line-height: 18px;

+ 26 - 0
resources/view/admin/index.php

@@ -374,6 +374,32 @@ ob_start();
                                             </div>
                                         </div>
 
+                                        <!-- Акцентный цвет -->
+                                        <div>
+                                            <label class="block text-sm font-medium text-gray-700 mb-2">Акцентный цвет</label>
+                                            <div class="flex gap-3">
+                                                <input type="color" value="<?= $styles['accent_color'] ?? '#FF6B35' ?>"
+                                                       class="w-12 h-10 rounded border border-gray-300 cursor-pointer"
+                                                       onchange="this.nextElementSibling.value = this.value">
+                                                <input type="text" name='styles[accent_color]' value="<?= htmlspecialchars($styles['accent_color'] ?? '') ?>"
+                                                       placeholder="#FF6B35"
+                                                       class="flex-1 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
+                                            </div>
+                                        </div>
+
+                                        <!-- Цвет границы контента -->
+                                        <div>
+                                            <label class="block text-sm font-medium text-gray-700 mb-2">Цвет границы контента</label>
+                                            <div class="flex gap-3">
+                                                <input type="color" value="<?= $styles['content_border_color'] ?? '#E4E4E4' ?>"
+                                                       class="w-12 h-10 rounded border border-gray-300 cursor-pointer"
+                                                       onchange="this.nextElementSibling.value = this.value">
+                                                <input type="text" name='styles[content_border_color]' value="<?= htmlspecialchars($styles['content_border_color'] ?? '') ?>"
+                                                       placeholder="#E4E4E4"
+                                                       class="flex-1 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
+                                            </div>
+                                        </div>
+
                                         <!-- Цвет таблицы -->
                                         <div>
                                             <label class="block text-sm font-medium text-gray-700 mb-2">Цвет таблицы (фон)</label>

+ 29 - 43
resources/view/home.php

@@ -13,54 +13,40 @@ ob_start();
 <?php endif; ?>
 
 
+<?php print_arr($containts); ?>
+
+
 <div class="section-wrapper container">
     <!-- Table of Contents -->
-    <div class="toc">
-        <div class="toc__header">
-            <h2 class="toc__title">Contents</h2>
-        </div>
-        <div class="toc__content">
-            <ol class="toc__list">
-                <li class="toc__item">
-                    <a href="#section1" class="toc__link">Introduction to the Topic</a>
-                </li>
-                <li class="toc__item">
-                    <a href="#section2" class="toc__link">Main Features and Benefits</a>
-                    <ul class="toc__list toc__list--nested">
-                        <li class="toc__item">
-                            <a href="#section2-1" class="toc__link">Feature Overview</a>
-                        </li>
-                        <li class="toc__item">
-                            <a href="#section2-2" class="toc__link">Key Benefits</a>
-                        </li>
-                        <li class="toc__item">
-                            <a href="#section2-3" class="toc__link">Comparison with Competitors</a>
-                        </li>
-                    </ul>
-                </li>
-                <li class="toc__item">
-                    <a href="#section3" class="toc__link">How to Get Started</a>
-                    <ul class="toc__list toc__list--nested">
-                        <li class="toc__item">
-                            <a href="#section3-1" class="toc__link">Installation Process</a>
-                        </li>
+    <?php if (!empty($containts)): ?>
+        <div class="toc">
+            <div class="toc__header">
+                <h2 class="toc__title">Contents</h2>
+            </div>
+            <div class="toc__content">
+                <ol class="toc__list">
+                    <?php foreach ($containts as $item): ?>
                         <li class="toc__item">
-                            <a href="#section3-2" class="toc__link">Initial Configuration</a>
+                            <a href="#<?= htmlspecialchars($item['id']) ?>" class="toc__link">
+                                <?= htmlspecialchars($item['text']) ?>
+                            </a>
+                            <?php if (!empty($item['h3'])): ?>
+                                <ul class="toc__list toc__list--nested">
+                                    <?php foreach ($item['h3'] as $subItem): ?>
+                                        <li class="toc__item">
+                                            <a href="#<?= htmlspecialchars($subItem['id']) ?>" class="toc__link">
+                                                <?= htmlspecialchars($subItem['text']) ?>
+                                            </a>
+                                        </li>
+                                    <?php endforeach; ?>
+                                </ul>
+                            <?php endif; ?>
                         </li>
-                    </ul>
-                </li>
-                <li class="toc__item">
-                    <a href="#section4" class="toc__link">Advanced Tips and Tricks</a>
-                </li>
-                <li class="toc__item">
-                    <a href="#section5" class="toc__link">Common Questions</a>
-                </li>
-                <li class="toc__item">
-                    <a href="#section6" class="toc__link">Conclusion</a>
-                </li>
-            </ol>
+                    <?php endforeach; ?>
+                </ol>
+            </div>
         </div>
-    </div>
+    <?php endif; ?>
 
     <section class="section text">
         <?= $topContent ?>

+ 29 - 0
resources/view/pages/default.php

@@ -41,6 +41,35 @@ $settingsContent = settings('content')->getAll();
         <section class="page-content">
             <div class="container">
                 <h1><?= htmlspecialchars($pageData['name']) ?></h1>
+
+                <?php if (!empty($containts)): ?>
+                    <div class="toc">
+                        <h2>Содержание</h2>
+                        <nav class="toc-nav">
+                            <ul>
+                                <?php foreach ($containts as $item): ?>
+                                    <li>
+                                        <a href="#<?= htmlspecialchars($item['id']) ?>">
+                                            <?= htmlspecialchars($item['text']) ?>
+                                        </a>
+                                        <?php if (!empty($item['h3'])): ?>
+                                            <ul>
+                                                <?php foreach ($item['h3'] as $subItem): ?>
+                                                    <li>
+                                                        <a href="#<?= htmlspecialchars($subItem['id']) ?>">
+                                                            <?= htmlspecialchars($subItem['text']) ?>
+                                                        </a>
+                                                    </li>
+                                                <?php endforeach; ?>
+                                            </ul>
+                                        <?php endif; ?>
+                                    </li>
+                                <?php endforeach; ?>
+                            </ul>
+                        </nav>
+                    </div>
+                <?php endif; ?>
+
                 <div class="content">
                     <?= $pageContent ?>
                 </div>

+ 5 - 0
src/Pages/home.php

@@ -32,6 +32,10 @@ $pageContent = $homepage['content'] ?? '';
 $extraFields = json_decode($homepage['extra_fields'] ?? '{}', true) ?: [];
 $topContent = $extraFields['top_content'] ?? '';
 
+// Подготавливаем содержание для контента
+$containts = getContainsByText($pageContent);
+$pageContent = addIdToHInText($pageContent, $containts);
+
 // Загружаем FAQ для главной страницы
 $faqData = $faqModel->getForRecord('page', $homepage['id']);
 $faqs = !empty($faqData) && is_array($faqData) ? $faqData[0] : [];
@@ -83,6 +87,7 @@ return ViewRender('home.php', [
     'pageContent' => $pageContent,
     'pageData' => $homepage,
     'topContent' => $topContent,
+    'containts' => $containts,
     'currentDomain' => $currentDomain,
     'currentUrl' => $currentUrl,
     'isHomepage' => $is_homepage,

+ 6 - 3
src/Pages/page.php

@@ -50,9 +50,12 @@ $pageContent = $currentPage['content'] ?? '';
 // Получаем топ контент из extra_fields
 $topContent = $extraFields['top_content'] ?? '';
 
+// Конкатенируем topContent и pageContent
+$fullContent = $topContent . $pageContent;
+
 // Подготавливаем содержание для контента
-$headings = getContainsByText($pageContent);
-$pageContent = addIdToHInText($pageContent, $headings);
+$containts = getContainsByText($fullContent);
+$pageContent = addIdToHInText($fullContent, $containts);
 
 // Получаем FAQ для этой страницы
 $faqItems = $faqModel->getByMorphable('page', $currentPage['id']);
@@ -84,7 +87,7 @@ return ViewRender($layoutFile, [
     'pageContent' => $pageContent,
     'pageData' => $currentPage,
     'topContent' => $topContent,
-    'headings' => $headings,
+    'containts' => $containts,
     'currentDomain' => $currentDomain,
     'currentUrl' => $currentUrl,
     'isHomepage' => !empty($currentPage['is_homepage']),

+ 2 - 2
src/helpers.php

@@ -47,7 +47,7 @@ function getContainsByText(?string $text): array
     foreach ($matches[1] as $key => $textH2) {
         if (empty($textH2) && isset($matches[2][$key]) && ! empty($matches[2][$key])) {
             $h3[] = [
-                'id' => Str::slug($matches[2][$key]),
+                'id' => getSlug($matches[2][$key]),
                 'text' => $matches[2][$key],
             ];
 
@@ -60,7 +60,7 @@ function getContainsByText(?string $text): array
 
         $h3 = [];
         $activeText = $textH2;
-        $activeId = Str::slug($textH2);
+        $activeId = getSlug($textH2);
         $h2Array[$activeId] = [
             'id' => $activeId,
             'text' => $activeText,

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff