Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fork] Add missing props noResults, noMore, error & a new one errorButton #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ jobs:

- name: Publish 🚀
if: steps.check.outputs.changed == 'true'
run: npm publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-infinite-loading",
"version": "1.3.8",
"name": "@cokejoke/svelte-infinite-loading",
"version": "1.3.9",
"description": "An infinite scroll component for Svelte apps",
"svelte": "src/index.js",
"main": "dist/svelte-infinite-loading.js",
Expand Down Expand Up @@ -41,17 +41,17 @@
"svelte-components"
],
"author": {
"name": "Skayo",
"name": "cokejoke",
"email": "[email protected]",
"url": "https://skayo.dev"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/Skayo/svelte-infinite-loading.git"
"url": "git+https://github.com/cokejoke/svelte-infinite-loading.git"
},
"bugs": {
"url": "https://github.com/Skayo/svelte-infinite-loading/issues"
"url": "https://github.com/cokejoke/svelte-infinite-loading/issues"
},
"homepage": "https://github.com/Skayo/svelte-infinite-loading"
"homepage": "https://github.com/cokejoke/svelte-infinite-loading"
}
16 changes: 12 additions & 4 deletions src/InfiniteLoading.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@
export let forceUseInfiniteWrapper = false;
export let identifier = +new Date();

/**
* Slot props
*/
export let noResults = 'No results :(';
export let noMore = 'No more data :)';
export let error = 'Oops, something went wrong :(';
export let errorButton = 'Retry';

let isFirstLoad = true; // save the current loading whether it is the first loading
let status = STATUS.READY;
let mounted = false;
Expand Down Expand Up @@ -334,26 +342,26 @@
{#if showNoResults}
<div class="infinite-status-prompt">
<slot name="noResults">
No results :(
{noResults}
</slot>
</div>
{/if}

{#if showNoMore}
<div class="infinite-status-prompt">
<slot name="noMore">
No more data :)
{noMore}
</slot>
</div>
{/if}

{#if showError}
<div class="infinite-status-prompt">
<slot name="error" {attemptLoad}>
Oops, something went wrong :(
{error}
<br>
<button class="btn-try-infinite" on:click={attemptLoad}>
Retry
{errorButton}
</button>
</slot>
</div>
Expand Down
11 changes: 8 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,23 @@ export interface InfiniteLoadingSlots {
* This message will be displayed when there is no data, which means that we have called the InfiniteEvent.details.complete
* method, before ever calling the InfiniteEvent.details.loaded method.
*/
noResults: {};
noResults: string;

/**
* This message will be displayed when there is no more data, which means we have called the InfiniteEvent.details.loaded
* method at least once before calling the InfiniteEvent.details.complete method.
*/
noMore: {};
noMore: string;

/**
* This message will be displayed when loading has failed, which means that we have called the InfiniteEvent.details.error method.
*/
error: { attemptLoad: () => void };
error: string;

/**
* This is a Part of the error message. It will change the button text, wich means that we have called the InfiniteEvent.details.error method.
*/
errorButton: string;

/**
* This slot will be displayed when loading data, you can also use your own spinner here.
Expand Down
Loading