discourse/app/assets/stylesheets/common/components/date-input.scss
Kris 6640a9d234
UX: improve mobile date picker slightly (#32822)
As seen in the advanced search filters... iOS doesn't show placeholders
for the date input, so we have a CSS adjustment for this, but it doesn't
clear when a value is present.

This update adds a class when a value is present so the placeholder can
be cleared.

Before:

![image](https://github.com/user-attachments/assets/37edad10-886b-41d7-b412-b303be351603)


After:

![image](https://github.com/user-attachments/assets/fee713ab-09f9-49fb-9fda-96bd72a260e1)


Also fixed extra left margin by removing a class.
2025-05-20 11:49:58 -04:00

87 lines
2.2 KiB
SCSS
Vendored

$calendar-icon: '<svg xmlns="http://www.w3.org/2000/svg" width="14px" height="16px" viewBox="0 0 448 512"><path d="M400 64h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zm-6 400H54c-3.3 0-6-2.7-6-6V160h352v298c0 3.3-2.7 6-6 6z"></path></svg>';
.d-date-input {
display: inline-flex;
cursor: pointer;
flex-direction: column;
min-width: 140px;
flex: 1 0 auto;
.date-picker {
cursor: pointer;
margin: 0;
text-align: left;
width: 100%;
box-shadow: none;
position: relative;
&::placeholder {
font-size: var(--font-0);
color: var(--primary-medium);
}
&:focus {
@include default-focus;
}
// iOS doesn't display the placeholder attribute for date inputs
html.ios-device &:not(.--has-value)::after {
font-size: var(--font-0);
color: var(--primary-medium);
content: attr(placeholder);
}
// use custom icon and fix issues across browsers
// - Safari does not use an icon
// - default Chrome/IE icon too tall, makes input height inconsistent
// - default Chrome/IE icon are black on dark themes
// - allows themes to style as needed
// Note that this does nothing in Firefox
html:not(.ios-device) & {
&::after {
content: "";
mask: svg-uri($calendar-icon) no-repeat 50% 50%;
position: absolute;
right: 4px;
top: 0;
box-sizing: border-box;
background-color: var(--primary);
height: 100%;
width: 20px;
z-index: 1;
}
&::-webkit-calendar-picker-indicator {
background: transparent;
position: absolute;
cursor: pointer;
right: 0;
z-index: 2;
}
}
}
.pika-single {
margin-left: -1px;
margin-top: 1px;
.pika-row td {
.pika-button.pika-day {
box-shadow: none;
border-radius: 0;
}
}
}
}
.d-date-input + .d-time-input {
margin-left: 1px;
}
.d-time-input + .d-date-input {
margin-left: 1px;
}
.d-date-input + .clear-date-time {
margin-left: 1px;
}