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

Responsive sizing? #203

Closed
notflip opened this issue May 11, 2023 · 6 comments
Closed

Responsive sizing? #203

notflip opened this issue May 11, 2023 · 6 comments
Labels
question Further information is requested

Comments

@notflip
Copy link

notflip commented May 11, 2023

Is your feature request related to a problem? Please describe.
This is more a discussion or question, but I'm wondering if responsive sizing is possible, so instead of a fixed "size" parameter, using percentage?

@notflip notflip added the enhancement New feature or request label May 11, 2023
@setaman setaman added question Further information is requested and removed enhancement New feature or request labels May 11, 2023
@setaman
Copy link
Owner

setaman commented May 11, 2023

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

@notflip
Copy link
Author

notflip commented May 11, 2023

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

@setaman
Copy link
Owner

setaman commented May 11, 2023

I'm glad it is useful

@setaman setaman closed this as completed May 11, 2023
@kalnode
Copy link

kalnode commented Jun 8, 2023

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

@notflip
Copy link
Author

notflip commented Jun 9, 2023

@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

@setaman
Copy link
Owner

setaman commented Jun 10, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants