Skip to content

Patches for Flexbox #27

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

Merged
merged 27 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
312f408
1 create npm baseline and modules api (#2)
bubulux Dec 20, 2024
0db1d7f
5 enable storybook development (#9)
bubulux Dec 22, 2024
65c8fd5
Patch for pipeline
bubulux Dec 22, 2024
2bfc40a
Auth patch
bubulux Dec 22, 2024
9832cad
next patch
bubulux Dec 22, 2024
16beabf
Wrong token
bubulux Dec 22, 2024
726278e
Github token as well
bubulux Dec 22, 2024
32f5f74
rm bot req
bubulux Dec 22, 2024
ce4d723
new script
bubulux Dec 22, 2024
5ecbdc0
w dispatch
bubulux Dec 22, 2024
e708a0f
final update
bubulux Dec 22, 2024
ec7e140
6 setup jest (#10)
bubulux Dec 23, 2024
3b0a6ec
7 setup cicd (#11)
bubulux Dec 23, 2024
e5275cd
Merge branch 'production' into development
bubulux Dec 23, 2024
9782687
Fix for pipeline check
bubulux Dec 23, 2024
46d03a8
Merge branch 'production' into development
bubulux Dec 23, 2024
4f96ce1
15 subsequent fixes for cicd (#16)
bubulux Dec 26, 2024
f1a63f9
Updated version for CI/CD Test
bubulux Dec 26, 2024
1d87d8a
4 add consistent flexbox component (#18)
bubulux Dec 26, 2024
1c4e104
8 initial readme file (#19)
bubulux Dec 26, 2024
ddde1ec
First release under unstable branch
bubulux Dec 26, 2024
32f2e29
Update version to 0.1.0
bubulux Dec 26, 2024
b05d756
22 create shallow dist for package (#23)
bubulux Dec 27, 2024
9fc5fdd
Merge branch 'production' into development
bubulux Dec 27, 2024
27e75c3
25 add missing flex properties to flex (#26)
bubulux Dec 28, 2024
092f376
Inc Version to 0.2.1 after Flexbox patches
bubulux Dec 28, 2024
bdf2829
Merge branch 'production' into development
bubulux Dec 28, 2024
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
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
{
"name": "fluentui-helpers",
"version": "0.2.0",
"version": "0.2.1",
"description": "Helper library for microsofts fluentui react library",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"author": "bubulus",
"license": "MIT",
"peerDependencies": {
"@fluentui/react-components": "^9",
"@fluentui/react-icons": "^2",
"@griffel/react": "^1.5",
"@fluentui/react-components": "^9",
"@fluentui/react-icons": "^2",
"@griffel/react": "^1.5",
Expand Down Expand Up @@ -69,6 +78,7 @@
"typescript": "5.5.4",
"vite": "^5.4.8",
"vite-plugin-dts": "^4.4.0",
"vite-plugin-dts": "^4.4.0",
"vite-tsconfig-paths": "^5.0.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import {

import type {
TFlexDirection,
TFlexOption,
TFlexOptionContent,
TFlexOptionItems,
TFlexWrap,
TFlexGrow,
TFlexShrink,
TFlexBasis,
TFlexShorthandDimensions,
TFlexPosition,
} from "@components/layout/Flex/types";
Expand All @@ -25,9 +30,14 @@ type TProps = {
children: ReactNode;
position?: TFlexPosition;
direction?: TFlexDirection;
justifyContent?: TFlexOption;
alignItems?: TFlexOption;
wrap?: boolean;
justifyContent?: TFlexOptionContent;
alignItems?: TFlexOptionItems;
alignContent?: TFlexOptionContent;
alignSelf?: TFlexOptionItems;
grow?: TFlexGrow;
noShrink?: TFlexShrink;
basis?: TFlexBasis;
wrap?: TFlexWrap;
className?: string;
gap?: TThemeSpacing;
margin?: TThemeShorthandSpacing;
Expand All @@ -49,8 +59,14 @@ type TProps = {
* - `direction`: flex-direction property
* - `justifyContent`: justify-content property
* - `alignItems`: align-items property
* - `alignContent`: align-content property
* - `alignSelf`: align-self property
* - `wrap`: flex-wrap property
* - `gap`: gap between children, with fixed predefined values from the design system, not discriminating between horizontal and vertical gap (because there are literally the same values)
* - `grow`: shorthand for flex-grow property
* - `noShrink`: shorthand for flex-shrink property, noShrik is the same as flex-shrink: 0
* - `basis`: shorthand for flex-basis property, only global values are supported, for specific values use className prop
* - `position`: position property, supports all global values
* - `margin`: margin property, using the same values like gap, expects the shorthand notation
* - `padding`: same like margin, but for padding, concrete example below
*
Expand All @@ -74,15 +90,33 @@ type TProps = {
*
*
* @default
* direction = "row", justifyContent = "start", alignItems = "start", wrap = false, gap = "None", margin = ["None"], padding = ["None"], shHeight = "auto", shWidth = "auto"
* direction = "row",
* position = "static",
* justifyContent = "start",
* alignItems = "stretch",
* alignContent = "stretch",
* alignSelf = "auto",
* grow = false,
* noShrink = false,
* wrap = false,
* gap = "None",
* margin = ["None"],
* padding = ["None"],
* shHeight = "auto",
* shWidth = "auto"
*/
export default function Flex({
direction = "row",
position = "static",
justifyContent = "start",
alignItems = "start",
alignContent = "stretch",
alignItems = "stretch",
alignSelf = "auto",
wrap = false,
gap = "None",
grow = false,
noShrink = false,
basis = "auto",
margin = ["None"],
padding = ["None"],
shHeight = "auto",
Expand All @@ -92,7 +126,17 @@ export default function Flex({
children,
...rest
}: TProps) {
const flexBoxClass = useFlexBox(justifyContent, alignItems, direction, wrap);
const flexBoxClass = useFlexBox(
justifyContent,
alignContent,
alignItems,
alignSelf,
direction,
wrap,
grow,
noShrink,
basis,
);
const gapClass = useGap(gap);
const marginClass = useMargin(margin);
const paddingClass = usePadding(padding);
Expand Down
46 changes: 39 additions & 7 deletions src/components/layout/Flex/hooks/useFlexBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,65 @@ import { useFlexBoxClasses } from "@components/layout/Flex/styles";

import type {
TFlexDirection,
TFlexOption,
TFlexOptionContent,
TFlexOptionItems,
TFlexShrink,
TFlexGrow,
TFlexBasis,
TFlexWrap,
} from "@components/layout/Flex/types";

export default function useFlexBox(
justifyContent?: TFlexOption,
alignItems?: TFlexOption,
justifyContent?: TFlexOptionContent,
alignContent?: TFlexOptionContent,
alignItems?: TFlexOptionItems,
alignSelf?: TFlexOptionItems,
direction?: TFlexDirection,
wrap?: boolean,
wrap?: TFlexWrap,
grow?: TFlexGrow,
noShrink?: TFlexShrink,
basis?: TFlexBasis,
) {
const classes = useFlexBoxClasses();

const directionClass = direction
? classes[`${direction}Direction`]
: undefined;

const justifyContentClass = justifyContent
? classes[`${justifyContent}Content`]
? classes[`${justifyContent}JustifyContent`]
: undefined;

const alignContentClass = alignContent
? classes[`${alignContent}AlignContent`]
: undefined;

const alignItemsClass = alignItems
? classes[`${alignItems}Items`]
? classes[`${alignItems}AlignItems`]
: undefined;

const alignSelfClass = alignSelf
? classes[`${alignSelf}AlignSelf`]
: undefined;

const wrapClass = wrap ? classes.wrap : classes.nowrap;
const basisClass = basis ? classes[`${basis}Basis`] : undefined;

const growClass = grow ? classes.growOne : classes.growZero;
const shrinkClass = noShrink ? classes.shrinkZero : classes.shrinkOne;
const wrapClass = wrap
? (wrap === "reverse" && classes.wrapReverse) || classes.wrap
: classes.nowrap;

return mergeClasses(
classes.base,
directionClass,
justifyContentClass,
alignContentClass,
alignItemsClass,
alignSelfClass,
growClass,
shrinkClass,
basisClass,
wrapClass,
);
}
2 changes: 1 addition & 1 deletion src/components/layout/Flex/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Flex from "@components/layout/Flex/component";
import Flex from "@components/layout/Flex/func";

export default Flex;
124 changes: 107 additions & 17 deletions src/components/layout/Flex/styles/flexBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,97 @@ const useFlexBoxClasses = makeStyles({
columnDirection: {
flexDirection: "column",
},
rowReverseDirection: {
flexDirection: "row-reverse",
},
columnReverseDirection: {
flexDirection: "column-reverse",
},

// justify-content
centerContent: {
centerJustifyContent: {
justifyContent: "center",
},
startContent: {
startJustifyContent: {
justifyContent: "flex-start",
},
endContent: {
endJustifyContent: {
justifyContent: "flex-end",
},
spaceBetweenContent: {
spaceBetweenJustifyContent: {
justifyContent: "space-between",
},
spaceAroundContent: {
spaceAroundJustifyContent: {
justifyContent: "space-around",
},
spaceEvenlyContent: {
spaceEvenlyJustifyContent: {
justifyContent: "space-evenly",
},
stretchContent: {
stretchJustifyContent: {
justifyContent: "stretch",
},

// align-items
centerItems: {
autoAlignItems: {
alignItems: "auto",
},
centerAlignItems: {
alignItems: "center",
},
startItems: {
startAlignItems: {
alignItems: "flex-start",
},
endItems: {
endAlignItems: {
alignItems: "flex-end",
},
stretchItems: {
stretchAlignItems: {
alignItems: "stretch",
},
spaceBetweenItems: {
alignItems: "space-between",
baselineAlignItems: {
alignItems: "baseline",
},

// align-self
autoAlignSelf: {
alignSelf: "auto",
},
startAlignSelf: {
alignSelf: "flex-start",
},
endAlignSelf: {
alignSelf: "flex-end",
},
spaceAroundItems: {
alignItems: "space-around",
centerAlignSelf: {
alignSelf: "center",
},
spaceEvenlyItems: {
alignItems: "space-evenly",
stretchAlignSelf: {
alignSelf: "stretch",
},
baselineAlignSelf: {
alignSelf: "baseline",
},

// align-content
centerAlignContent: {
alignContent: "center",
},
startAlignContent: {
alignContent: "flex-start",
},
endAlignContent: {
alignContent: "flex-end",
},
stretchAlignContent: {
alignContent: "stretch",
},
spaceBetweenAlignContent: {
alignContent: "space-between",
},
spaceAroundAlignContent: {
alignContent: "space-around",
},
spaceEvenlyAlignContent: {
alignContent: "space-evenly",
},

// wrap
Expand All @@ -62,6 +110,48 @@ const useFlexBoxClasses = makeStyles({
nowrap: {
flexWrap: "nowrap",
},
wrapReverse: {
flexWrap: "wrap-reverse",
},

// grow
growOne: {
flexGrow: 1,
},
growZero: {
flexGrow: 0,
},

// shrink
shrinkOne: {
flexShrink: 1,
},
shrinkZero: {
flexShrink: 0,
},

// basis
autoBasis: {
flexBasis: "auto",
},
"0Basis": {
flexBasis: 0,
},
fillBasis: {
flexBasis: "fill",
},
maxContentBasis: {
flexBasis: "max-content",
},
minContentBasis: {
flexBasis: "min-content",
},
fitContentBasis: {
flexBasis: "fit-content",
},
contentBasis: {
flexBasis: "content",
},
});

export default useFlexBoxClasses;
Loading
Loading