Skip to content

Commit 72b25fe

Browse files
committed
fix(storybook): починить истории примитивов
- avatar-control: добавить provideHttpClient и API_URL провайдеры - file-item: добавить link в stories и шаблон - file-upload-item: привязать обработчики delete/retry - loader: исправить цвет circle — убрать var() для hex значений - search: привязать type инпута + добавить type в argTypes - textarea: ограничить ширину small блока, counter/error внутри контейнера
1 parent b915481 commit 72b25fe

9 files changed

Lines changed: 40 additions & 6 deletions

File tree

projects/social_platform/.storybook/preview.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import type { Preview } from "@storybook/angular";
22
import { applicationConfig } from "@storybook/angular";
33
import { provideZonelessChangeDetection } from "@angular/core";
4+
import { provideHttpClient } from "@angular/common/http";
45

56
const preview: Preview = {
67
// Приложение zoneless — без этого signals в историях не обновляются.
78
decorators: [
89
applicationConfig({
9-
providers: [provideZonelessChangeDetection()],
10+
providers: [provideZonelessChangeDetection(), provideHttpClient()],
1011
}),
1112
],
1213
parameters: {

projects/social_platform/src/app/ui/primitives/avatar-control/avatar-control.component.stories.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
/** @format */
22

3-
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
3+
import { Meta, StoryObj, moduleMetadata, applicationConfig } from "@storybook/angular";
44
import { ReactiveFormsModule, FormControl } from "@angular/forms";
5+
import { provideHttpClient } from "@angular/common/http";
6+
import { API_URL } from "@corelib";
57
import { AvatarControlComponent } from "./avatar-control.component";
68

79
const meta: Meta<AvatarControlComponent> = {
810
title: "UI/PRIMITIVES/AvatarControl",
911
component: AvatarControlComponent,
1012
tags: ["autodocs"],
1113
decorators: [
14+
applicationConfig({
15+
providers: [
16+
provideHttpClient(),
17+
{ provide: API_URL, useValue: "" },
18+
],
19+
}),
1220
moduleMetadata({
1321
imports: [ReactiveFormsModule],
1422
}),

projects/social_platform/src/app/ui/primitives/file-item/file-item.component.stories.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const meta: Meta<FileItemComponent> = {
2323
type: { control: "text" },
2424
name: { control: "text" },
2525
size: { control: "number" },
26+
link: { control: "text" },
2627
mode: { control: "inline-radio", options: ["default", "preview"] },
2728
canDelete: { control: "boolean" },
2829
},
@@ -34,6 +35,7 @@ const meta: Meta<FileItemComponent> = {
3435
[type]="type"
3536
[name]="name"
3637
[size]="size"
38+
[link]="link"
3739
[mode]="mode"
3840
[canDelete]="canDelete"
3941
></app-file-item>
@@ -52,6 +54,7 @@ export const Default: Story = {
5254
size: 2457600,
5355
mode: "default",
5456
canDelete: false,
57+
link: "https://example.com/Документ.pdf",
5558
},
5659
};
5760

@@ -62,6 +65,7 @@ export const WithDelete: Story = {
6265
size: 1048576,
6366
mode: "default",
6467
canDelete: true,
68+
link: "https://example.com/Удаляемый.pdf",
6569
},
6670
};
6771

@@ -72,6 +76,7 @@ export const Preview: Story = {
7276
size: 3145728,
7377
mode: "preview",
7478
canDelete: true,
79+
link: "https://example.com/Фото.jpg",
7580
},
7681
};
7782

@@ -82,5 +87,6 @@ export const SmallFile: Story = {
8287
size: 2048,
8388
mode: "default",
8489
canDelete: false,
90+
link: "https://example.com/readme.txt",
8591
},
8692
};

projects/social_platform/src/app/ui/primitives/file-upload-item/file-upload-item.component.stories.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ const meta: Meta<FileUploadItemComponent> = {
1616
error: { control: "text" },
1717
},
1818
render: (args) => ({
19-
props: args,
19+
props: {
20+
...args,
21+
onDelete: () => console.log("[FileUploadItem] delete"),
22+
onRetry: () => console.log("[FileUploadItem] retry"),
23+
},
2024
template: `
2125
<div style="max-width: 400px;">
2226
<app-file-upload-item
@@ -26,6 +30,8 @@ const meta: Meta<FileUploadItemComponent> = {
2630
[link]="link"
2731
[loading]="loading"
2832
[error]="error"
33+
(delete)="onDelete()"
34+
(retry)="onRetry()"
2935
></app-file-upload-item>
3036
</div>
3137
`,

projects/social_platform/src/app/ui/primitives/loader/loader.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
} @else if (type() === "circle") {
2525
<div
2626
class="lds-ring"
27-
[style]="'--size:' + size() + ';' + '--color:' + 'var(--' + color() + ');'"
27+
[style]="'--size:' + size() + ';' + '--color:' + color() + ';'"
2828
>
2929
<div></div>
3030
<div></div>

projects/social_platform/src/app/ui/primitives/search/search.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<input
1717
#inputEl
1818
class="text-body-12"
19-
type="text"
19+
[type]="type()"
20+
[value]="value"
2021
[placeholder]="placeholder()"
2122
(input)="onInput($event)"
2223
/>

projects/social_platform/src/app/ui/primitives/search/search.component.stories.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const meta: Meta<SearchComponent> = {
1515
],
1616
argTypes: {
1717
placeholder: { control: "text" },
18+
type: { control: "select", options: ["text", "password", "email"] },
1819
openable: { control: "boolean" },
1920
error: { control: "boolean" },
2021
},
@@ -26,6 +27,7 @@ const meta: Meta<SearchComponent> = {
2627
template: `<app-search
2728
[formControl]="control"
2829
[placeholder]="placeholder"
30+
[type]="type"
2931
[openable]="openable"
3032
[error]="error"
3133
></app-search>`,

projects/social_platform/src/app/ui/primitives/textarea/textarea.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- @format -->
22

3-
<div class="field" [class.field--error]="error()">
3+
<div class="field" [class.field--error]="error()" [class.field--small]="size() === 'small'" [class.field--big]="size() === 'big'">
44
<div class="field__left-icon">
55
<ng-content select="left-icon"></ng-content>
66
</div>

projects/social_platform/src/app/ui/primitives/textarea/textarea.component.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@
66
.field {
77
position: relative;
88

9+
&--small {
10+
min-width: 245px;
11+
}
12+
13+
&--big {
14+
width: 100%;
15+
}
16+
917
&__input {
18+
display: block;
19+
width: 100%;
1020
min-height: 162px;
1121
padding: 12px 18px;
1222
color: var(--black);

0 commit comments

Comments
 (0)