diff --git a/src/lib/components/progressbar/progressbar.component.ts b/src/lib/components/progressbar/progressbar.component.ts new file mode 100644 index 00000000..641b117b --- /dev/null +++ b/src/lib/components/progressbar/progressbar.component.ts @@ -0,0 +1,22 @@ +import { Component, Input } from '@angular/core'; +import { ProgressBar } from 'primeng/progressbar'; + +export type ProgressBarMode = 'determinate' | 'indeterminate'; + +@Component({ + selector: 'progressbar', + standalone: true, + imports: [ProgressBar], + template: ` + + `, +}) +export class ProgressBarComponent { + @Input() value = 0; + @Input() mode: ProgressBarMode = 'determinate'; + @Input() showValue = true; +} diff --git a/src/prime-preset/tokens/components/progressbar.ts b/src/prime-preset/tokens/components/progressbar.ts new file mode 100644 index 00000000..eda95979 --- /dev/null +++ b/src/prime-preset/tokens/components/progressbar.ts @@ -0,0 +1,5 @@ +export const progressbarCss = ({ dt }: { dt: (path: string) => string }) => ` + .p-progressbar-label { + font-family: ${dt('fonts.fontFamily.base')}; + } +`; diff --git a/src/stories/components/progressbar/examples/progressbar-indeterminate.component.ts b/src/stories/components/progressbar/examples/progressbar-indeterminate.component.ts new file mode 100644 index 00000000..bab48736 --- /dev/null +++ b/src/stories/components/progressbar/examples/progressbar-indeterminate.component.ts @@ -0,0 +1,14 @@ +import { Component } from '@angular/core'; +import { ProgressBarComponent } from '../../../../lib/components/progressbar/progressbar.component'; + +@Component({ + selector: 'app-progressbar-indeterminate', + standalone: true, + imports: [ProgressBarComponent], + template: ` +
+ +
+ `, +}) +export class ProgressBarIndeterminateComponent {} diff --git a/src/stories/components/progressbar/examples/progressbar-no-label.component.ts b/src/stories/components/progressbar/examples/progressbar-no-label.component.ts new file mode 100644 index 00000000..8fa5eb28 --- /dev/null +++ b/src/stories/components/progressbar/examples/progressbar-no-label.component.ts @@ -0,0 +1,14 @@ +import { Component } from '@angular/core'; +import { ProgressBarComponent } from '../../../../lib/components/progressbar/progressbar.component'; + +@Component({ + selector: 'app-progressbar-no-label', + standalone: true, + imports: [ProgressBarComponent], + template: ` +
+ +
+ `, +}) +export class ProgressBarNoLabelComponent {} diff --git a/src/stories/components/progressbar/progressbar.stories.ts b/src/stories/components/progressbar/progressbar.stories.ts new file mode 100644 index 00000000..54de6614 --- /dev/null +++ b/src/stories/components/progressbar/progressbar.stories.ts @@ -0,0 +1,170 @@ +import { Meta, StoryObj, moduleMetadata } from '@storybook/angular'; +import { ProgressBarComponent } from '../../../lib/components/progressbar/progressbar.component'; +import { ProgressBarIndeterminateComponent } from './examples/progressbar-indeterminate.component'; +import { ProgressBarNoLabelComponent } from './examples/progressbar-no-label.component'; + +type ProgressBarArgs = ProgressBarComponent; + +const meta: Meta = { + title: 'Components/Misc/ProgressBar', + component: ProgressBarComponent, + tags: ['autodocs'], + decorators: [ + moduleMetadata({ + imports: [ + ProgressBarComponent, + ProgressBarIndeterminateComponent, + ProgressBarNoLabelComponent, + ], + }), + ], + parameters: { + docs: { + description: { + component: `Информирует пользователя о статусе длительного процесса. + +\`\`\`typescript +import { ProgressBarComponent } from '@cdek-it/angular-ui-kit'; +\`\`\``, + }, + }, + designTokens: { + prefix: '--p-progressbar', + }, + }, + argTypes: { + value: { + control: { type: 'number', min: 0, max: 100 }, + description: 'Значение прогресса (0–100)', + table: { + category: 'Props', + defaultValue: { summary: '0' }, + type: { summary: 'number' }, + }, + }, + mode: { + control: 'select', + options: ['determinate', 'indeterminate'], + description: 'Режим отображения', + table: { + category: 'Props', + defaultValue: { summary: 'determinate' }, + type: { summary: "'determinate' | 'indeterminate'" }, + }, + }, + showValue: { + control: 'boolean', + description: 'Отображать числовое значение', + table: { + category: 'Props', + defaultValue: { summary: 'true' }, + type: { summary: 'boolean' }, + }, + }, + }, +}; + +const commonTemplate = ``; + +export default meta; +type Story = StoryObj; + +// ── Default ────────────────────────────────────────────────────────────────── + +export const Default: Story = { + name: 'Default', + render: (args) => { + const parts: string[] = []; + + if (args.value != null && args.value !== 0) parts.push(`[value]="${args.value}"`); + if (args.mode && args.mode !== 'determinate') parts.push(`mode="${args.mode}"`); + if (!args.showValue) parts.push(`[showValue]="false"`); + + const template = parts.length + ? `` + : ``; + + return { props: args, template }; + }, + args: { + value: 50, + mode: 'determinate', + showValue: true, + }, + parameters: { + docs: { + description: { + story: 'Базовый пример компонента. Используйте Controls для интерактивного изменения пропсов.', + }, + }, + }, +}; + +// ── Stories ────────────────────────────────────────────────────────────────── + +export const Indeterminate: Story = { + render: (args) => ({ props: args, template: commonTemplate }), + args: { + mode: 'indeterminate', + showValue: true, + }, + parameters: { + docs: { + description: { story: 'Анимированный режим без конкретного значения.' }, + source: { + language: 'ts', + code: ` +import { Component } from '@angular/core'; +import { ProgressBarComponent } from '@cdek-it/angular-ui-kit'; + +@Component({ + selector: 'app-progressbar-indeterminate', + standalone: true, + imports: [ProgressBarComponent], + template: \` +
+ +
+ \`, +}) +export class ProgressBarIndeterminateComponent {}`, + }, + }, + }, +}; + +export const NoLabel: Story = { + render: (args) => ({ props: args, template: commonTemplate }), + args: { + value: 60, + mode: 'determinate', + showValue: false, + }, + parameters: { + docs: { + description: { story: 'Полоса прогресса без числовой метки.' }, + source: { + language: 'ts', + code: ` +import { Component } from '@angular/core'; +import { ProgressBarComponent } from '@cdek-it/angular-ui-kit'; + +@Component({ + selector: 'app-progressbar-no-label', + standalone: true, + imports: [ProgressBarComponent], + template: \` +
+ +
+ \`, +}) +export class ProgressBarNoLabelComponent {}`, + }, + }, + }, +};