]> skyeroc.xyz Git - flatmark/commitdiff
feat: button
authorelektrischerwalfisch <mail@elektrischerwalfisch.de>
Mon, 14 Apr 2025 08:22:22 +0000 (10:22 +0200)
committerelektrischerwalfisch <mail@elektrischerwalfisch.de>
Mon, 14 Apr 2025 08:22:22 +0000 (10:22 +0200)
pages-en/examples.md
theme/css/style.css
theme/functions.php

index b4337322aaf05ebd8c44e6332ce4e74d578e89f8..662ec81eef6c1ba0322aacf2f4f98c666bae1b1d 100644 (file)
@@ -14,6 +14,10 @@ These shortcodes are available by default in the flatMark-theme:
     Content with backgrond-color
 {/background}
 
+{button}
+    Link inside this shortcode appears as button
+{/button}
+
 {img-rounded}
     Picture with rounded border
 {/img-rounded}
@@ -36,7 +40,7 @@ These shortcodes are available by default in the flatMark-theme:
 {/code}
 
 ### Additional values
-The shortcodes for columns and background accept additional values which are rendered as classes so that the output can be styled directly by css. In the default flatMark-theme these additional values are already styled:
+The shortcodes for columns, background and buttons accept additional values which are rendered as classes so that the output can be styled directly by css. In the default flatMark-theme these additional values are already styled:
 {code}
 {columns 50-50}
 {columns 33-66}
@@ -45,6 +49,9 @@ The shortcodes for columns and background accept additional values which are ren
 
 {background color-01}
 {background color-02}
+
+{button color-01}
+{button color-02}
 {/code}  
 <br>  
 
@@ -103,6 +110,9 @@ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
 {/columns}
 <br>
 
+{button color-01}[Button color-01](/en/home){/button}
+
+{button color-02}[Button color-02](/en/home){/button}
 
 
 
index 9ec897ca0100897d455ca57f0f0126c6d878b520..0f6ded9151a80b93b1cfa69e81e89747b0065f1a 100644 (file)
@@ -197,6 +197,12 @@ main .img-rounded {aspect-ratio: 1/1;border-radius: 50%;overflow: hidden;}
 main .background .img-rounded {border: var(--space-below-01) solid var(--colorlight); margin-top: calc(0px - var(--space-below-02));}
 main .img-rounded img {object-fit: cover;width: 100%;height: 100%;display: block;}
 
+main .button {}
+main .button a {display: inline-block;background: var(--colordark);color: var(--colorlight);text-decoration:none;padding: var(--space-below-00) var(--side-space-01);font-weight: 700;}
+main .button a:hover {opacity: 0.5;}
+main .button.bg-color-01 a {background: var(--color-01);}
+main .button.bg-color-02 a {background: var(--color-02);}
+
 main code {font-family: courier 'Courier New', Courier, monospace;font-size: var(--fontsize-m);background: var(--color-gray-01);color: var(--colordark);}
 
 #main pre:has(code) {word-break: normal;word-wrap: normal;overflow: scroll;background: var(--color-gray-01);padding: var(--space-below-01) var(--space-below-01);border-radius: 10px;margin-bottom: var(--space-below-01);}
index eb79be0820c94b98723c5518e2fbda5d3121aa68..49da295bb422787ca9a8fce073e7625245b24d7c 100644 (file)
             return '<div class="background ' . $bgClass . '">' . $bgHtml . '</div>';
         }, $markdown);
 
+    // Shortcode: button with optional class
+        $pattern = '/\{button(.*?)\}(.*?)\{\/button\}/s';
+        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+            // Capture the additional class (if any exists) directly after {button}
+            $buttonAttributes = trim($matches[1]);  // e.g., "color-01" from {button color-01}
+            $buttonContent = $matches[2];   // Capture the content inside {button} ... {/button}
+
+            // Add prefix to the class
+            $buttonPrefix = 'bg-'; // Define the prefix here
+            $buttonClass = !empty($buttonAttributes) ? $buttonPrefix . $buttonAttributes : '';  // Prefix added to class (e.g., bg-color-01)
+
+            // Convert the inner Markdown content
+            $buttonHtml = $Parsedown->text($buttonContent);
+
+            // Wrap everything in a div and add class if available
+            return '<div class="button ' . $buttonClass . '">' . $buttonHtml . '</div>';
+        }, $markdown);
+
     // Shortcode: img rounded
         $pattern = '/\{img-rounded\}(.*?)\{\/img-rounded\}/s';
         $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {