Description
Currently the Calendar component can't prevent users from selecting certain days. That is, we can click on any cell and the day will be selected. Also we can't customize the month names and the week days.
Suggested Solution
My suggested solution involves the addition of some new fields to the Calendar, such as
# for German
Calendar(
#German months
month_names=['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni' ,'Juli', 'August', 'September', 'Oktober','November', 'Dezember']
# German week days: Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag, Sonntag
# For german we could rename the week days such as the ones below
week_days= [ 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'Si' ],
# the user will be able to select only Montag, Mittwoch, and Donnerstag, because the other weak days the biz isn't opened
# I'm not considering week days as an array which starts by 0
valid_days=[1, 3, 5],
)
Calendar(
#Portuguese months
month_names=['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho' ,'Julio', 'Agosto', 'Setembro', 'Outubro','Novembro', 'Dezembro']
# Portuguese week days: Domingo, Segunda, Terça, Quarta, Quinta, Sexta, Sábado
# The first day of the week starts with Sunday
week_days= [ 'Do', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab' ],
# the user will be able to select only Segunda, Quarta, and Quinta, because the other weak days the biz isn't opened
# I'm not considering week days as an array which starts by 0
valid_days=[2, 4, 5],
)
month_names : Array of str
week_names : Array of str
valid_days : Array of ints
Alternatives
Perhaps customizing input type="date with Rio theme will prove easier an quicker to maintain. However, the level of control will decay.
Additional Context
I've looked into calendar.ts inside rio/frontend/code/components and I noticed the properties: monthNamesLong?: Array<string>, and dayNamesLong?: Array<string>. If those props are made public to Python, we can easily customize month and week days. Also there are some methods which might need some changes:
- updateElement; so we don't select some days: adding a new SCSS rule perhaps ? for invalid week days
- updateGrid: call new week days inside for loop, change classes.push("rio-calendar-selected-day") to something like classes.push("rio-calendar-unselected-day") for days we cant select
Related Issues/Pull Requests
None, I've searched at Discussions, Issues and Discord.
Description
Currently the Calendar component can't prevent users from selecting certain days. That is, we can click on any cell and the day will be selected. Also we can't customize the month names and the week days.
Suggested Solution
My suggested solution involves the addition of some new fields to the Calendar, such as
month_names : Array of str
week_names : Array of str
valid_days : Array of ints
Alternatives
Perhaps customizing
input type="datewith Rio theme will prove easier an quicker to maintain. However, the level of control will decay.Additional Context
I've looked into calendar.ts inside rio/frontend/code/components and I noticed the properties:
monthNamesLong?: Array<string>, anddayNamesLong?: Array<string>. If those props are made public to Python, we can easily customize month and week days. Also there are some methods which might need some changes:Related Issues/Pull Requests
None, I've searched at Discussions, Issues and Discord.