Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/components/flex/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export const Flex = forwardRef(
gap,
align,
justify,
flexGrow,
style,
} = props;

const flex = useFlex({
m: { flexWrap, gap, align, flexDirection, justify },
m: { flexWrap, gap, align, flexDirection, justify, flexGrow },
md: { ...md },
d: { ...d },
});
Expand Down
12 changes: 12 additions & 0 deletions src/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export type UiKitFlexParams = {
gap?: UiKitGap;
flexDirection?: UiKitFlexDirection;
flexWrap?: UiKitFlexWrap;
flexGrow?: number;
};

export type UiKitBackgroundProps = {
Expand Down Expand Up @@ -350,6 +351,17 @@ export type UiKitEffectProps = {
opacity?: number;
overflow?: "visible" | "hidden" | "scroll" | "auto" | "clip";
backdropBlur?: string | number;
cursor?:
| "auto"
| "default"
| "pointer"
| "not-allowed"
| "text"
| "move"
| "wait"
| "crosshair"
| "grab"
| "grabbing";
};

export type ElementRef<E extends ElementType> =
Expand Down
28 changes: 28 additions & 0 deletions src/components/use-flex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const useFlex = (params: {
const styles: Record<string, string | number> = {};
let className = "";

// === GAP ===
if (typeof params.m.gap !== "undefined") {
styles["--gap"] = styleTransformer(params.m.gap);
className += "gap-[var(--gap)] ";
Expand All @@ -237,6 +238,7 @@ export const useFlex = (params: {
className += "lg:gap-[var(--d-gap)] ";
}

// === JUSTIFY ===
if (params.m.justify) {
className += justifyStyle(params.m.justify) + " ";
}
Expand All @@ -250,6 +252,7 @@ export const useFlex = (params: {
className += justifyStyle(params.d.justify, "lg") + " ";
}

// === FLEX WRAP ===
if (params.m.flexWrap) {
className += flexWrapStyle(params.m.flexWrap) + " ";
}
Expand All @@ -264,6 +267,7 @@ export const useFlex = (params: {
className += flexWrapStyle(params.d.flexWrap, "lg") + " ";
}

// === ALIGN ===
if (params.m.align) {
className += alignStyle(params.m.align) + " ";
}
Expand All @@ -278,6 +282,7 @@ export const useFlex = (params: {
className += alignStyle(params.d.align, "lg") + " ";
}

// === DIRECTION ===
if (params.m.flexDirection) {
className += directionStyle(params.m.flexDirection) + " ";
}
Expand All @@ -295,6 +300,29 @@ export const useFlex = (params: {
className += directionStyle(params.d.flexDirection, "lg") + " ";
}

// === FLEX GROW ===
if (typeof params.m.flexGrow !== "undefined") {
styles["--grow"] = params.m.flexGrow;
className += "grow-[var(--grow)] ";
}

const mdGrow = params.md.flexGrow ?? params.m.flexGrow;
if (
typeof params.md.flexGrow !== "undefined" &&
params.md.flexGrow !== params.m.flexGrow
) {
styles["--md-grow"] = params.md.flexGrow;
className += "md:grow-[var(--md-grow)] ";
}

if (
typeof params.d.flexGrow !== "undefined" &&
params.d.flexGrow !== mdGrow
) {
styles["--d-grow"] = params.d.flexGrow;
className += "lg:grow-[var(--d-grow)] ";
}

return {
styles,
className,
Expand Down
9 changes: 6 additions & 3 deletions src/components/use-position/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const usePosition = ({

if (m) {
if (m.position.type) {
className += `${m.position.type} `;
styles["--positionType"] = m.position.type;
className += `[position:var(--positionType)] `;
}

if (typeof m.position.top !== "undefined") {
Expand Down Expand Up @@ -68,7 +69,8 @@ export const usePosition = ({
if (md) {
if (md.position.type) {
if (m?.position.type !== md.position.type) {
className += `md:${md.position.type} `;
styles["--mdPositionType"] = md.position.type;
className += `md:[position:var(--mdPositionType)] `;
}
mdCalculatedValues.position.type = md.position.type;
}
Expand Down Expand Up @@ -128,7 +130,8 @@ export const usePosition = ({

if (d) {
if (d.position.type) {
className += `lg:${d.position.type} `;
styles["--dPositionType"] = d.position.type;
className += `lg:[position:var(--dPositionType)] `;
}

if (
Expand Down
Loading