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

feat: add className prop to Allotment.Pane #108

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 src/allotment.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

.splitView {
height: 100%;
overflow: hidden;
position: relative;
width: 100%;
}
Expand All @@ -29,7 +30,6 @@
.splitView > .splitViewContainer > .splitViewView {
position: absolute;
white-space: initial;
overflow: hidden;
}

.splitView > .splitViewContainer > .splitViewView:not(.visible) {
Expand Down
6 changes: 4 additions & 2 deletions src/allotment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function isPane(item: React.ReactNode): item is typeof Pane {
}

export interface CommonProps {
/** Sets a className attribute on the outer component */
className?: string;
/** Maximum size of each element */
maxSize?: number;
/** Minimum size of each element */
Expand All @@ -32,9 +34,9 @@ export type PaneProps = {
} & CommonProps;

export const Pane = forwardRef<HTMLDivElement, PaneProps>(
({ children }: PaneProps, ref) => {
({ className, children }: PaneProps, ref) => {
return (
<div ref={ref} className={styles.splitViewView}>
<div ref={ref} className={classNames(styles.splitViewView, className)}>
{children}
</div>
);
Expand Down
12 changes: 12 additions & 0 deletions stories/allotment.stories.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@
height: 100%;
justify-content: center;
}

.customPane {
background-color: red;
overflow: scroll;
}

.customPaneContent {
width: 200px;
background: rgb(222, 222, 222);
color: rgb(30, 30, 30);
overflow: visible;
}
19 changes: 19 additions & 0 deletions stories/allotment.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meta, Story } from "@storybook/react";
import classNames from "classnames";
import { debounce } from "lodash";
import { useEffect, useMemo, useRef, useState } from "react";

Expand Down Expand Up @@ -245,3 +246,21 @@ export const ConfigureSash: Story = ({ sashSize, ...args }) => {
ConfigureSash.args = {
sashSize: 4,
};

export const PaneClassName: Story = (args) => {
return (
<div className={styles.container}>
<Allotment {...args}>
<Allotment.Pane className={styles.customPane}>
<div className={classNames(styles.content, styles.customPaneContent)}>
div1
</div>
</Allotment.Pane>
<Allotment.Pane>
<div className={styles.content}>div2</div>
</Allotment.Pane>
</Allotment>
</div>
);
};
PaneClassName.args = {};