Giter Site home page Giter Site logo

vaban-ru / vue-bottom-sheet Goto Github PK

View Code? Open in Web Editor NEW
200.0 2.0 41.0 694 KB

πŸ”₯ A nice clean and touch-friendly bottom sheet component based on Vue.js and Hammer.js for Vue 3

Home Page: https://bs.vaban.ru

License: MIT License

Vue 84.83% JavaScript 3.79% HTML 4.33% TypeScript 7.05%
vue vuejs bottom-sheet component

vue-bottom-sheet's Introduction

Example

Vue Bottom Sheet

Size Downloads Version

A nice clean and touch-friendly bottom sheet component based on Vue.js and hammer.js for Vue 3

Installation

NPM

npm install @webzlodimir/vue-bottom-sheet

Yarn

yarn add @webzlodimir/vue-bottom-sheet

Usage

<template>
  <vue-bottom-sheet ref="myBottomSheet">
    <h1>Lorem Ipsum</h1>
    <h2>What is Lorem Ipsum?</h2>
    <p>
      <strong>Lorem Ipsum</strong> is simply dummy text
    </p>
  </vue-bottom-sheet>
</template>

<script setup>
import VueBottomSheet from "@webzlodimir/vue-bottom-sheet";
import  "@webzlodimir/vue-bottom-sheet/dist/style.css";
import { ref } from "vue";

const myBottomSheet = ref(null)

const open = () => {
  myBottomSheet.value.open();
}

const close = () => {
  myBottomSheet.value.close();
}
</script>

Usage setup + TS

<template>
  <vue-bottom-sheet ref="myBottomSheet">
    <h1>Lorem Ipsum</h1>
    <h2>What is Lorem Ipsum?</h2>
    <p>
      <strong>Lorem Ipsum</strong> is simply dummy text
    </p>
  </vue-bottom-sheet>
</template>

<script setup lang="ts">
import VueBottomSheet from "@webzlodimir/vue-bottom-sheet";
import  "@webzlodimir/vue-bottom-sheet/dist/style.css";
import { ref } from "vue";

const myBottomSheet = ref<InstanceType<typeof VueBottomSheet>>()

const open = () => {
  myBottomSheet.value.open();
}

const close = () => {
  myBottomSheet.value.close();
}
</script>

Usage in Nuxt 3

For Nuxt 3, just wrap component in <client-only>

<template>
  <client-only>
    <vue-bottom-sheet ref="myBottomSheet">
      <h1>Lorem Ipsum</h1>
      <h2>What is Lorem Ipsum?</h2>
      <p>
        <strong>Lorem Ipsum</strong> is simply dummy text
      </p>
    </vue-bottom-sheet>
  </client-only>
</template>

Props

Prop Type Description Example Defaults
max-width Number Set max-width of component card in px :max-width="640" 640
max-height Number Sets the maximum height of the window, if not set it takes the height of the content :max-height="90" -
can-swipe Boolean Enable or disable swipe to close :can-swipe="false" true
overlay Boolean Enable overlay :overlay="false" true
overlay-color String Set overlay color with opacity overlay-color="#0000004D" #0000004D
overlay-click-close Boolean Close window on overlay click :overlay-click-close="false" true
transition-duration Number Transition animation duration :transition-duration="0.5" 0.5

Events

Event Description Example
opened Fire when card component is opened @opened=""
closed Fire when card component is closed @closed=""
dragging-up Fire while card component dragging up @dragging-up=""
dragging-down Fire while card component dragging down @dragging-down=""

Slots

You can use this named slots:

<template>
  <vue-bottom-sheet ref="myBottomSheet">
    <template #header>
      <h1>Lorem Ipsum</h1>
    </template>
    <template #default>
      <h2>What is Lorem Ipsum?</h2>
    </template>
    <template #footer>
      <p>
        <strong>Lorem Ipsum</strong> is simply dummy text
      </p>
    </template>
  </vue-bottom-sheet>
</template>

vue-bottom-sheet's People

Contributors

1dernir avatar alekseysychev avatar moehmeni avatar moradi-morteza avatar onedernir avatar remoove avatar vaban-ru avatar vad1ym avatar veguss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-bottom-sheet's Issues

Vue 3 update

First of all, i really love this package, it's awesome!
But now i'm using Vue 3 in my company. So, could we have an update to use this package in Vue 3?

Π”Π΅ΠΌΠΎ

ΠΠ°ΠΏΠΈΡΠ°Ρ‚ΡŒ ΠΈ Π²Ρ‹Π»ΠΎΠΆΠΈΡ‚ΡŒ Π΄Π΅ΠΌΠΎΠ½ΡΡ‚Ρ€Π°Ρ†ΠΈΠΎΠ½Π½ΡƒΡŽ Π²Π΅Ρ€ΡΠΈΡŽ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚Π° с Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒΡŽ ΠΏΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡Π°Ρ‚ΡŒ настройки.

window is not defined

<script setup>
import VueBottomSheet from "@webzlodimir/vue-bottom-sheet"

This triggers on Nuxt 3 after installation
image

Prop for closing

Right now we can only choose to open / close the bottom sheet entirely. It will be nice if there's a way for me to pass a prop for close=false so that it remains at the initial height that i set (#39)

Π‘ΠΎΠ±Ρ‹Ρ‚ΠΈΠ΅ закрытия

ΠŸΡ€ΠΈΠ²Π΅Ρ‚!
Бпасибо Π²Π°ΠΌ Π·Π° прСкрасный ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚!
Π•ΡΡ‚ΡŒ ΠΎΠ΄Π½Π° ΡΠ»ΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ с Π΅Π³ΠΎ использованиСм, Π½Π΅Ρ‚ возмоТности ΡΠ»Π΅Π΄ΠΈΡ‚ΡŒ Π·Π° Π·Π°ΠΊΡ€Ρ‹Ρ‚ΠΈΠ΅ΠΌ модального ΠΎΠΊΠ½Π° (Π±ΡƒΠ΄ΡŒ Ρ‚ΠΎ свайп ΠΈΠ»ΠΈ ΠΊΠ»ΠΈΠΊ Π²Π½Π΅ ΠΎΠΊΠ½Π°).
Как Π²Π°Ρ€ΠΈΠ°Π½Ρ‚, ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ²Π΅ΡΠΈΡ‚ΡŒ event, Ρ‡Ρ‚ΠΎ-Π½ΠΈΠ±ΡƒΠ΄ΡŒ Π²Ρ€ΠΎΠ΄Π΅ @closed="method"

Prop for bottom sheet styling / color

Right now it is default to white and has no shadow, but i would like to customize the bottom sheet so that it still looks good on white backgrounds without an overlay.

Here's an example without the prop at the moment on light mode.

CleanShot 2023-08-12 at 00 37 38@2x

It would look better if i can set it to a another color or add a shadow to the top border

CleanShot 2023-08-12 at 00 45 28@2x

Prop for initial height

Right now we have a prop for maxHeight, but it will be nice if this component has props which are similar to native bottom sheet component or a simple prop for setting initial height in addition to the max height.

For example, i would like the bottom sheet to start off short first at 90px, then users can drag it to a max height of 80% of the viewport height.

Initial height

CleanShot 2023-08-12 at 00 50 18@2x

Max height

CleanShot 2023-08-12 at 00 51 47@2x

Анимация появлСния

Π‘Π΄Π΅Π»Π°Ρ‚ΡŒ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ Π²Ρ‹Π±ΠΈΡ€Π°Ρ‚ΡŒ ΠΈΠ· прСдустановлСнных Π·Π½Π°Ρ‡Π΅Π½ΠΈΠΉ Ρ€Π°Π·Π»ΠΈΡ‡Π½Ρ‹Π΅ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ Π°Π½ΠΈΠΌΠ°Ρ†ΠΈΠΉ появлСния

Dragging behaviour

iPhone XS
iOS 14.4
Chrome OS

Expected Behaviour:
Opening the bottom sheet, I expect to be able to drag its vertical position with my finger.

Actutal Behaviour
However, I can only drag the sheet downwards. Dragging it upwards stops the dragging, probably because the dragging event is not fired outside the bottom sheet?

Possible Improvement
Fire the dragging event on the surrounding container aswell.

Full screen

how to full screen mode on panup, and scrollable content?

TypeError: Cannot read properties of undefined (reading 'clientHeight')

I got blocker error from this library, it said as follow

TypeError: Cannot read properties of undefined (reading 'clientHeight')

Screen Shot 2023-07-02 at 18 32 17

My code is simple, there is no complex properties that i used

<vue-bottom-sheet ref="myBottomSheet">
    <div class="form p-4 text-left">
        <h3 class="text-sm font-semibold">No. {{ detailLegend.position }} | {{ detailLegend.arrow }} : {{ detailLegend.clue }}</h3>
        <input v-model="myAnswer" type="text" class="input" placeholder="Ketik jawaban">
        <button @click="submitAnswer" class="button is-success">Kirim</button>
        <button class="button" @click="myBottomSheet.close()">Tutup</button>
    </div>
</vue-bottom-sheet>

setup(props, { emit }){

        const myBottomSheet = ref(null)

    return {
     myBottomSheet
   }
}

Please help me!

ДокумСнтация

ΠŸΠ΅Ρ€Π΅Π²Π΅ΡΡ‚ΠΈ README Π½Π° английский, Π° Ρ‚Π°ΠΊΠΆΠ΅ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Ρ‚Π°ΠΌ ссылку Π½Π° Ρ€ΡƒΡΡΠΊΡƒΡŽ Π²Π΅Ρ€ΡΠΈΡŽ README

Minimum height limit to not close the component completely

Is it possible to make the bottom sheet component completely non-closable? For example through a single height property? The `max-height' property displays the component without exceeding a certain limit (size). In parallel, does it also have a minimum height property?

I just want to make this component visible at least slightly when users swipe down in my app. Or is there another way to do it?

Thanks in advance for the answer!

hint for component

It would be great if they added the onScroll event to the component to be able to perform an infinity scroll like tiktok, instagram and many others have

First time opening

It seems that for the first time, instead of going up, only the opacity changes

Example is wrong

The correct import while using TypeScript is

import VueBottomSheet from "@webzlodimir/vue-bottom-sheet/dist";

instead of

import VueBottomSheet from "@webzlodimir/vue-bottom-sheet";

Please fix package.json to use let typescript detect the types declaration file

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.