Skip to content

Commit b6ab4ec

Browse files
adicionando botao de copiar texto e ajustando estilos
1 parent 22ccbc1 commit b6ab4ec

File tree

7 files changed

+45
-8
lines changed

7 files changed

+45
-8
lines changed

public/assets/js/script.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $(document).ready(function(){
4141
root.style.setProperty('--backgroundColor', newColor);
4242
});
4343

44-
$('#titleMargin').on('change', function(){
44+
$('#titleMargin').on('change', function( ){
4545
let newTitleMargin = $(this).val();
4646
root.style.setProperty('--titleMargin', newTitleMargin+'px');
4747
});
@@ -50,4 +50,22 @@ $(document).ready(function(){
5050
let newMarginHeight = $(this).val();
5151
root.style.setProperty('--marginHeight', newMarginHeight+'px');
5252
});
53+
54+
$('.copy-button').click(function() {
55+
event.preventDefault();
56+
57+
let elementName = $(this).children()[0].value;
58+
elementToCopy = $('#'+elementName);
59+
60+
let textToCopy = elementToCopy.text();
61+
if(textToCopy == ''){
62+
textToCopy = elementToCopy.val();
63+
}
64+
65+
let tempTextarea = $('<textarea>');
66+
$('body').append(tempTextarea);
67+
tempTextarea.val(textToCopy).select();
68+
document.execCommand('copy');
69+
tempTextarea.remove();
70+
});
5371
});
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' => 'rounded p-1 w-full h-10 cursor-pointer border border-stone-300 bg-white shadow-sm hover:bg-stone-100 focus:border-emerald-500 focus:ring-emerald-500 focus:border-2']) }}>
3+
<input @disabled($disabled) type="color" {{ $attributes->merge(['class' => 'rounded p-1 w-full h-10 cursor-pointer border border-stone-300 bg-white shadow-sm hover:bg-stone-100 focus:border-emerald-500 focus:ring-emerald-500 focus:border-2 transition ease-in-out duration-150']) }}>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@props(['value'])
2+
3+
<button {{ $attributes->merge(['class' => "copy-button cursor-pointer inline-flex items-center px-1 py-1 bg-white border border-stone-300 rounded-md font-semibold
4+
text-xs text-stone-700 uppercase tracking-widest shadow-sm hover:bg-stone-50 focus:outline-none focus:ring-2 focus:ring-emerald-500
5+
focus:ring-offset-2 disabled:opacity-25 transition ease-in-out duration-150"])
6+
}}>
7+
<input type="hidden" name="elementToCopy" value="{{ $value ?? '' }}">
8+
{{ $slot }}
9+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
10+
<path stroke-linecap="round" stroke-linejoin="round" d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184" />
11+
</svg>
12+
</button>
13+
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) {{ $attributes->merge(['class' => 'border-stone-300 focus:border-emerald-500 focus:ring-emerald-500 rounded shadow-sm hover:bg-stone-100']) }}>
3+
<input @disabled($disabled) {{ $attributes->merge(['class' => 'border-stone-300 focus:border-emerald-500 focus:ring-emerald-500 rounded shadow-sm hover:bg-stone-100 transition ease-in-out duration-150']) }}>

resources/views/content/partials/parsed-content.blade.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<x-section class="col-span-5 order-2 lg:col-span-2 lg:order-3 flex flex-col">
2-
<header class="text-lg font-medium px-4 py-2">Preview Content</header>
2+
<header class="text-lg font-medium px-4 py-2 flex justify-between items-center">
3+
<span>Preview Content</span>
4+
<x-copy-button value='htmlText'></x-copy-button>
5+
</header>
36

47
<div id="htmlText" class="parsedown flex flex-col gap-y-2 sm:w-auto p-4 h-max grow rounded-b">
58
Formatted content will appear here

resources/views/content/partials/write-content.blade.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<x-section class="col-span-5 order-1 lg:col-span-2 lg:order-2">
2-
<header class="text-lg font-medium px-4 py-2">Write here</header>
2+
<header class="text-lg font-medium px-4 py-2 flex justify-between items-center">
3+
<span>Write here</span>
4+
<x-copy-button value='text'></x-copy-button>
5+
</header>
36

4-
<div class="grow-wrap dont-break-out">
7+
<div id="replicated-value" class="grow-wrap dont-break-out">
58
<textarea id="text" name="text" type="text" rows="27" cols=""
6-
class="p-4 block w-full rounded-b border-white focus:border-emerald-500 focus:ring-emerald-500 focus:border-1"
9+
class="p-4 block w-full rounded-b border-white focus:border-emerald-500 focus:ring-emerald-500 focus:border-1 transition ease-in-out duration-150"
710
required autofocus autocomplete="text" placeholder="Type here"
811
onInput="this.parentNode.dataset.replicatedValue = this.value"></textarea>
912
</div>

resources/views/layouts/app.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@
5353

5454
<script src="{{ url('assets/js/jquery-3.7.1.min.js') }}"></script>
5555
<script src="{{ url('assets/js/js.cookie.min.js') }}"></script>
56-
<script src="{{ url('assets/js/script.js?v1') }}"></script>
56+
<script src="{{ url('assets/js/script.js?v2') }}"></script>
5757
</html>

0 commit comments

Comments
 (0)