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

docs(date-range): add premade shortcuts story #3341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
48 changes: 47 additions & 1 deletion stories/documentation/forms/date2/date-range-input.stories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LOCALE_ID } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { DateRangeInputComponent } from '@lucca-front/ng/date2';
import { CalendarShortcut, DateRangeInputComponent, PremadeShortcuts } from '@lucca-front/ng/date2';
import { FormFieldComponent } from '@lucca-front/ng/form-field';
import { applicationConfig, Meta, moduleMetadata, StoryObj } from '@storybook/angular';
import { cleanupTemplate, generateInputs } from '../../../helpers/stories';
Expand Down Expand Up @@ -53,6 +53,52 @@ export default {
} as Meta;

export const Basic: StoryObj<DateRangeInputComponent> = {
args: {
hideToday: false,
hideWeekend: false,
clearable: false,
mode: 'day',
},
};

const shortcutsStr =
"[\n {\n label: 'Since start of week',\n range: PremadeShortcuts['SinceStartOfWeek']('fr'),\n },\n {\n label: 'Last week',\n range: PremadeShortcuts['LastWeek']('fr'),\n },\n {\n label: 'Last month',\n range: PremadeShortcuts['LastMonth']('fr'),\n },\n]";

export const WithShortcuts: StoryObj<DateRangeInputComponent> = {
render: (args: any, { argTypes }) => {
const { min, max, selected, ...flags } = args;
return {
props: {
min: min ? new Date(min) : null,
max: max ? new Date(max) : null,
shortcuts: [
{
label: 'Since start of week',
range: PremadeShortcuts['SinceStartOfWeek']('fr'),
},
{
label: 'Last week',
range: PremadeShortcuts['LastWeek']('fr'),
},
{
label: 'Last month',
range: PremadeShortcuts['LastMonth']('fr'),
},
] as CalendarShortcut[],
shortcutsStr,
},

template: cleanupTemplate(`
<lu-form-field label="Date range input example" inlineMessage="Inline message example">
<lu-date-range-input [(ngModel)]="selected" [min]="min" [max]="max" [shortcuts]="shortcuts" ${generateInputs(flags, argTypes)}></lu-date-range-input>
</lu-form-field>

<pr-story-model-display>{{selected | json}}</pr-story-model-display>

<h3>Shortcuts:</h3>
<pre>{{shortcutsStr}}</pre>`),
};
},
args: {
hideToday: false,

Expand Down