generated from filamentphp/plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from savannabits/2.x
Enhancements on the Signature Pad:
- Loading branch information
Showing
8 changed files
with
127 additions
and
76 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 70 additions & 38 deletions
108
resources/views/forms/components/fields/signature-pad.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,81 @@ | ||
@php | ||
$extraAlpineAttributes = $getExtraAlpineAttributes(); | ||
$id = $getId(); | ||
$isConcealed = $isConcealed(); | ||
$isDisabled = $isDisabled(); | ||
$isPrefixInline = $isPrefixInline(); | ||
$isSuffixInline = $isSuffixInline(); | ||
$prefixActions = $getPrefixActions(); | ||
$prefixIcon = $getPrefixIcon(); | ||
$prefixLabel = $getPrefixLabel(); | ||
$suffixActions = $getSuffixActions(); | ||
$suffixIcon = $getSuffixIcon(); | ||
$suffixLabel = $getSuffixLabel(); | ||
$statePath = $getStatePath(); | ||
@endphp | ||
<x-dynamic-component | ||
:component="$getFieldWrapperView()" | ||
:field="$field" | ||
> | ||
<div | ||
wire:ignore | ||
ax-load | ||
x-load-css="[ | ||
@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('signature-pad-styles', 'coolsam/signature-pad')), | ||
@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('signature-pad-styles', \Coolsam\SignaturePad\Forms\Components\Fields\SignaturePad::PACKAGE_NAME)), | ||
]" | ||
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('signature-pad', 'coolsam/signature-pad') }}" | ||
x-data="signaturePad({ | ||
state: $wire.{{ $applyStateBindingModifiers('entangle(\'' . $getStatePath() . '\')') }}, | ||
disabled : {{$isDisabled() ? 'true':'false'}}, | ||
dotSize : '{{$getStrokeDotSize()}}', | ||
minWidth: '{{$getStrokeMinWidth()}}', | ||
maxWidth : '{{$getStrokeMaxWidth()}}', | ||
minDistance: '{{$getStrokeMinDistance()}}', | ||
penColor: '{{$getPenColor()}}', | ||
backgroundColor: '{{$getBackgroundColor()}}' | ||
})" class="p-2 md:p-4 bg-white dark:bg-gray-700 sm:rounded-md"> | ||
<template x-show="state"> | ||
<img | ||
class="w-full h-full border-2 dark:border-gray-800 border-dashed rounded-md" :src="state" | ||
alt="sig"> | ||
ax-load | ||
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('signature-pad', \Coolsam\SignaturePad\Forms\Components\Fields\SignaturePad::PACKAGE_NAME) }}" | ||
x-data="signaturePad( | ||
$wire.{{ $applyStateBindingModifiers("entangle('{$getStatePath()}')") }}, | ||
{ | ||
disabled : {{$isDisabled ? 'true':'false'}}, | ||
dotSize : '{{$getStrokeDotSize()}}', | ||
minWidth: '{{$getStrokeMinWidth()}}', | ||
maxWidth : '{{$getStrokeMaxWidth()}}', | ||
minDistance: '{{$getStrokeMinDistance()}}', | ||
penColor: '{{$getPenColor()}}', | ||
backgroundColor: '{{$getBackgroundColor()}}', | ||
id: '{{ $id }}', | ||
})" | ||
class="p-2 md:p-4 bg-white dark:bg-gray-500 sm:rounded-md"> | ||
<template x-if="state"> | ||
<img class="border mx-auto dark:border-gray-700 rounded-lg w-full max-w-[800px]" alt="current_signature" :src="state"> | ||
</template> | ||
<canvas | ||
x-ref="canvas" | ||
style="max-height: 200px !important; max-width: 800px !important; border-style: dashed; border-width: initial" | ||
class="w-full h-full m-2 mx-auto border-dotted rounded-md dark:border-gray-800"></canvas> | ||
<div class="flex mt-2 justify-center space-x-2"> | ||
<x-filament::button x-if="!signaturePad?.isEmpty()" color="danger" outlined="true" size="sm" @click.prevent="clear()"> | ||
{{__('signature-pad::signature-pad.clear')}} | ||
</x-filament::button> | ||
@if(!$isDisabledDownload()) | ||
<x-filament::button color="primary" outlined="true" size="sm" icon="heroicon-o-arrow-down-on-square" | ||
@click.prevent="downloadSVG()">.svg | ||
</x-filament::button> | ||
<x-filament::button color="primary" outlined="true" size="sm" icon="heroicon-o-arrow-down-on-square" | ||
@click.prevent="downloadPNG()">.png | ||
</x-filament::button> | ||
<x-filament::button color="primary" outlined="true" size="sm" icon="heroicon-o-arrow-down-on-square" | ||
@click.prevent="downloadJPG()">.jpg | ||
@if(!($isReadOnly() || $isDisabled)) | ||
<canvas | ||
before="Hello World" | ||
{{ \Filament\Support\prepare_inherited_attributes($getExtraInputAttributeBag()) | ||
->merge($extraAlpineAttributes, escape: false) | ||
->merge([ | ||
'disabled' => $isDisabled, | ||
'id' => $id, | ||
'x-ref' => 'canvas', | ||
'x-model' => 'state', | ||
'placeholder' => $getPlaceholder(), | ||
'readonly' => $isReadOnly(), | ||
'required' => $isRequired() && (! $isConcealed), | ||
], escape: false) }} | ||
style="max-height: 100px !important; max-width: 800px !important; border-style: dashed; border-width: initial" | ||
class="w-full h-full m-2 mx-auto border-dashed rounded-md dark:border-gray-700 before:content-[attr(before)]"> | ||
</canvas> | ||
<div class="flex mt-2 justify-center space-x-2"> | ||
<x-filament::button icon="heroicon-o-arrow-path" color="danger" outlined="true" size="sm" @click.prevent="resizeCanvas()"> | ||
</x-filament::button> | ||
@endif | ||
</div> | ||
|
||
<template x-if="signaturePad"> | ||
<x-filament::button color="danger" outlined="true" size="sm" @click.prevent="clear()"> | ||
{{__('signature-pad::signature-pad.clear')}} | ||
</x-filament::button> | ||
</template> | ||
@if(!$isDisabledDownload()) | ||
<x-filament::button color="primary" outlined="true" size="sm" icon="heroicon-o-arrow-down-on-square" | ||
@click.prevent="downloadSVG()">.svg | ||
</x-filament::button> | ||
<x-filament::button color="primary" outlined="true" size="sm" icon="heroicon-o-arrow-down-on-square" | ||
@click.prevent="downloadPNG()">.png | ||
</x-filament::button> | ||
<x-filament::button color="primary" outlined="true" size="sm" icon="heroicon-o-arrow-down-on-square" | ||
@click.prevent="downloadJPG()">.jpg | ||
</x-filament::button> | ||
@endif | ||
</div> | ||
@endif | ||
</div> | ||
</x-dynamic-component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters