-
-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Please see the first comment under this issue for more accurate issue status.
What:
I suggest that useResponsiveValue hook respected the behavior system used in responsive props. This means that a breakpoint without an explicit behavior implies the default one (i.e. "up"). Breakpoints (properties) accept an explicit behavior that changes the way their values are applied.
import { useResponsiveValue } from 'atomic-layout'
const Component = () => {
const data = useResponsiveValue({
sm: 2,
lg: 3,
})
return <p>{data}</p>
}The example above would assign the following values:
xs - undefined
sm - 2
md - 2 (stretches, since "sm" has no behavior, which implies the default "up")
lg - 3 (explicit override)
xl - 3 (stretches similarly to "md")
Why:
Current implementation of useResponsiveValue treats all properties as with "only" behavior. This makes it hard for a value to persist between breakpoints and requires to repeat it.
import { useResponsiveValue } from 'atomic-layout'
const Component = () => {
const data = useResponsiveValue({
md: 2,
lg: 2,
})
return <p>{data}</p>
}Using the second parameter of defaultValue doesn't help, because it's assign on any matches outside of the given breakpoint names. It's generally meant for a different behavior.