Comments (7)
from vaadin-minicalendar.
Hey @fschon! I do get 1 and 2 (so I think 😅) but you'd need to elaborate on your 3rd suggestion.
Do you wish to have a specific styling for some days?
from vaadin-minicalendar.
Yes. In my use case, each available day should have a different styling to non available days. So only two different styles necessary - available or not available styles.
But I thought that maybe someone would have a need for more than one styling option for days, therefore the "list of lists of stylings". So maybe:
- a list of available styled days
- a list of not available styled days
- and a list of public holiday styled days.
Of course some kind of styling priority would have to be defined - maybe last one wins?
Thanks in advance for updating the component.
from vaadin-minicalendar.
Hey @fschon, thanks for your suggestions.
I just checked the Vaadin internal com.vaadin.flow.component.datepicker.DatePicker
but I could not find a constructor allowing you to define the valid range (a.k.a. setMin(LocalDate) and setMax(LocalDate)).
(As a side note: I updated the AddOn to Vaadin to 24.3.9
)
MiniCalendar
provides a setDayEnabledProvider(SerializablePredicate<LocalDate>)
method to dynamically en- or disable days for selection. This could also be a more complex predicate like the following:
miniCalendar.setDayEnabledProvider(date ->
date.isAfter(LocalDate.of(2024, Month.APRIL, 1)) &&
date.isBefore(LocalDate.of(2024, Month.MAY, 1)) &&
isNoPublicHoliday(date)
);
Same goes for adding styles to your days. You can simply use setDayStyleProvider(SerializableFunction<LocalDate, List<String>>)
to dynamically add (multiple) styles to a certain date:
List<LocalDate> publicHolidays = gatherYourLocalHolidays();
miniCalendar.setDayStyleProvider(day -> {
if (publicHolidays.contains(day)) {
return List.of("public-holiday", "some-other-spicy-style");
}
return null;
});
Regarding the public holidays you mentioned I am not quite sure what you mean. Holidays differ by country and there's no easy way (that I know of) to trustworthy check for them using the standard Java LocalDate API. I'd like to not include any 3rd party libraries into the AddOn if not really necessary.
That's the reason I tried to make it quite flexible in the first place.
If your request adresses convenience I can surely provide an additional constructor in which you can directly pass a dayEnabledProvider
and a dayStyleProvider
.
Please let me know if this helps you already or if you still need a change 🙂
from vaadin-minicalendar.
Hey @fschon, thanks for clarification.
I think I understand better what you mean now.
The component does not actually make server roundtrips for the styles to be applied, it happens server side before the component gets "drawn".
I just adapted my showcase sample to add styles to each day and just increment a counter, so that the data is dynamic, see below screen capture:
MiniCalendar_StyleProvider.mp4
So if you already have static information about the stylings you wish to apply, you've basically already won.
My warning in the documentation refers to heavy db operations in these callbacks, which is really (really) a bad thing to do.
If you e.g. load the data on view creation, store the reference in a local var and use that var in the style provider you should be fine.
If you experience this differently it would be super nice to have a minimalist sample project to play around, or maybe also a short screencast of the roundtrips you're experiencing.
Please don't get me wrong, I'm really not trying to "not do that change" for you, I'm just trying to figure out what the best solution could be 😅
I also was thinking about adding the actual date as a css class to the span of the days. In this way you could simply inject CSS into your page and you'd also be ready 2 go.
However I'm still debating with myself whether I like this or not 😆
from vaadin-minicalendar.
from vaadin-minicalendar.
Yep, there are no client-server roundtrips per day. The creation of the layout happens server side and before the component gets attached. As I said, it's just not a good idea to have some heavy computation in these callbacks as they can get called quite a few times when you navigate through the calendar.
I'm closing this issue now but please do let me know when you really have some performance issues and see any possible enhancements. 🙂
from vaadin-minicalendar.
Related Issues (20)
- Make TextFormat for days configurable
- Add Checkstyle to project
- Automatically deploy new showcase versions to online hosting provider HOT 1
- Fix GitHub workflow configuration
- Fix resource includes
- False MANIFEST.MF entry preventing vaadin release
- False MANIFEST.MF entry in publishable archive preventing vaadin release
- Bump Vaadin to 23.3.5
- Automatically build & publish runnable docker image to GitHub Packages on release
- Add manual trigger to deploy branch to railway
- Maven Multi-Module Setup breaks the Release
- Exclude org.slf4j:slf4j-simple from addon release build
- Bump Vaadin to 24.0.3
- Fix Dockerfile setup
- Add separate Dockerfile for Railway.app deployment
- Fix Railway Pipeline HOT 2
- Calendar styling not applied HOT 3
- Bump Vaadin to 24.3.9
- Bump Showcase Tomcat version to 10.1.7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vaadin-minicalendar.