Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
flo-bit committed Feb 14, 2024
0 parents commit c52f6b3
Show file tree
Hide file tree
Showing 40 changed files with 4,856 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
31 changes: 31 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};
51 changes: 51 additions & 0 deletions .github/workflows/deploy_gh_pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- gh-deploy

jobs:
build_site:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- name: Install dependencies
run: npm install

- name: build
env:
BASE_PATH: '/${{ github.event.repository.name }}'
run: |
npm run build
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v2
with:
# this should match the `pages` option in your adapter-static options
path: 'build/'

deploy:
needs: build_site
runs-on: ubuntu-latest

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v2
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# svelte-swiper-cards

Tinder-like swipeable cards for svelte.

> [!NOTE]
> In active development. Not ready for production.
## Features

- Built with tailwind
- Reuses cards (only two cards, that are swapped)
- Customizable (customize the card)
- Modern: uses @use-gesture/vanilla for gesture handling
- TypeScript

## Installation

- Copy `CardSwiper` folder from `src/libs` to your projects `lib` folder.

- Install dependency

```bash
npm i @use-gesture/vanilla
```

## Usage

```svelte
<script>
import { CardSwiper } from '$lib/CardSwiper';
</script>
<div class="h-screen w-screen">
<CardSwiper
cardData={(index) => {
return {
title: 'Card ' + index,
description: 'Description ' + index
};
}}
/>
</div>
```

### Customize

Customize the `Card.svelte` file to your needs, if you need to pass in more data to your card, edit the `CardData` type in `CardSwiper/index.ts` (and add the prop to `Card.svelte`).

### Programmatic control

You can control the cards programmatically by calling the swipe function.

```svelte
<script>
import { CardSwiper } from '$lib/CardSwiper';
let swipe: (direction?: 'left' | 'right') => void;
</script>
<div class="h-screen w-screen">
<CardSwiper
cardData={(index) => {
return {
title: 'Card ' + index,
description: 'Description ' + index
};
}}
bind:swipe
/>
<button on:click={() => swipe('left')}>Swipe left</button>
<button on:click={() => swipe('right')}>Swipe right</button>
</div>
```

## Todo

- Events
- Examples
- Refactor
- Testing on multiple devices
- Show optional overlay on cards when swiping

## License

MIT
Loading

0 comments on commit c52f6b3

Please sign in to comment.