Skip to content

Commit 4983b0e

Browse files
adicionando edição de margem entre elementos
1 parent b0222bf commit 4983b0e

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

app/Http/Controllers/ContentController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function generatePdf(Request $request){
3636
$filename = $nameInfo['filename'].'.'.$nameInfo['extension'];
3737

3838
$cssVariables = [
39+
'--marginHeight' => $request->marginHeight.'px',
3940
'--titleMargin' => $request->titleMargin.'px',
4041
];
4142
$cssColors = [
@@ -48,7 +49,7 @@ public function generatePdf(Request $request){
4849

4950
$htmlText = $this->markdownToHtml($rawText);
5051

51-
$rawCss = Storage::disk('public')->get('app.css');
52+
$rawCss = Storage::disk('public')->get('pdf.css');
5253

5354
$parsedCss = $this->parseCssVariables($rawCss, $cssVariables);
5455

public/assets/css/app.css

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
--backgroundColor0: hsl(from var(--backgroundColor) h s calc(l - 10));
1212
--backgroundColor1: hsl(from var(--backgroundColor) h s calc(l - 20));
1313

14-
--titleMargin: 8px;
14+
--marginHeight: 8px;
1515
}
1616

1717
#htmlText {
@@ -27,41 +27,43 @@
2727
.parsedown h1 {
2828
font-size: 34px;
2929
font-weight: bold;
30-
margin-top: var(--titleMargin);
30+
margin-top: var(--titleMargin) !important;
3131
}
3232

3333
.parsedown h2 {
3434
font-size: 24px;
3535
font-weight: bold;
36-
margin-top: var(--titleMargin);
36+
margin-top: var(--titleMargin) !important;
3737
}
3838

3939
.parsedown h3 {
4040
font-size: 20px;
4141
font-weight: bold;
42-
margin-top: var(--titleMargin);
42+
margin-top: var(--titleMargin) !important;
4343
}
4444

4545
.parsedown h4 {
4646
font-size: 18px;
4747
font-weight: bold;
48-
margin-top: var(--titleMargin);
48+
margin-top: var(--titleMargin) !important;
4949
}
5050

5151
.parsedown h5 {
5252
font-size: 16px;
5353
font-weight: bold;
54-
margin-top: var(--titleMargin);
54+
margin-top: var(--titleMargin) !important;
5555
}
5656

5757
.parsedown ul {
5858
list-style-type: circle;
5959
list-style-position: inside;
60+
margin-top: var(--marginHeight) !important;
6061
}
6162

6263
.parsedown ol {
6364
list-style-type: decimal;
6465
list-style-position: inside;
66+
margin-top: var(--marginHeight) !important;
6567
}
6668

6769
.parsedown a {
@@ -83,6 +85,7 @@
8385
margin: 4px 0px 16px 0px;
8486
text-wrap: wrap;
8587
overflow-wrap: break-word;
88+
margin-top: var(--marginHeight) !important;
8689
}
8790

8891
.parsedown code {
@@ -121,6 +124,7 @@ table {
121124
table-layout: fixed;
122125
width: 100%;
123126
border-collapse: collapse;
127+
margin-top: var(--marginHeight) !important;
124128
}
125129

126130
th,
@@ -135,7 +139,6 @@ th {
135139

136140
blockquote {
137141
font-size: 16px;
138-
margin: 16px auto;
139142
font-style: italic;
140143
color: var(--textColor);
141144
padding: 16px;
@@ -145,6 +148,7 @@ blockquote {
145148
line-height: 1.6;
146149
position: relative;
147150
background: var(--backgroundColor0);
151+
margin-top: var(--marginHeight) !important;
148152
}
149153

150154

public/assets/js/script.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ $(document).ready(function(){
4242
});
4343

4444
$('#titleMargin').on('change', function(){
45-
let newMargin = $(this).val();
46-
root.style.setProperty('--titleMargin', newMargin+'px');
45+
let newTitleMargin = $(this).val();
46+
root.style.setProperty('--titleMargin', newTitleMargin+'px');
47+
});
48+
49+
$('#marginHeight').on('change', function(){
50+
let newMarginHeight = $(this).val();
51+
root.style.setProperty('--marginHeight', newMarginHeight+'px');
4752
});
4853
});

resources/views/content/partials/style-editor.blade.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
<x-input-label for="titleMargin" class="truncate">Title Margin</x-input-label>
1919
<x-text-input name="titleMargin" id="titleMargin" placeholder="4px" type="number"></x-text-input>
2020
</div>
21+
<div class="flex flex-col flex-grow">
22+
<x-input-label for="marginHeight" class="truncate">Margin Between Elements</x-input-label>
23+
<x-text-input name="marginHeight" id="marginHeight" placeholder="4px" type="number"></x-text-input>
24+
</div>
2125
</div>
2226
</x-section>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ h5 {
3939
ul {
4040
list-style-type: circle;
4141
list-style-position: inside;
42+
margin-top: var(--marginHeight);
4243
}
4344

4445
ol {
4546
list-style-type: decimal;
4647
list-style-position: inside;
48+
margin-top: var(--marginHeight);
4749
}
4850

4951
a {
@@ -65,6 +67,7 @@ pre {
6567
margin: 4px 0px 16px 0px;
6668
text-wrap: wrap;
6769
overflow-wrap: break-word;
70+
margin-top: var(--marginHeight);
6871
}
6972

7073
code {
@@ -81,6 +84,7 @@ table {
8184
table-layout: fixed;
8285
width: 100%;
8386
border-collapse: collapse;
87+
margin-top: var(--marginHeight);
8488
}
8589

8690
th,
@@ -105,4 +109,5 @@ blockquote {
105109
line-height: 1.6;
106110
position: relative;
107111
background: var(--backgroundColor0);
112+
margin-top: var(--marginHeight);
108113
}

0 commit comments

Comments
 (0)