Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 412 additions & 0 deletions docs/docs/components/flex.mdx

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/vanilla-extract-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"preview": "vite preview"
},
"dependencies": {
"@hover-design/react": "*",
"@vanilla-extract/css": "^1.6.8",
"@vanilla-extract/vite-plugin": "^3.1.2",
"polished": "^4.1.3",
Expand Down
42 changes: 42 additions & 0 deletions lib/src/components/Flex/Flex.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { ForwardRefRenderFunction } from "react";
import { FlexProps } from "./flex.types";
import { assignInlineVars } from "@vanilla-extract/dynamic";

export const FlexComponent:ForwardRefRenderFunction<HTMLDivElement, FlexProps> = ({
alignContent = 'normal',
alignItems = 'flex-start',
flexDirection = 'row',
flexWrap = 'nowrap',
justifyContent = 'normal',
flexShrink = '1',
flexGrow = '0',
flexBasis = 'auto',
gap = 'normal',
children,
style,
...nativeProps
}, ref) => {
const flexStyles = assignInlineVars({
display: 'flex',
alignContent,
alignItems,
flexDirection,
flexWrap,
justifyContent,
flexShrink: flexShrink.toString(),
flexGrow: flexGrow.toString(),
flexBasis: flexBasis.toString(),
gap: gap.toString()
});
/**
* If user passes style object it will merge with current style
*/
Object.assign(flexStyles, style);

return (
<div style={flexStyles} {...nativeProps} ref={ref}> {children} </div>
)
};

const FlexWithRef = React.forwardRef(FlexComponent);
export { FlexWithRef as Flex };
12 changes: 12 additions & 0 deletions lib/src/components/Flex/flex.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface FlexProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
{
alignContent?: React.CSSProperties['alignContent'],
alignItems?: React.CSSProperties['alignItems'],
flexDirection?: React.CSSProperties['flexDirection'],
flexWrap?: React.CSSProperties['flexWrap'],
justifyContent?: React.CSSProperties['justifyContent'],
flexShrink?: React.CSSProperties['flexShrink'],
flexGrow?: React.CSSProperties['flexGrow'],
flexBasis?: React.CSSProperties['flexBasis'],
gap?:React.CSSProperties['gap'],
}
1 change: 1 addition & 0 deletions lib/src/components/Flex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Flex";
7 changes: 4 additions & 3 deletions lib/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export * from "./components/Badge";
export * from "./components/Button";
export * from "./components/Card";
export * from "./components/reset";
export * from "./components/Switch";
export * from "./components/Badge";
export * from "./components/Flex";
export * from "./components/List";
export * from "./components/ListItem";
export * from "./components/reset";
export * from "./components/Switch";
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[build]
publish = "./build"
command = "( pnpm run build || npm install pnpm turbo ) && cd .. && pnpm i --no-frozen-lockfile && npx turbo run build --scope=docs --include-dependencies --no-deps"

Loading