Code Monkey home page Code Monkey logo

Comments (6)

notflip avatar notflip commented on August 17, 2024 1

@kalnode I used the following setup in Nuxt. (will work in Vue too). It's sort-of responsive, but with this composable I can set a size for each of the breakpoints in my app.

 <ve-progress
    :progress="99"
    :size="breakpoints.is === 'xs' ? 130 : 200"
>

<script>
const { breakpoints } = useBreakpoint()
</script>

The breakpoints composable is copied from somewhere

import { onMounted, reactive } from 'vue'

const screens = {
    xs: 320,
    sm: 640,
    md: 768,
    lg: 1024,
    xl: 1280
}

const breakpoints = reactive({ w: 0, h: 0, is: 'xs' })

const xs = (val) => val >= screens.xs && val < screens.sm
const sm = (val) => val >= screens.sm && val < screens.md
const md = (val) => val >= screens.md && val < screens.lg
const lg = (val) => val >= screens.lg && val < screens.xl
const xl = (val) => val >= screens.xl

const getBreakpoint = (w) => {
    if (xs(w)) return 'xs'
    else if (sm(w)) return 'sm'
    else if (md(w)) return 'md'
    else if (lg(w)) return 'lg'
    else if (xl(w)) return 'xl'
    else return 'all'
}

const setBreakpoint = () => {
    breakpoints.w = window.innerWidth
    breakpoints.h = window.innerHeight
    breakpoints.is = getBreakpoint(window.innerWidth)
}

const useBreakpoint = () => {
    onMounted(() => {
        setBreakpoint()
        window.addEventListener('resize', () => {
            setBreakpoint()
        })
    })

    return {
        breakpoints
    }
}

export default useBreakpoint

from vue-ellipse-progress.

setaman avatar setaman commented on August 17, 2024 1

This is a good "work around" @notflip, thanks for sharing. Probably the front end framework of your choice will already have similar composable, like useDisplay from Vuetify, or you could even use useBreakpoints provided by Vueuse.

@kalnode let me know if you find something

from vue-ellipse-progress.

setaman avatar setaman commented on August 17, 2024

At the moment, unfortunately, only fixed values work. The circumference is calculated based on different parameters (e.g. thickness of the line, the size of the dot, etc.). Relative size would make this calculation much more complex.

But I don't say that I exclude it completely. Maybe in the future I will give it a try, I also think that would be a useful feature

from vue-ellipse-progress.

notflip avatar notflip commented on August 17, 2024

@setaman That makes sense, I understand! Thanks for this plugin, I love it.

from vue-ellipse-progress.

setaman avatar setaman commented on August 17, 2024

I'm glad it is useful

from vue-ellipse-progress.

kalnode avatar kalnode commented on August 17, 2024

Not being responsive is the primary reason I'm looking elsewhere =(.

from vue-ellipse-progress.

Related Issues (20)

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.