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

Timepicker accessibility #531

Merged
Merged
Show file tree
Hide file tree
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
95 changes: 71 additions & 24 deletions sass/components/_timepicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
width: auto;
flex: 1 auto;
background-color: var(--md-sys-color-primary);;
padding: 10px;
padding: 2rem .67rem .67rem .67rem;
font-weight: 300;
}

.timepicker-text-container {
font-size: 4rem;
font-weight: bold;
text-align: left;
color: var(--font-on-primary-color-medium);
font-weight: 400;
Expand All @@ -43,21 +42,33 @@
}
}

.timepicker-display-column {
display: inline-flex;
}

.timepicker-input-hours-wrapper,
.timepicker-input-minutes-wrapper {
width: 6.9rem;
height: 5.2rem;
}

.timepicker-input-hours,
.timepicker-input-minutes,
.timepicker-span-am-pm div {
cursor: pointer;
}

input[type=text].timepicker-input-hours {
text-align: right;
width: 28%;
margin-right: 3px;
input[type=text].timepicker-input-hours,
input[type=text].timepicker-input-minutes {
height: 100%;
padding: .8rem;
border: 0;
text-align: center;
}

input[type=text].timepicker-input-minutes {
width: 33%;
margin-left: 3px;
.timepicker-input-divider-wrapper {
width: 1.6rem;
text-align: center;
}

input[type=text].text-primary {
Expand All @@ -67,36 +78,55 @@ input[type=text].text-primary {
.timepicker-display-am-pm {
font-size: 1.3rem;
position: absolute;
top: 1.2rem;
top: 1rem;
right: 1rem;
bottom: auto;
font-weight: 400;
}

.timepicker-span-am-pm {
height: 5.2rem;
max-width: 3.5rem;
}

.timepicker-modal .am-btn,
.timepicker-modal .pm-btn {
width: 3.6rem;
height: 2rem;
height: 50%;
padding-left: calc(var(--btn-padding) / 1.6);
padding-right: calc(var(--btn-padding) / 1.6);
line-height: 2rem;
vertical-align: middle;
text-align: center;
background-color: transparent;
border: 1px solid var(--md-sys-color-outline);
}

.timepicker-modal .am-btn {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}

.timepicker-modal .pm-btn {
border-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
}

/* Analog Clock Display */
.timepicker-analog-display {
flex: 2.5 auto;
padding: .67rem;
background-color: var(--md-sys-color-surface);
}

.timepicker-plate {
background-color: rgba(0, 0, 0, 0.09);
border-radius: 50%;
width: 270px;
height: 270px;
width: 260px;
height: 260px;
overflow: visible;
position: relative;
margin: 30px 14px 14px;
padding: 10px;
margin: 2rem 1.6rem 1.6rem 1.6rem;
user-select: none;
}

Expand Down Expand Up @@ -193,40 +223,57 @@ input[type=text].text-primary {
}

/* Media Queries */
@media #{$medium-and-up} {
@media #{$large-and-up} {
.timepicker-modal {
max-width: 600px;
width: auto;
max-width: 620px;
}

.timepicker-container.modal-content {
flex-direction: row;
}

.timepicker-digital-display {
padding: .67rem;
}

.timepicker-text-container {
top: 32%;
padding: 0;
top: 31%;
text-align: center;
}

.timepicker-display-am-pm {
position: relative;
top: auto;
right: auto;
bottom: auto;
text-align: center;
margin-top: 1.2rem;
}

input[type=text].timepicker-input-minutes {
min-width: 5.3rem;
.timepicker-span-am-pm {
max-width: unset;
}

.timepicker-modal .am-btn,
.timepicker-modal .pm-btn {
width: auto;
height: auto;
padding-left: var(--btn-padding);
padding-right: var(--btn-padding);
border-radius: var(--btn-border-radius);
border: 1px solid var(--md-sys-color-outline);
line-height: inherit;
vertical-align: top;
text-align: inherit;
}

.timepicker-modal .am-btn {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}

.timepicker-modal .pm-btn {
border-left: 0;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
}
24 changes: 15 additions & 9 deletions src/timepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ export class Timepicker extends Component<TimepickerOptions> {
if (this.options.twelveHour) {
// AM Button
this._amBtn = document.createElement('div');
this._amBtn.classList.add('am-btn');
this._amBtn.classList.add('am-btn', 'btn');
this._amBtn.innerText = 'AM';
this._amBtn.addEventListener('click', this._handleAmPmClick);
this.spanAmPm.appendChild(this._amBtn);
// PM Button
this._pmBtn = document.createElement('div');
this._pmBtn.classList.add('pm-btn');
this._pmBtn.classList.add('pm-btn', 'btn');
this._pmBtn.innerText = 'PM';
this._pmBtn.addEventListener('click', this._handleAmPmClick);
this.spanAmPm.appendChild(this._pmBtn);
Expand Down Expand Up @@ -552,12 +552,12 @@ export class Timepicker extends Component<TimepickerOptions> {
_updateAmPmView() {
if (this.options.twelveHour) {
if (this.amOrPm === 'PM') {
this._amBtn.classList.remove('text-primary');
this._pmBtn.classList.add('text-primary');
this._amBtn.classList.remove('filled');
this._pmBtn.classList.add('filled');
}
else if (this.amOrPm === 'AM') {
this._amBtn.classList.add('text-primary');
this._pmBtn.classList.remove('text-primary');
this._amBtn.classList.add('filled');
this._pmBtn.classList.remove('filled');
}
}
}
Expand Down Expand Up @@ -834,9 +834,15 @@ export class Timepicker extends Component<TimepickerOptions> {
<div class="timepicker-digital-display">
<div class="timepicker-text-container">
<div class="timepicker-display-column">
<input type="text" maxlength="2" autofocus class="timepicker-input-hours text-primary" />
:
<input type="text" maxlength="2" class="timepicker-input-minutes" />
<div class="timepicker-input-hours-wrapper">
<input type="text" maxlength="2" autofocus class="timepicker-input-hours text-primary" />
</div>
<div class="timepicker-input-divider-wrapper">
<span class="timepicker-input-divider">:</span>
</div>
<div class="timepicker-input-minutes-wrapper">
<input type="text" maxlength="2" class="timepicker-input-minutes" />
</div>
</div>
<div class="timepicker-display-column timepicker-display-am-pm">
<div class="timepicker-span-am-pm"></div>
Expand Down