Skip to content

Commit

Permalink
feat: add content section variant
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Dec 4, 2023
1 parent 90d2a24 commit 44fe8ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib/sections/ContentSection/ContentSection.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ export const WithForm = {
</ContentSection.Footer>
</>
),
variant: "narrow",
},
};
14 changes: 10 additions & 4 deletions src/lib/sections/ContentSection/ContentSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";

import { Col } from "@canonical/react-components";
import { Col, Row } from "@canonical/react-components";
import classNames from "classnames";

import "./ContentSection.scss";
Expand Down Expand Up @@ -29,12 +29,18 @@ export const ContentSection = ({
children,
className,
as,
variant = "wide",
...props
}: ContentSectionProps) => {
}: ContentSectionProps & {
variant?: "narrow" | "wide";
}) => {
const Component = as || "section";
const sectionClass = classNames("content-section", className);
return (
<Component {...props} className={classNames("content-section", className)}>
<Col size={12}>{children}</Col>
<Component {...props} className={sectionClass}>
<Row>
<Col size={variant === "narrow" ? 6 : 12}>{children}</Col>
</Row>
</Component>
);
};
Expand Down

0 comments on commit 44fe8ec

Please sign in to comment.