How can I map a responsive prop to a specific PropertyValue #905
-
example:
in the component above I have a new prop I would like to have something like below so I can do this independently per break point example:
How can I create something like obviously you can't get the breakpoint like this |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
nvm I guess the simplest thing would be to do this
and then you could just do (the difference doing it this way is you dont pass a boolean, but the condition and the value per condition which is less opinionated but more flexible)
|
Beta Was this translation helpful? Give feedback.
-
actually this is closer to what I'm looking for import { styled } from '../panda-css-gen/jsx';
import { HTMLStyledProps } from '../panda-css-gen/jsx';
import { PropertyValue } from '../panda-css-gen/types/prop-type';
// Restrict/rename properties
type PositionedProps = {
mode: PropertyValue<'position'>;
children?: React.ReactNode;
} & Pick<HTMLStyledProps<'div'>,
'top' | 'right' | 'bottom' | 'left' | 'inset'
> &
React.HTMLAttributes<HTMLDivElement>;
export const Positioned: React.FC<PositionedProps> = ({
// default values for properties
children,
mode = 'absolute',
inset = 0,
...rest
}) => (
// pass default/renamed and rest properties to panda styled component
<styled.div position={mode} inset={inset} {...rest}>
{children}
</styled.div>
); |
Beta Was this translation helpful? Give feedback.
-
For anyone in the futer |
Beta Was this translation helpful? Give feedback.
actually this is closer to what I'm looking for