Skip to content

Commit

Permalink
Merge pull request #5 from ghostdevv/retry
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdevv authored Nov 29, 2022
2 parents 109bfd9 + 80e550b commit fdec674
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ The only required prop is the `siteKey` which you can get from [adding a site he

## Props

| Prop | Type | Description | Required |
|--------------|----------------------------------------|----------------------------------------------------------------------------------------------|----------------------------------------------|
| `siteKey` | `string` | sitekey for your website ||
| `theme` | `'light' \| 'dark' \| 'auto'` | colour theme of the widget (defaults to `auto`) ||
| `size` | `'normal' \| 'compact'` | size of the widget (defaults to `normal`) ||
| `action` | `string` | A string that can be used to differentiate widgets, returned on validation ||
| `cData` | `string` | A string that can attach customer data to a challange, returned on validation ||
| `tabIndex` | `number` | Used for accessibility (defaults to `0`) ||
| `forms` | `boolean` | if true the response token will be a property on the form data (default `true`) ||
| `formsField` | `string` | the `name` of the input which will appear on the form data (default `cf-turnstile-response`) ||
| Prop | Type | Description | Required |
|-----------------|----------------------------------------|------------------------------------------------------------------------------------------------|----------|
| `siteKey` | `string` | sitekey for your website ||
| `theme` | `'light' \| 'dark' \| 'auto'` | colour theme of the widget (defaults to `auto`) ||
| `size` | `'normal' \| 'compact'` | size of the widget (defaults to `normal`) ||
| `action` | `string` | A string that can be used to differentiate widgets, returned on validation ||
| `cData` | `string` | A string that can attach customer data to a challange, returned on validation ||
| `tabIndex` | `number` | Used for accessibility (defaults to `0`) ||
| `forms` | `boolean` | if true the response token will be a property on the form data (default `true`) ||
| `formsField` | `string` | the `name` of the input which will appear on the form data (default `cf-turnstile-response`) ||
| `retry` | `'auto' \| 'never'` | should the widget automatically retry to obtain a token if it did not succeed (default `auto`) ||
| `retryInterval` | `number` | if `retry` is true, this controls the time between attempts in milliseconds (default `8000`) ||

For more information about some of the props [checkout the Cloudflare Documentation](https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/#configurations).

Expand Down
11 changes: 7 additions & 4 deletions src/lib/Turnstile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
size?: TurnstileSize;
'response-field'?: boolean;
'response-field-name'?: string;
'retry-interval'?: number;
retry?: TurnstileRetry;
}
export type TurnstileRetry = 'auto' | 'never';
export type TurnstileSize = 'normal' | 'compact';
export type TurnstileTheme = 'light' | 'dark' | 'auto';
</script>
Expand All @@ -57,6 +60,8 @@
export let formsField: string = 'cf-turnstile-response';
export let action: string | undefined = undefined;
export let cData: string | undefined = undefined;
export let retryInterval: number | undefined = 8000;
export let retry: TurnstileRetry = 'auto';
export let theme: TurnstileTheme = 'auto';
export let size: TurnstileSize = 'normal';
export let forms = true;
Expand All @@ -81,10 +86,6 @@
function expired() {
dispatch('turnstile-expired', {});
if (widgetId) {
window.turnstile.reset(widgetId);
}
}
function timeout() {
Expand All @@ -105,9 +106,11 @@
sitekey: siteKey,
'response-field-name': formsField,
'retry-interval': retryInterval,
'response-field': forms,
tabindex: tabIndex,
action,
retry,
theme,
cData,
size,
Expand Down

0 comments on commit fdec674

Please sign in to comment.