An open API service indexing awesome lists of open source software.

https://github.com/snuffydev/svelte-flatlist

A draggable, customizable, mobile-friendly menu that's simple and easy to use.
https://github.com/snuffydev/svelte-flatlist

draggable drawer flatlist menu mobile svelte svelte-component svelte-components sveltejs

Last synced: 5 months ago
JSON representation

A draggable, customizable, mobile-friendly menu that's simple and easy to use.

Awesome Lists containing this project

README

        

# Svelte FlatList

A mobile-friendly, simple, and customizable draggable menu.

**Documentation / Demo site**: https://svelte-flatlist.netlify.app/

[Find me on NPM!](https://www.npmjs.com/package/svelte-flatlist)

## Demo

[Demo/Docs](https://svelte-flatlist.netlify.app/)
[REPL](https://svelte.dev/repl/b1b6b42ca4c944ca99f0063d5ca1ccdb?version=3.44.2)

### Installation

`npm install -D svelte-flatlist`

# Usage

Using Svelte FlatList is very simple. Below are some usage examples.

## Each Block

_See this in action at the Svelte REPL!_
[Link](https://svelte.dev/repl/2cfb8d8b8ff2447688874a2e0dacb731?version=3.44.2)

```html

import FlatList from 'svelte-flatlist';
let visible;
const items = [0,1,2,3,4,5];

function handleClose(){
visible = false;
}

(visible=true)}>
Click me!

{#each items as item}
{item}
{/each}

```

## Customize the theme

_See this in action at the Svelte REPL!_
[Link](https://svelte.dev/repl/dbe96ccc7e974dee80ce57a45d17ae2e?version=3.44.2)

```html

import FlatList from 'svelte-flatlist';
let visible;
const items = [0,1,2,3,4,5];

function handleClose(){
visible = false;
}

(visible=true)}>
Click me!

item 1
item 2
item 3
item 4
item 5

```

## Manually list items

_See this in action at the Svelte REPL!_
[Link](https://svelte.dev/repl/dbe96ccc7e974dee80ce57a45d17ae2e?version=3)

```html

import FlatList from 'svelte-flatlist';

let visible;
function handleClose(){
visible = false;
}

(visible=true)}>
Click me!

item 1
item 2
item 3
item 4

```

## Props

| Prop | Description |
| -------- | --------------------------------------------------------------------------- |
| visible | (REQUIRED) visibility state |
| style | (See below for options) Customize the colors to fit your needs. |
| zIndex | Same as CSS z-index (defaults to 9999) |
| position | Position of the list on screen (defaults to 'center') |
| duration | Duration of the opening & closing transition (defaults to 400) |
| maxWidth | Maximum width of the list - must include a CSS unit (defaults to 640px) |
| gap | Gap in between list items - must include a CSS unit (defaults to 0.8rem) |
| overflow | Behavior for vertical overflow, same as CSS overflow-y (defaults to 'auto') |

## Style Properties

Svelte-Flatlist allows you to modify the styles to fit your needs best using `style` prop.

Example:

```html

```

### ```style``` Type

The type of the ```style``` prop:

```typescript
type ListStyle = {
bgColor?: string;
handle?: HandleStyle;
};

type HandleStyle = {
bgColor?: string;
fgColor?: string;
height?: string;
};
```

### More Info

| Style Props | Description |
| ----------- | ---------------------------------------------------- |
| bgColor | Base background color |
| handle | (see below for options) Color options for the handle |


| Handle Properties | Description |
| ----------------- | -------------------------- |
| bgColor | Handle background color |
| fgColor | Handle foreground color |
| height | Handle height (ex: '5rem') |

## Events

| Event | Description |
| ----- | ------------------------------- |
| close | Event fires when list is closed |

## Events

| Event | Description |
| ----- | ------------------------------- |
| close | Event fires when list is closed |