feat: allow recipient to select signature color (#1325)
Allow users to select a colour for the signature. The allowed colours are black, white, red, blue, and green.
This commit is contained in:
@@ -140,6 +140,14 @@ msgstr "Genehmiger"
|
|||||||
msgid "Approving"
|
msgid "Approving"
|
||||||
msgstr "Genehmigung"
|
msgstr "Genehmigung"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:276
|
||||||
|
msgid "Black"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:290
|
||||||
|
msgid "Blue"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: packages/ui/primitives/document-flow/field-item-advanced-settings.tsx:297
|
#: packages/ui/primitives/document-flow/field-item-advanced-settings.tsx:297
|
||||||
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:58
|
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:58
|
||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
@@ -179,7 +187,7 @@ msgstr "Checkbox-Werte"
|
|||||||
msgid "Clear filters"
|
msgid "Clear filters"
|
||||||
msgstr "Filter löschen"
|
msgstr "Filter löschen"
|
||||||
|
|
||||||
#: packages/ui/primitives/signature-pad/signature-pad.tsx:256
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:310
|
||||||
msgid "Clear Signature"
|
msgid "Clear Signature"
|
||||||
msgstr "Unterschrift löschen"
|
msgstr "Unterschrift löschen"
|
||||||
|
|
||||||
@@ -312,6 +320,10 @@ msgstr "Globale Empfängerauthentifizierung"
|
|||||||
msgid "Go Back"
|
msgid "Go Back"
|
||||||
msgstr "Zurück"
|
msgstr "Zurück"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:297
|
||||||
|
msgid "Green"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: packages/lib/constants/recipient-roles.ts:72
|
#: packages/lib/constants/recipient-roles.ts:72
|
||||||
msgid "I am a signer of this document"
|
msgid "I am a signer of this document"
|
||||||
msgstr "Ich bin ein Unterzeichner dieses Dokuments"
|
msgstr "Ich bin ein Unterzeichner dieses Dokuments"
|
||||||
@@ -477,6 +489,10 @@ msgstr "Erhält Kopie"
|
|||||||
msgid "Recipient action authentication"
|
msgid "Recipient action authentication"
|
||||||
msgstr "Empfängeraktion Authentifizierung"
|
msgstr "Empfängeraktion Authentifizierung"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:283
|
||||||
|
msgid "Red"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: packages/ui/primitives/document-flow/add-settings.tsx:298
|
#: packages/ui/primitives/document-flow/add-settings.tsx:298
|
||||||
#: packages/ui/primitives/template-flow/add-template-settings.tsx:332
|
#: packages/ui/primitives/template-flow/add-template-settings.tsx:332
|
||||||
msgid "Redirect URL"
|
msgid "Redirect URL"
|
||||||
@@ -733,6 +749,10 @@ msgstr "Viewer"
|
|||||||
msgid "Viewing"
|
msgid "Viewing"
|
||||||
msgstr "Viewing"
|
msgstr "Viewing"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:280
|
||||||
|
#~ msgid "White"
|
||||||
|
#~ msgstr ""
|
||||||
|
|
||||||
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:44
|
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:44
|
||||||
msgid "You are about to send this document to the recipients. Are you sure you want to continue?"
|
msgid "You are about to send this document to the recipients. Are you sure you want to continue?"
|
||||||
msgstr "Sie sind dabei, dieses Dokument an die Empfänger zu senden. Sind Sie sicher, dass Sie fortfahren möchten?"
|
msgstr "Sie sind dabei, dieses Dokument an die Empfänger zu senden. Sind Sie sicher, dass Sie fortfahren möchten?"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -135,6 +135,14 @@ msgstr "Approver"
|
|||||||
msgid "Approving"
|
msgid "Approving"
|
||||||
msgstr "Approving"
|
msgstr "Approving"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:276
|
||||||
|
msgid "Black"
|
||||||
|
msgstr "Black"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:290
|
||||||
|
msgid "Blue"
|
||||||
|
msgstr "Blue"
|
||||||
|
|
||||||
#: packages/ui/primitives/document-flow/field-item-advanced-settings.tsx:297
|
#: packages/ui/primitives/document-flow/field-item-advanced-settings.tsx:297
|
||||||
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:58
|
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:58
|
||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
@@ -174,7 +182,7 @@ msgstr "Checkbox values"
|
|||||||
msgid "Clear filters"
|
msgid "Clear filters"
|
||||||
msgstr "Clear filters"
|
msgstr "Clear filters"
|
||||||
|
|
||||||
#: packages/ui/primitives/signature-pad/signature-pad.tsx:256
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:310
|
||||||
msgid "Clear Signature"
|
msgid "Clear Signature"
|
||||||
msgstr "Clear Signature"
|
msgstr "Clear Signature"
|
||||||
|
|
||||||
@@ -307,6 +315,10 @@ msgstr "Global recipient action authentication"
|
|||||||
msgid "Go Back"
|
msgid "Go Back"
|
||||||
msgstr "Go Back"
|
msgstr "Go Back"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:297
|
||||||
|
msgid "Green"
|
||||||
|
msgstr "Green"
|
||||||
|
|
||||||
#: packages/lib/constants/recipient-roles.ts:72
|
#: packages/lib/constants/recipient-roles.ts:72
|
||||||
msgid "I am a signer of this document"
|
msgid "I am a signer of this document"
|
||||||
msgstr "I am a signer of this document"
|
msgstr "I am a signer of this document"
|
||||||
@@ -472,6 +484,10 @@ msgstr "Receives copy"
|
|||||||
msgid "Recipient action authentication"
|
msgid "Recipient action authentication"
|
||||||
msgstr "Recipient action authentication"
|
msgstr "Recipient action authentication"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:283
|
||||||
|
msgid "Red"
|
||||||
|
msgstr "Red"
|
||||||
|
|
||||||
#: packages/ui/primitives/document-flow/add-settings.tsx:298
|
#: packages/ui/primitives/document-flow/add-settings.tsx:298
|
||||||
#: packages/ui/primitives/template-flow/add-template-settings.tsx:332
|
#: packages/ui/primitives/template-flow/add-template-settings.tsx:332
|
||||||
msgid "Redirect URL"
|
msgid "Redirect URL"
|
||||||
@@ -728,6 +744,10 @@ msgstr "Viewer"
|
|||||||
msgid "Viewing"
|
msgid "Viewing"
|
||||||
msgstr "Viewing"
|
msgstr "Viewing"
|
||||||
|
|
||||||
|
#: packages/ui/primitives/signature-pad/signature-pad.tsx:280
|
||||||
|
#~ msgid "White"
|
||||||
|
#~ msgstr "White"
|
||||||
|
|
||||||
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:44
|
#: packages/ui/primitives/document-flow/send-document-action-dialog.tsx:44
|
||||||
msgid "You are about to send this document to the recipients. Are you sure you want to continue?"
|
msgid "You are about to send this document to the recipients. Are you sure you want to continue?"
|
||||||
msgstr "You are about to send this document to the recipients. Are you sure you want to continue?"
|
msgstr "You are about to send this document to the recipients. Are you sure you want to continue?"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -9,6 +9,13 @@ import type { StrokeOptions } from 'perfect-freehand';
|
|||||||
import { getStroke } from 'perfect-freehand';
|
import { getStroke } from 'perfect-freehand';
|
||||||
|
|
||||||
import { unsafe_useEffectOnce } from '@documenso/lib/client-only/hooks/use-effect-once';
|
import { unsafe_useEffectOnce } from '@documenso/lib/client-only/hooks/use-effect-once';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@documenso/ui/primitives/select';
|
||||||
|
|
||||||
import { cn } from '../../lib/utils';
|
import { cn } from '../../lib/utils';
|
||||||
import { getSvgPathFromStroke } from './helper';
|
import { getSvgPathFromStroke } from './helper';
|
||||||
@@ -36,6 +43,7 @@ export const SignaturePad = ({
|
|||||||
const [isPressed, setIsPressed] = useState(false);
|
const [isPressed, setIsPressed] = useState(false);
|
||||||
const [lines, setLines] = useState<Point[][]>([]);
|
const [lines, setLines] = useState<Point[][]>([]);
|
||||||
const [currentLine, setCurrentLine] = useState<Point[]>([]);
|
const [currentLine, setCurrentLine] = useState<Point[]>([]);
|
||||||
|
const [selectedColor, setSelectedColor] = useState('black');
|
||||||
|
|
||||||
const perfectFreehandOptions = useMemo(() => {
|
const perfectFreehandOptions = useMemo(() => {
|
||||||
const size = $el.current ? Math.min($el.current.height, $el.current.width) * 0.03 : 10;
|
const size = $el.current ? Math.min($el.current.height, $el.current.width) * 0.03 : 10;
|
||||||
@@ -85,6 +93,7 @@ export const SignaturePad = ({
|
|||||||
ctx.restore();
|
ctx.restore();
|
||||||
ctx.imageSmoothingEnabled = true;
|
ctx.imageSmoothingEnabled = true;
|
||||||
ctx.imageSmoothingQuality = 'high';
|
ctx.imageSmoothingQuality = 'high';
|
||||||
|
ctx.fillStyle = selectedColor;
|
||||||
|
|
||||||
lines.forEach((line) => {
|
lines.forEach((line) => {
|
||||||
const pathData = new Path2D(
|
const pathData = new Path2D(
|
||||||
@@ -129,6 +138,7 @@ export const SignaturePad = ({
|
|||||||
|
|
||||||
ctx.imageSmoothingEnabled = true;
|
ctx.imageSmoothingEnabled = true;
|
||||||
ctx.imageSmoothingQuality = 'high';
|
ctx.imageSmoothingQuality = 'high';
|
||||||
|
ctx.fillStyle = selectedColor;
|
||||||
|
|
||||||
newLines.forEach((line) => {
|
newLines.forEach((line) => {
|
||||||
const pathData = new Path2D(
|
const pathData = new Path2D(
|
||||||
@@ -237,7 +247,13 @@ export const SignaturePad = ({
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
ref={$el}
|
ref={$el}
|
||||||
className={cn('relative block dark:invert', className)}
|
className={cn(
|
||||||
|
'relative block',
|
||||||
|
{
|
||||||
|
'dark:hue-rotate-180 dark:invert': selectedColor === 'black',
|
||||||
|
},
|
||||||
|
className,
|
||||||
|
)}
|
||||||
style={{ touchAction: 'none' }}
|
style={{ touchAction: 'none' }}
|
||||||
onPointerMove={(event) => onMouseMove(event)}
|
onPointerMove={(event) => onMouseMove(event)}
|
||||||
onPointerDown={(event) => onMouseDown(event)}
|
onPointerDown={(event) => onMouseDown(event)}
|
||||||
@@ -247,6 +263,44 @@ export const SignaturePad = ({
|
|||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div className="text-foreground absolute right-2 top-2 filter">
|
||||||
|
<Select defaultValue={selectedColor} onValueChange={(value) => setSelectedColor(value)}>
|
||||||
|
<SelectTrigger className="h-auto w-auto border-none p-1">
|
||||||
|
<SelectValue placeholder="" />
|
||||||
|
</SelectTrigger>
|
||||||
|
|
||||||
|
<SelectContent className="w-[150px]" align="end">
|
||||||
|
<SelectItem value="black">
|
||||||
|
<div className="text-muted-foreground flex items-center px-1 text-sm">
|
||||||
|
<div className="border-border mr-2 h-5 w-5 rounded-full border-2 bg-black shadow-sm" />
|
||||||
|
<Trans>Black</Trans>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
|
||||||
|
<SelectItem value="red">
|
||||||
|
<div className="text-muted-foreground flex items-center px-1 text-sm">
|
||||||
|
<div className="border-border mr-2 h-5 w-5 rounded-full border-2 bg-[red] shadow-sm" />
|
||||||
|
<Trans>Red</Trans>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
|
||||||
|
<SelectItem value="blue">
|
||||||
|
<div className="text-muted-foreground flex items-center px-1 text-sm">
|
||||||
|
<div className="border-border mr-2 h-5 w-5 rounded-full border-2 bg-[blue] shadow-sm" />
|
||||||
|
<Trans>Blue</Trans>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
|
||||||
|
<SelectItem value="green">
|
||||||
|
<div className="text-muted-foreground flex items-center px-1 text-sm">
|
||||||
|
<div className="border-border mr-2 h-5 w-5 rounded-full border-2 bg-[green] shadow-sm" />
|
||||||
|
<Trans>Green</Trans>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="absolute bottom-4 right-4 flex gap-2">
|
<div className="absolute bottom-4 right-4 flex gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in New Issue
Block a user