The underlying Pull-Request has changed. Press reload to see the changes.
+- Warning: Non saved modification will be lost.
++
{colors.map(color => (
@@ -44,7 +38,6 @@ storiesOf("Buttons|Button", module)
const buttonStory = (name: string, storyFn: () => ReactElement) => {
return storiesOf("Buttons|" + name, module)
- .addDecorator(RoutingDecorator)
.addDecorator(SpacingDecorator)
.add("Default", storyFn);
};
@@ -53,7 +46,7 @@ buttonStory("CreateButton", () =>
Create);
buttonStory("DeleteButton", () =>
Delete);
buttonStory("DownloadButton", () =>
).add(
"Disabled",
- () =>
+ () =>
);
buttonStory("EditButton", () =>
Edit);
buttonStory("SubmitButton", () =>
Submit);
diff --git a/scm-ui/ui-components/src/repos/Diff.stories.tsx b/scm-ui/ui-components/src/repos/Diff.stories.tsx
new file mode 100644
index 0000000000..2f93ffd919
--- /dev/null
+++ b/scm-ui/ui-components/src/repos/Diff.stories.tsx
@@ -0,0 +1,47 @@
+import React, { useEffect, useState } from "react";
+import { storiesOf } from "@storybook/react";
+import Diff from "./Diff";
+// @ts-ignore
+import parser from "gitdiff-parser";
+import simpleDiff from "../__resources__/Diff.simple";
+import Button from "../buttons/Button";
+import { DiffEventContext } from "./DiffTypes";
+import Toast from "../toast/Toast";
+
+const diffFiles = parser.parse(simpleDiff);
+
+storiesOf("Diff", module)
+ .add("Default", () =>
)
+ .add("Side-By-Side", () =>
)
+ .add("Collapsed", () =>
)
+ .add("File Controls", () =>
} />)
+ .add("File Annotation", () => (
+ [Custom File annotation for {file.newPath}
]} />
+ ))
+ .add("Line Annotation", () => (
+ {
+ return {
+ N2: [Line Annotation
]
+ };
+ }}
+ />
+ ))
+ .add("OnClick", () => {
+ const OnClickDemo = ({}) => {
+ const [changeId, setChangeId] = useState();
+ useEffect(() => {
+ const interval = setInterval(() => setChangeId(undefined), 2000);
+ return () => clearInterval(interval);
+ });
+ const onClick = (context: DiffEventContext) => setChangeId(context.changeId);
+ return (
+ <>
+ {changeId && }
+
+ >
+ );
+ };
+ return ;
+ });
diff --git a/scm-ui/ui-components/src/repos/DiffFile.tsx b/scm-ui/ui-components/src/repos/DiffFile.tsx
index 0c51a30982..4e2e7e08b4 100644
--- a/scm-ui/ui-components/src/repos/DiffFile.tsx
+++ b/scm-ui/ui-components/src/repos/DiffFile.tsx
@@ -20,7 +20,7 @@ type Collapsible = {
};
type State = Collapsible & {
- sideBySide: boolean;
+ sideBySide?: boolean;
};
const DiffFilePanel = styled.div`
@@ -87,7 +87,7 @@ class DiffFile extends React.Component {
super(props);
this.state = {
collapsed: !!this.props.defaultCollapse,
- sideBySide: false
+ sideBySide: props.sideBySide
};
}
diff --git a/scm-ui/ui-components/src/repos/DiffTypes.ts b/scm-ui/ui-components/src/repos/DiffTypes.ts
index 58dd5aef5b..ba89d40aaa 100644
--- a/scm-ui/ui-components/src/repos/DiffTypes.ts
+++ b/scm-ui/ui-components/src/repos/DiffTypes.ts
@@ -66,7 +66,7 @@ export type DiffEventHandler = (context: DiffEventContext) => void;
export type FileControlFactory = (file: File, setCollapseState: (p: boolean) => void) => ReactNode | null | undefined;
export type DiffObjectProps = {
- sideBySide: boolean;
+ sideBySide?: boolean;
onClick?: DiffEventHandler;
fileControlFactory?: FileControlFactory;
fileAnnotationFactory?: FileAnnotationFactory;