Skip to content

Commit a720c6c

Browse files
committed
Button Update
*Added an option to select button type *Added an option to change the size of the button *Added an option to enable button quiet variants
1 parent d3a56e7 commit a720c6c

4 files changed

Lines changed: 132 additions & 35 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Budibase-Signature-Plugin",
3-
"version": "1.2.10",
3+
"version": "1.2.11",
44
"description": "A plugin that allows signatures to be created and saved in budibase",
55
"license": "MIT",
66
"svelte": "index.js",

schema.json

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@
124124
"type": "boolean",
125125
"key": "showClearSignatureButton",
126126
"label": "Show Clear Signature Button",
127-
"defaultValue": true
127+
"barTitle": "Show Clear Signature Button",
128+
"defaultValue": true,
129+
"showInBar": true,
130+
"barIcon": "Button"
128131
},
129132
{
130133
"type": "boolean",
@@ -136,6 +139,78 @@
136139
"value": true
137140
}
138141
},
142+
{
143+
"type": "select",
144+
"label": "Button Variant",
145+
"key": "buttonType",
146+
"showInBar": true,
147+
"barTitle": "Button Variant",
148+
"options": [
149+
{
150+
"label": "Primary",
151+
"value": 0
152+
},
153+
{
154+
"label": "Secondary",
155+
"value": 1
156+
},
157+
{
158+
"label": "Action",
159+
"value": 2
160+
},
161+
{
162+
"label": "Warning",
163+
"value": 3
164+
},
165+
{
166+
"label": "Over background",
167+
"value": 4
168+
}
169+
],
170+
"defaultValue": 0,
171+
"dependsOn": {
172+
"setting": "showClearSignatureButton",
173+
"value": true
174+
}
175+
},
176+
{
177+
"type": "select",
178+
"label": "Button Size",
179+
"key": "buttonSize",
180+
"showInBar": true,
181+
"options": [
182+
{
183+
"label": "Small",
184+
"value": "S"
185+
},
186+
{
187+
"label": "Medium",
188+
"value": "M"
189+
},
190+
{
191+
"label": "Large",
192+
"value": "L"
193+
},
194+
{
195+
"label": "Extra large",
196+
"value": "XL"
197+
}
198+
],
199+
"defaultValue": "M",
200+
"dependsOn": {
201+
"setting": "showClearSignatureButton",
202+
"value": true
203+
}
204+
},
205+
{
206+
"type": "boolean",
207+
"label": "Button Quiet",
208+
"key": "buttonQuiet",
209+
"showInBar": true,
210+
"barIcon": "VisibilityOff",
211+
"barTitle": "Quiet button",
212+
"barSeparator": false
213+
},
139214
{
140215
"type": "text",
141216
"key": "clearSignatureButtonText",

src/Canvas.svelte

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
export let saveBackgroundColour = true
1313
export let setSignatureValue = () => {}
1414
export let showClearSignatureButton = true
15-
export let showButtonIcon = true
15+
export let buttonIcon = "Erase"
1616
export let clearSignatureButtonText = "Clear Signature"
1717
export let modalTitle = "Clear Signature"
1818
export let modalActionButtonText = "Clear"
@@ -21,7 +21,10 @@
2121
export let borderColor = "#000000"
2222
export let borderWidth = "1px"
2323
export let inBuilder = false
24-
24+
export let buttonStyle = [true, false, false, false, false]
25+
export let buttonSize = "M"
26+
export let buttonQuiet = false
27+
2528
let eraseSignatureModal
2629
let canvas
2730
let context
@@ -118,42 +121,28 @@
118121

119122
<svelte:window on:resize={handleSize} />
120123
{#if showClearSignatureButton}
121-
<div style="padding-right:8px;padding-bottom:8px;">
122-
{#if showButtonIcon}
123-
{#if !inBuilder}
124-
<Button icon="Erase" primary on:click={eraseSignatureModal.show}>
125-
{clearSignatureButtonText}
126-
</Button>
127-
{:else}
128-
<Button icon="Erase" primary>
129-
{clearSignatureButtonText}
130-
</Button>
131-
{/if}
132-
{:else}
124+
<div style="padding-right:8px;padding-bottom:8px;">
133125
{#if !inBuilder}
134-
<Button primary on:click={eraseSignatureModal.show}>
126+
<Button icon={buttonIcon} size={buttonSize} primary={buttonStyle[0]} secondary={buttonStyle[1]} cta={buttonStyle[2]} warning={buttonStyle[3]} overBackground={buttonStyle[4]} quiet={buttonQuiet} on:click={eraseSignatureModal.show}>
135127
{clearSignatureButtonText}
136128
</Button>
137-
{:else}
138-
<Button primary>
129+
<Modal bind:this={eraseSignatureModal}>
130+
<ModalContent
131+
title={modalTitle}
132+
confirmText={modalActionButtonText}
133+
onConfirm={clearCanvas}
134+
>
135+
<span
136+
>{modalBody}</span
137+
>
138+
</ModalContent>
139+
</Modal>
140+
{:else}
141+
<Button icon={buttonIcon} size={buttonSize} primary={buttonStyle[0]} secondary={buttonStyle[1]} cta={buttonStyle[2]} warning={buttonStyle[3]} overBackground={buttonStyle[4]} quiet={buttonQuiet}>
139142
{clearSignatureButtonText}
140143
</Button>
141144
{/if}
142-
{/if}
143-
{#if !inBuilder}
144-
<Modal bind:this={eraseSignatureModal}>
145-
<ModalContent
146-
title={modalTitle}
147-
confirmText={modalActionButtonText}
148-
onConfirm={clearCanvas}
149-
>
150-
<span
151-
>{modalBody}</span
152-
>
153-
</ModalContent>
154-
</Modal>
155-
{/if}
156-
</div>
145+
</div>
157146
{/if}
158147
<canvas style="outline-style: {borderOutline}; outline-color: {borderColor}; outline-width: {borderWidth}"
159148
{width}

src/Component.svelte

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@
2323
export let signatureData
2424
export let validation
2525
export let tooltip = ""
26+
export let buttonType
27+
export let buttonSize
28+
export let buttonQuiet
2629
2730
let initalImage
2831
let currentImage
2932
33+
let buttonStyle = []
34+
let buttonIcon
35+
3036
let canBeDisplayed
3137
let errorMessages = [];
3238
@@ -121,7 +127,31 @@ $: formField = formApi?.registerField(
121127
if (($builderStore.inBuilder)){
122128
inBuilder = true;
123129
}
130+
131+
$: setupButtonType(buttonType)
132+
133+
function setupButtonType(buttonType){
134+
buttonStyle = []
135+
for (let i = 0; i < 5; i++){
136+
if (buttonType === i){
137+
buttonStyle.push(true)
138+
} else {
139+
buttonStyle.push(false)
140+
}
141+
}
142+
}
143+
144+
$: buttonIconSetup(showButtonIcon)
145+
146+
function buttonIconSetup(showButtonIcon){
147+
if (showButtonIcon){
148+
buttonIcon = "Erase"
149+
} else {
150+
buttonIcon = ""
151+
}
152+
}
124153
</script>
154+
125155
<div class="spectrum-Form-item" class:above={labelPos === "above"} use:styleable={$component.styles}>
126156
{#if !canBeDisplayed}
127157
<!-- Display error messages when requirements are not defined -->
@@ -153,7 +183,7 @@ $: formField = formApi?.registerField(
153183
{penWidth}
154184
{saveBackgroundColour}
155185
{showClearSignatureButton}
156-
{showButtonIcon}
186+
{buttonIcon}
157187
{clearSignatureButtonText}
158188
{setSignatureValue}
159189
{modalTitle}
@@ -163,6 +193,9 @@ $: formField = formApi?.registerField(
163193
{borderColor}
164194
{borderWidth}
165195
{inBuilder}
196+
{buttonStyle}
197+
{buttonSize}
198+
{buttonQuiet}
166199
>
167200
</Canvas>
168201

0 commit comments

Comments
 (0)