Skip to content

Commit dd90e38

Browse files
authored
Add new ModelPacks component (#3469)
1 parent aa2f371 commit dd90e38

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface ModelPackDetails {
2+
name: string;
3+
path: string;
4+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { Meta, StoryFn } from "@storybook/react";
2+
3+
import { ModelPacks as ModelPacksComponent } from "../../view/model-alerts/ModelPacks";
4+
5+
export default {
6+
title: "Model Alerts/Model Packs",
7+
component: ModelPacksComponent,
8+
argTypes: {
9+
openModelPackClick: {
10+
action: "open-model-pack-clicked",
11+
table: {
12+
disable: true,
13+
},
14+
},
15+
},
16+
} as Meta<typeof ModelPacksComponent>;
17+
18+
const Template: StoryFn<typeof ModelPacksComponent> = (args) => (
19+
<ModelPacksComponent {...args} />
20+
);
21+
22+
export const ModelPacks = Template.bind({});
23+
ModelPacks.args = {
24+
modelPacks: [
25+
{
26+
name: "Model pack 1",
27+
path: "/path/to/model-pack-1",
28+
},
29+
{
30+
name: "Model pack 2",
31+
path: "/path/to/model-pack-2",
32+
},
33+
],
34+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { styled } from "styled-components";
2+
import { LinkIconButton } from "../common/LinkIconButton";
3+
import type { ModelPackDetails } from "../../common/model-pack-details";
4+
5+
const Title = styled.h3`
6+
font-size: medium;
7+
font-weight: 500;
8+
margin: 0;
9+
`;
10+
11+
const List = styled.ul`
12+
list-style: none;
13+
padding: 0;
14+
margin-top: 5px;
15+
`;
16+
17+
export const ModelPacks = ({
18+
modelPacks,
19+
openModelPackClick,
20+
}: {
21+
modelPacks: ModelPackDetails[];
22+
openModelPackClick: (path: string) => void;
23+
}): React.JSX.Element => {
24+
if (modelPacks.length <= 0) {
25+
return <></>;
26+
}
27+
28+
return (
29+
<>
30+
<Title>Model packs</Title>
31+
<List>
32+
{modelPacks.map((modelPack) => (
33+
<li key={modelPack.path}>
34+
<LinkIconButton onClick={() => openModelPackClick(modelPack.path)}>
35+
<span slot="start" className="codicon codicon-file-code"></span>
36+
{modelPack.name}
37+
</LinkIconButton>
38+
</li>
39+
))}
40+
</List>
41+
</>
42+
);
43+
};

0 commit comments

Comments
 (0)