Skip to content
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

[next] fix(NcDateTimePickerNative): visual fixes #6473

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions src/components/NcDateTimePickerNative/NcDateTimePickerNative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
<NcSelect v-bind="props" v-model="type" />
<NcDateTimePickerNative
v-model="value"
:id="id"
:label="label"
:type="type" />
</div>
Expand All @@ -45,7 +44,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
},
type: 'datetime-local',
value: new Date(),
id: 'date-time-picker',
label: 'Select a new date or time',
}
},
Expand All @@ -66,7 +64,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
<span>Picked date: {{ value || 'null' }}</span>
<NcDateTimePickerNative
v-model="value"
:id="id"
:min="yesterdayDate"
:max="someDate"
:label="label"
Expand All @@ -79,7 +76,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
data() {
return {
value: new Date(),
id: 'date-time-picker',
label: 'Please select a new date',
yesterdayDate: new Date(new Date().setDate(new Date().getDate() - 1)),
someDate: new Date(new Date().setDate(new Date().getDate() + 7)),
Expand All @@ -93,7 +89,11 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p

<template>
<div class="native-datetime-picker">
<label :class="{ 'hidden-visually': hideLabel }" :for="id">{{ label }}</label>
<label class="native-datetime-picker--label"
:class="{ 'hidden-visually': hideLabel }"
:for="id">
{{ label }}
</label>
<input :id="id"
class="native-datetime-picker--input"
:class="inputClass"
Expand All @@ -108,6 +108,7 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p

<script>
import ScopeComponent from '../../utils/ScopeComponent.js'
import GenRandomId from '../../utils/GenRandomId.js'

const inputDateTypes = ['date', 'datetime-local', 'month', 'time', 'week']

Expand All @@ -132,7 +133,8 @@ export default ScopeComponent({
*/
id: {
type: String,
required: true,
default: () => 'date-time-picker-' + GenRandomId(),
validator: id => id.trim() !== '',
},
/**
* type attribute of the input field
Expand Down Expand Up @@ -327,10 +329,30 @@ export default ScopeComponent({
flex-direction: column;
}

.native-datetime-picker .native-datetime-picker--label {
margin-block-end: 2px;
}

.native-datetime-picker .native-datetime-picker--input {
// If border width differs between focused and unfocused we need to compensate to prevent jumping
--input-border-width-offset: calc(var(--border-width-input-focused, 2px) - var(--border-width-input, 2px));
width: 100%;
flex: 0 0 auto;
padding-right: 4px;
margin: 0;
padding-inline-start: calc(var(--border-radius-large) + var(--input-border-width-offset));
padding-inline-end: calc(var(--default-grid-baseline) + var(--input-border-width-offset));
border: var(--border-width-input, 2px) solid var(--color-border-maxcontrast);

&:active:not([disabled]),
&:hover:not([disabled]),
&:focus:not([disabled]),
&:focus-within:not([disabled]) {
border-color: var(--color-main-text);
border-width: var(--border-width-input-focused, 2px);
box-shadow: 0 0 0 2px var(--color-main-background) !important;
// Reset padding offset when focused
--input-border-width-offset: 0px;
}
}

[data-theme-light],
Expand Down
Loading