mirror of
https://github.com/coder/coder.git
synced 2026-09-24 06:47:27 +08:00
28 lines
674 B
TypeScript
28 lines
674 B
TypeScript
import { makeStyles } from "@material-ui/core/styles"
|
|
import React from "react"
|
|
|
|
type Direction = "column" | "row"
|
|
|
|
interface StyleProps {
|
|
spacing: number
|
|
direction: Direction
|
|
}
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
stack: {
|
|
display: "flex",
|
|
flexDirection: ({ direction }: StyleProps) => direction,
|
|
gap: ({ spacing }: StyleProps) => theme.spacing(spacing),
|
|
},
|
|
}))
|
|
|
|
export interface StackProps {
|
|
spacing?: number
|
|
direction?: Direction
|
|
}
|
|
|
|
export const Stack: React.FC<StackProps> = ({ children, spacing = 2, direction = "column" }) => {
|
|
const styles = useStyles({ spacing, direction })
|
|
return <div className={styles.stack}>{children}</div>
|
|
}
|