Skip to content

Commit

Permalink
Merge pull request #77 from aversini/fix(Flexgrid)-align-items-and-ju…
Browse files Browse the repository at this point in the history
…stify-content-should-support-normal-

fix(Flexgrid): align-items and justify-content should support "normal"
  • Loading branch information
aversini authored Nov 25, 2023
2 parents e617030 + 7ffc27e commit 32033a8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
53 changes: 47 additions & 6 deletions packages/documentation/src/stories/Flexgrid.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Flexgrid, FlexgridItem } from "@versini/ui-components";
import {
Button,
Flexgrid,
FlexgridItem,
Main,
TextInput,
} from "@versini/ui-components";

const meta: Meta<typeof Flexgrid> = {
component: Flexgrid,
Expand All @@ -10,8 +16,8 @@ const meta: Meta<typeof Flexgrid> = {
className: "",
rowGap: 1,
columnGap: 1,
alignHorizontal: "flex-start",
alignVertical: "flex-start",
alignHorizontal: "normal",
alignVertical: "normal",
direction: "row",
},
argTypes: {
Expand All @@ -31,6 +37,7 @@ const meta: Meta<typeof Flexgrid> = {
alignHorizontal: {
control: "radio",
options: [
"normal",
"flex-start",
"center",
"flex-end",
Expand All @@ -41,7 +48,14 @@ const meta: Meta<typeof Flexgrid> = {
},
alignVertical: {
control: "radio",
options: ["flex-start", "center", "flex-end", "stretch", "baseline"],
options: [
"normal",
"flex-start",
"center",
"flex-end",
"stretch",
"baseline",
],
},
},
};
Expand Down Expand Up @@ -144,8 +158,6 @@ export const Basic: Story = {

export const Interactive: Story = {
args: {
alignHorizontal: "flex-start",
alignVertical: "flex-start",
height: "auto",
},
render: (args) => (
Expand Down Expand Up @@ -191,3 +203,32 @@ export const Interactive: Story = {
</>
),
};

export const WithLoginForm: Story = {
render: (args) => (
<Main>
<form
//className="mx-auto flex w-96 flex-col flex-wrap"
>
<Flexgrid
{...args}
// direction="column" className="mx-auto w-96"
>
<FlexgridItem>
<TextInput
type="password"
name="password"
label="Enter your password here"
/>
</FlexgridItem>

<FlexgridItem>
<Button noBorder type="submit" className="mb-4 mt-6">
Log in
</Button>
</FlexgridItem>
</Flexgrid>
</form>
</Main>
),
};
4 changes: 2 additions & 2 deletions packages/ui-components/src/components/Flexgrid/Flexgrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const Flexgrid = ({
width = "auto",

direction = "row",
alignHorizontal = "flex-start",
alignVertical = "flex-start",
alignHorizontal = "normal",
alignVertical = "normal",

...otherProps
}: FlexgridProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type FlexgridProps = {
* the alignment along the main axis (horizontal).
*/
alignHorizontal?:
| "normal"
| "flex-start"
| "center"
| "flex-end"
Expand All @@ -20,7 +21,13 @@ export type FlexgridProps = {
* Equivalent to "align-items" in flexbox, this prop defines
* the alignment along the cross axis (vertical).
*/
alignVertical?: "flex-start" | "center" | "flex-end" | "stretch" | "baseline";
alignVertical?:
| "normal"
| "flex-start"
| "center"
| "flex-end"
| "stretch"
| "baseline";

/**
* The class name of the Flexgrid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe("Flexgrid default rules", () => {
const gridRoot = await screen.findByTestId("grid-1");
expectToHaveStyles(gridRoot, {
"flex-direction": "row",
"justify-content": "flex-start",
"align-items": "flex-start",
"justify-content": "normal",
"align-items": "normal",
});
expectToHaveClasses(gridRoot, ["box-border", "flex", "flex-wrap"]);
});
Expand Down

0 comments on commit 32033a8

Please sign in to comment.