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

Grid #83

Open
synuns opened this issue Jan 7, 2025 · 0 comments
Open

Grid #83

synuns opened this issue Jan 7, 2025 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@synuns
Copy link
Member

synuns commented Jan 7, 2025

Component Function Definition

Core Features:

  • Full CSS Grid system implementation as a React component
  • Complete support for CSS Grid properties
  • Flexible grid template configuration
  • Grid item placement and sizing control

Design Requirements

Grid Container

  • Default display: display: grid
  • Support for all CSS Grid container properties
  • Custom grid areas support

Grid Items

  • Full control over item placement
  • Area-based positioning
  • Size configuration

Component Specifications

interface GridProps extends ComponentProps<'div'> {
  templateColumns?: CSSProperties['gridTemplateColumns'];
  templateRows?: CSSProperties['gridTemplateRows'];
  templateAreas?: CSSProperties['gridTemplateAreas'];
  gap?: CSSProperties['gap'];
  autoFlow?: CSSProperties['gridAutoFlow'];
  autoRows?: CSSProperties['gridAutoRows'];
  autoColumns?: CSSProperties['gridAutoColumns'];
  inline?: boolean;
  style?: CSSProperties;
  asChild?: boolean;
}

interface GridItemProps extends ComponentProps<'div'> {
  column?: CSSProperties['gridColumn'];
  row?: CSSProperties['gridRow'];
  area?: CSSProperties['gridArea'];
  justifySelf?: CSSProperties['justifySelf'];
  alignSelf?: CSSProperties['alignSelf'];
  colSpan?: number;
  rowSpan?: number;
  colStart?: number | 'auto';
  colEnd?: number | 'auto';
  rowStart?: number | 'auto';
  rowEnd?: number | 'auto';
  style?: CSSProperties;
  asChild?: boolean;
}

Usage Examples

// Template Areas Example
<Grid.Root
  templateAreas={`
    "header header header"
    "sidebar main main"
    "footer footer footer"
  `}
  templateColumns="200px 1fr"
  gap="1rem"
>
  <Grid.Item area="header">
    <Box>Header</Box>
  </Grid.Item>
  <Grid.Item area="sidebar">
    <Box>Sidebar</Box>
  </Grid.Item>
  <Grid.Item area="main">
    <Box>Main</Box>
  </Grid.Item>
  <Grid.Item area="footer">
    <Box>Footer</Box>
  </Grid.Item>
</Grid.Root>

// Spanning Example
<Grid.Root
  templateColumns="repeat(4, 1fr)"
  templateRows="repeat(2, 1fr)"
  gap="1rem"
>
  <Grid.Item rowSpan={2}>
    <Box>rowSpan 2</Box>
  </Grid.Item>
  <Grid.Item colSpan={2}>
    <Box>colSpan 2</Box>
  </Grid.Item>
</Grid.Root>

Technical Considerations

  1. CSS Module Integration
  • CSS Variable-based styling system
  • Conditional class application
  • Modular style structure
  1. Type Safety
  • Full TypeScript support
  • React.ForwardRef implementation
  • Comprehensive prop interfaces
  1. Testing Strategy
  • Component rendering tests
  • Style application tests
  • Polymorphic behavior tests

Reference Materials

Additional Discussion Points

  • Consider adding validation for grid template areas syntax
  • Evaluate the need for shorthand property support
  • Support responsive
@synuns synuns added the documentation Improvements or additions to documentation label Jan 7, 2025
@synuns synuns self-assigned this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant