Skip to content

Commit c2140d0

Browse files
adicionando input para tamanho da margem dos títulos
1 parent 383b3c0 commit c2140d0

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

app/Http/Controllers/ContentController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,22 @@ public function generatePdf(Request $request){
3535
}
3636
$filename = $nameInfo['filename'].'.'.$nameInfo['extension'];
3737

38+
$cssVariables = [
39+
'--titleMargin' => $request->titleMargin.'px',
40+
];
3841
$cssColors = [
3942
'--textColor' => $request->textColor,
4043
'--highlightColor' => $request->highlightColor,
4144
'--backgroundColor' => $request->backgroundColor,
4245
];
4346
$cssColors = $colorService->generateDarkerColors($cssColors, 2);
47+
$cssVariables = array_merge($cssVariables, $cssColors);
4448

4549
$htmlText = $this->markdownToHtml($rawText);
4650

4751
$rawCss = Storage::disk('public')->get('app.css');
4852

49-
$parsedCss = $this->parseCssVariables($rawCss, $cssColors);
53+
$parsedCss = $this->parseCssVariables($rawCss, $cssVariables);
5054

5155
$css = '<style>'. $parsedCss .'</style>';
5256

public/assets/css/app.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
--backgroundColor: #FFFFFF;
1111
--backgroundColor0: hsl(from var(--backgroundColor) h s calc(l - 10));
1212
--backgroundColor1: hsl(from var(--backgroundColor) h s calc(l - 20));
13+
14+
--titleMargin: 8px;
1315
}
1416

1517
#htmlText {
@@ -25,31 +27,31 @@
2527
.parsedown h1 {
2628
font-size: 34px;
2729
font-weight: bold;
28-
margin-top: 20px;
30+
margin-top: var(--titleMargin);
2931
}
3032

3133
.parsedown h2 {
3234
font-size: 24px;
3335
font-weight: bold;
34-
margin-top: 20px;
36+
margin-top: var(--titleMargin);
3537
}
3638

3739
.parsedown h3 {
3840
font-size: 20px;
3941
font-weight: bold;
40-
margin-top: 20px;
42+
margin-top: var(--titleMargin);
4143
}
4244

4345
.parsedown h4 {
4446
font-size: 18px;
4547
font-weight: bold;
46-
margin-top: 20px;
48+
margin-top: var(--titleMargin);
4749
}
4850

4951
.parsedown h5 {
5052
font-size: 16px;
5153
font-weight: bold;
52-
margin-top: 20px;
54+
margin-top: var(--titleMargin);
5355
}
5456

5557
.parsedown ul {

public/assets/js/script.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ $(document).ready(function(){
4040
let newColor = $(this).val();
4141
root.style.setProperty('--backgroundColor', newColor);
4242
});
43+
44+
$('#titleMargin').on('change', function(){
45+
let newMargin = $(this).val();
46+
root.style.setProperty('--titleMargin', newMargin+'px');
47+
});
4348
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@props(['disabled' => false])
22

3-
<input @disabled($disabled) type="color" {{ $attributes->merge(['class' => 'float-right rounded p-1 w-full h-10 cursor-pointer border border-gray-200 bg-white']) }}>
3+
<input @disabled($disabled) type="color" {{ $attributes->merge(['class' => 'rounded p-1 w-full h-10 cursor-pointer border border-gray-200 bg-white shadow-sm']) }}>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
<x-color-input-label for="backgroundColor" class="truncate">Background Color</x-color-input-label>
1515
<x-color-input name="backgroundColor" id="backgroundColor" value="#FFFFFF"></x-color-input>
1616
</div>
17+
<div class="flex flex-col flex-grow">
18+
<x-input-label for="titleMargin" class="truncate">Title Margin</x-input-label>
19+
<x-text-input name="titleMargin" id="titleMargin" placeholder="4px" type="number"></x-text-input>
20+
</div>
1721
</div>
1822
</x-section>

storage/app/public/app.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ body {
99
h1 {
1010
font-size: 34px;
1111
font-weight: bold;
12-
margin-top: 20px;
12+
margin-top: var(--titleMargin);
1313
}
1414

1515
h2 {
1616
font-size: 24px;
1717
font-weight: bold;
18-
margin-top: 20px;
18+
margin-top: var(--titleMargin);
1919
}
2020

2121
h3 {
2222
font-size: 20px;
2323
font-weight: bold;
24-
margin-top: 20px;
24+
margin-top: var(--titleMargin);
2525
}
2626

2727
h4 {
2828
font-size: 18px;
2929
font-weight: bold;
30-
margin-top: 20px;
30+
margin-top: var(--titleMargin);
3131
}
3232

3333
h5 {
3434
font-size: 16px;
3535
font-weight: bold;
36-
margin-top: 20px;
36+
margin-top: var(--titleMargin);
3737
}
3838

3939
ul {

0 commit comments

Comments
 (0)