Skip to content

How can I map a responsive prop to a specific PropertyValue #905

Answered by panoskouff
panoskouff asked this question in Q&A
Discussion options

You must be logged in to vote

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
  <st…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by panoskouff
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants