Skip to content

feat: Add part to ion-datetime component to allow CSS customization #24963

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

Closed
3 tasks done
iwoogy opened this issue Mar 18, 2022 · 11 comments
Closed
3 tasks done

feat: Add part to ion-datetime component to allow CSS customization #24963

iwoogy opened this issue Mar 18, 2022 · 11 comments
Labels

Comments

@iwoogy
Copy link

iwoogy commented Mar 18, 2022

Prerequisites

Describe the Feature Request

I would like to customize the CSS styles of the ion-datetime in a more precise way.

I read this article that explain how to access styles inside the shadow dom.
https://ionicframework.com/docs/theming/css-shadow-parts

I noticed that parts are not exposed in the ion-datetime
image

Describe the Use Case

I would like to implement that kind of styling

image

Describe Preferred Solution

Adding part attribtues to the shadow root children will help to access the styling of ion-datetime component

Describe Alternatives

No alternative for now.

Related Code

The code is pretty simple

image

image

image

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Mar 18, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the issue. Could you help me understand which parts of ion-datetime you are unable to style?

Datetime has several CSS Variables that you can use as well as the color property to customize the overall theme of the component.

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Mar 18, 2022
@ionitron-bot ionitron-bot bot removed the triage label Mar 18, 2022
@iwoogy
Copy link
Author

iwoogy commented Mar 19, 2022

I would need for instance to change the style of the selectable dates

image

From the documentation, it seems like there are only 3 custom css properties available

image

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Mar 19, 2022
@indraraj26
Copy link

Look like there are multiple event as per event, You want to apply background.

@iwoogy Is purple square selected one ?

@iwoogy
Copy link
Author

iwoogy commented Mar 20, 2022

The purple square is just an annotation.
This new legend will help understand the feature as the designer intended it.

image

@liamdebeasi
Copy link
Contributor

We encourage developers to theme components in a way that matches the overall theme of their application. To this, you can generate a new custom color theme and use the color property to apply these styles. I used https://ionicframework.com/docs/theming/colors#new-color-creator to do this.

Here is an example: https://codepen.io/liamdebeasi/pen/YzYWBgV

The :root and .ion-color-custom classes are a bit involved, but the idea is that these styles are used across your entire application, not just for ion-datetime. From there, you can style ion-datetime specific styles in the ion-datetime selector block.

Can you try this and let me know if it works?

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Mar 21, 2022
@ionitron-bot ionitron-bot bot removed the triage label Mar 21, 2022
@iwoogy
Copy link
Author

iwoogy commented Mar 22, 2022

Thanks for your support.

It works to fulfill 50% of the designer requirements.

The today date and the selected date have to be the same color using the color attribute.
The disabled dates do not seem to be configurable.
The selectables dates styles cannot be changed.

Does the styling of the shadow parts could help allowing more control over the styling ?

Is it possible to hide the weekdays in order to have many ion-date components on the same page with only one weekdays header ?

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Mar 22, 2022
@liamdebeasi
Copy link
Contributor

Can you provide your use cases for these additional customizations? We intended for ion-datetime to match the native calendar picker components as closely as possible.

At the moment it is not possible to hide the weekdays on the datetime component.

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Mar 22, 2022
@ionitron-bot ionitron-bot bot removed the triage label Mar 22, 2022
@iwoogy
Copy link
Author

iwoogy commented Mar 23, 2022

Can you provide your use cases for these additional customizations? We intended for ion-datetime to match the native calendar picker components as closely as possible.

I'm in the process of converting a NativeScript into Ionic. I used to implement the graphic designer requirements in NativeScript in a custom calendar. I was wondering if the new component can help reproduce the same requirements.

image

At the moment it is not possible to hide the weekdays on the datetime component.

Ok. Noted.

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Mar 23, 2022
@iwoogy iwoogy closed this as completed Mar 23, 2022
@ckang777
Copy link

Hello @iwoogy. Looks like you closed this issue. Were you able to resolve this issue? If so how did you achieve this? I'm in the same boat and wanted a solution for this use case. Thanks.

@iwoogy
Copy link
Author

iwoogy commented Mar 26, 2022

Hello @ckang777

I didn't solve the issue. I negociated with the graphic designer to scale down the customisation ambition to fit the current constraint.

@ionitron-bot
Copy link

ionitron-bot bot commented Apr 25, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants