Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
uvarov-frontend committed Sep 15, 2023
1 parent 42a54ac commit 9cfb844
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/en/learn/action-handlers/get-and-change-every-day.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Get and change every day

By having access to each day, we may post additional information or otherwise change each day on the calendar.

As an example, let's add a random cost to each day.

<Sandbox example="action-handlers-get-and-change-every-day" />
2 changes: 1 addition & 1 deletion docs/en/reference/additionally/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@ new VanillaCalendar('#calendar', {
});
```

The method is triggered when the calendar is initialized and the month and year are changed. Allows you to get the necessary information about each day and its HTML element.
The method is triggered when the calendar is initialized and any change. Allows you to get the necessary information about each day and its HTML element.
Parameters that can be obtained: `day` - day number, `date` - full date in `YYYY-MM-DD` format, `HTMLElement` - parent (wrapper) HTML element of the day, `HTMLButtonElement` - child (button) HTML element of the day.
7 changes: 7 additions & 0 deletions docs/ru/learn/action-handlers/get-and-change-every-day.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Получить и изменить каждый день

Имея доступ к каждому дню, мы можем публиковать дополнительную информацию или иным образом изменять каждый день в календаре.

В качестве примера давайте добавим рандомную стоимость к каждому дню.

<Sandbox example="action-handlers-get-and-change-every-day" />
2 changes: 1 addition & 1 deletion docs/ru/reference/additionally/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,5 @@ new VanillaCalendar('#calendar', {
});
```

Метод срабатывает при инициализации календаря и изменении месяца и года. Позволяет получить необходимую информацию о каждом дне и его HTML-элементе.
Метод срабатывает при инициализации календаря и любых изменениях. Позволяет получить необходимую информацию о каждом дне и его HTML-элементе.
Параметры, которые можно получить: `day` - номер дня, `date` - полная дата в формате `YYYY-MM-DD`, `HTMLElement` - родительский (обертка) HTML-элемент дня, `HTMLButtonElement` - дочерний (кнопка) HTML-элемент дня.
23 changes: 23 additions & 0 deletions examples/action-handlers-get-and-change-every-day.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import VanillaCalendar from '@uvarov.frontend/vanilla-calendar';
import '@uvarov.frontend/vanilla-calendar/build/vanilla-calendar.min.css';
import '@uvarov.frontend/vanilla-calendar/build/themes/light.min.css';
import '@uvarov.frontend/vanilla-calendar/build/themes/dark.min.css';

const options = {
actions: {
getDays(day, date, HTMLElement, HTMLButtonElement) {
const randomBoolean = Math.random() < 0.5;
if (!randomBoolean) return;
const randomPrice = Math.floor(Math.random() * (999 - 100 + 1) + 100);

HTMLButtonElement.style.flexDirection = 'column';
HTMLButtonElement.innerHTML = `
<span>${day}</span>
<span style="font-size: 8px;color: #8BC34A;">$${randomPrice}</span>
`;
},
},
};

const calendar = new VanillaCalendar('#calendar', options);
calendar.init();
2 changes: 2 additions & 0 deletions examples/type-of-calendar-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import '@uvarov.frontend/vanilla-calendar/build/themes/dark.min.css';

const options = {
type: 'multiple',
months: 2,
jumpMonths: 2,
};

const calendar = new VanillaCalendar('#calendar', options);
Expand Down

0 comments on commit 9cfb844

Please sign in to comment.