Skip to content
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

wip: feat: Add row--4-cols-medium grid row #1146

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"tsc-alias": "1.8.10",
"typescript": "5.5.4",
"typescript-eslint": "8.4.0",
"vanilla-framework": "4.16.0",
"vanilla-framework": "4.17.0",
"wait-on": "8.0.0",
"webpack": "5.94.0"
},
Expand Down
45 changes: 44 additions & 1 deletion src/components/Row/Row.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import { Meta, StoryObj } from "@storybook/react";

import Row from "./Row";
import Col from "../Col";

const meta: Meta<typeof Row> = {
component: Row,
Expand All @@ -11,6 +13,14 @@ const meta: Meta<typeof Row> = {
control: {
type: "text",
},
description: "The content of the row.",
},
fourColumnMedium: {
control: {
type: "boolean",
},
type: { name: "boolean", required: false },
description: "Whether the row has four columns on medium screens.",
},
},
};
Expand All @@ -26,6 +36,39 @@ export const Default: Story = {
name: "Default",

args: {
children: "children...",
children: (
<>
<Col size={3} medium={2}>
.col-3.col-medium-2
</Col>
<Col size={6} medium={2}>
.col-6.col-medium-2
</Col>
<Col size={3} medium={2}>
.col-3.col-medium-2
</Col>
</>
),
},
};

export const FourColumnMediumGrid: Story = {
name: "Four column medium grid",

args: {
children: (
<>
<Col size={3} medium={2}>
.col-3.col-medium-2
</Col>
<Col size={6} medium={1}>
.col-6.col-medium-1
</Col>
<Col size={3} medium={1}>
.col-3.col-medium-1
</Col>
</>
),
fourColumnMedium: true,
},
};
12 changes: 12 additions & 0 deletions src/components/Row/Row.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ describe("Row ", () => {
);
const row = screen.getByTestId("row");
expect(row).toHaveClass("row");
expect(row).not.toHaveClass("row--4-cols-medium");
expect(row).toHaveClass("extra-class");
});

it("can use a four column grid on medium screens", () => {
render(
<Row data-testid="row" fourColumnMedium={true}>
Test content
</Row>,
);
const row = screen.getByTestId("row");
expect(row).toHaveClass("row--4-cols-medium");
expect(row).not.toHaveClass("row");
});
});
19 changes: 17 additions & 2 deletions src/components/Row/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export type Props = PropsWithSpread<
* Optional class(es) to pass to the wrapping div element.
*/
className?: ClassName;
/**
* Whether the row should have 4 columns on medium screens.
*/
fourColumnMedium?: boolean;
},
HTMLProps<HTMLDivElement>
>;
Expand All @@ -22,8 +26,19 @@ export type Props = PropsWithSpread<
*
* Vanilla has a responsive grid using a combination of rows and columns.
*/
const Row = ({ children, className, ...props }: Props): JSX.Element => (
<div className={classNames(className, "row")} {...props}>
const Row = ({
children,
className,
fourColumnMedium = false,
...props
}: Props): JSX.Element => (
<div
className={classNames(
className,
fourColumnMedium ? "row--4-cols-medium" : "row",
)}
{...props}
>
{children}
</div>
);
Expand Down
Loading