Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
feat(datepicker): Added datepicker component.
Browse files Browse the repository at this point in the history
Fixes #894
  • Loading branch information
thomaspink authored and nimrod13 committed Nov 18, 2020
1 parent ccd282f commit 9d2101c
Show file tree
Hide file tree
Showing 19 changed files with 1,326 additions and 2 deletions.
41 changes: 41 additions & 0 deletions apps/dev/src/datepicker/datepicker-demo.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,53 @@
<h1>Datepicker</h1>

<h2>Full datepicker</h2>

<dt-datepicker
[startAt]="startAt"
[disabled]="isDatepickerDisabled"
[isTimeEnabled]="isDatepickerTimeEnabled"
></dt-datepicker>

<dt-checkbox [(ngModel)]="isDatepickerDisabled">Disabled</dt-checkbox>
<dt-checkbox [(ngModel)]="isDatepickerTimeEnabled"
>Enabled Time Mode</dt-checkbox
>

<h2>Calendar</h2>

<dt-calendar [startAt]="startAt"></dt-calendar>

<h2>Calendar body only</h2>

<dt-calendar-body [activeDate]="startAt"></dt-calendar-body>

<h2>Timepicker</h2>

<dt-timepicker [disabled]="isTimepickerDisabled"></dt-timepicker>

<dt-checkbox [(ngModel)]="isTimepickerDisabled">Disabled</dt-checkbox>

<div dtTheme=":dark" class="dt-example-dark">
<h2>Full Dark Mode Datepicker</h2>

<dt-datepicker
[startAt]="startAt"
[disabled]="isDarkDatepickerDisabled"
[isTimeEnabled]="isDarkDatepickerTimeEnabled"
></dt-datepicker>
<dt-checkbox [(ngModel)]="isDarkDatepickerDisabled">Disabled</dt-checkbox>
<dt-checkbox [(ngModel)]="isDarkDatepickerTimeEnabled"
>Enabled Time Mode</dt-checkbox
>

<h2>Dark Mode Calendar</h2>

<dt-calendar [startAt]="startAt"></dt-calendar>

<h2>Dark Mode Calendar Body Only</h2>

<dt-calendar-body [activeDate]="startAt"></dt-calendar-body>

<h2>Dark Mode Timepicker</h2>

<dt-timepicker
Expand Down
5 changes: 5 additions & 0 deletions apps/dev/src/datepicker/datepicker-demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import { Component } from '@angular/core';
styleUrls: ['datepicker-demo.component.scss'],
})
export class DatepickerDemo {
startAt = new Date(2020, 7, 31);
isDatepickerDisabled = false;
isTimepickerDisabled = false;
isDarkDatepickerDisabled = false;
isDarkTimepickerDisabled = false;
isDatepickerTimeEnabled = true;
isDarkDatepickerTimeEnabled = true;
}
6 changes: 6 additions & 0 deletions libs/barista-components/experimental/datepicker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ ng_module_view_engine(
),
angular_assets = [
":styles",
"src/datepicker.html",
"src/calendar.html",
"src/calendar-body.html",
"src/timepicker.html",
"src/timeinput.html",
],
Expand Down Expand Up @@ -58,6 +61,9 @@ sass_library(
multi_sass_binary(
name = "styles",
srcs = [
"src/datepicker.scss",
"src/calendar-body.scss",
"src/calendar.scss",
"src/timepicker.scss",
"src/timeinput.scss",
":theme"
Expand Down
3 changes: 3 additions & 0 deletions libs/barista-components/experimental/datepicker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

export * from './src/calendar-body';
export * from './src/calendar';
export * from './src/timeinput';
export * from './src/timepicker';
export * from './src/datepicker';
export * from './src/datepicker-module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<span
[attr.id]="_labelid"
class="dt-calendar-body-header-label"
aria-live="polite"
>{{ _label }}</span
>

<table
class="dt-calendar-table"
role="grid"
[attr.aria-labelledby]="ariaLabelledby || _labelid"
[attr.aria-describedby]="ariaLabelledby || _labelid"
>
<thead class="dt-calendar-table-header">
<tr>
<th
scope="col"
*ngFor="let day of _weekdays"
[attr.aria-label]="day.long"
[attr.abbr]="day.short"
>
{{ day.short }}
</th>
</tr>
</thead>
<tbody class="dt-calendar-table-body">
<tr
*ngFor="let week of _weeks; let weekIndex = index"
role="row"
class="dt-calendar-table-row"
>
<td
*ngIf="weekIndex === 0 && _firstRowOffset"
aria-hidden="true"
[attr.colspan]="_firstRowOffset"
></td>
<td
*ngFor="let cell of week; let dateIndex = index"
role="gridcell"
class="dt-calendar-table-cell"
[class.dt-calendar-active]="_isSame(cell, activeDate)"
[class.dt-calendar-selected]="_isSame(cell, selected)"
[attr.aria-selected]="_isSame(cell, selected)"
[attr.aria-label]="cell.ariaLabel"
(click)="_cellClicked(cell)"
>
<div class="dt-calendar-table-cell-inner">
{{ cell.displayValue }}
</div>
</td>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@import '../../../core/src/style/variables';
@import './calendar-body-theme';

:host {
display: block;
outline: none;
}

.dt-calendar-table {
border-spacing: 0;
border-collapse: collapse;
width: 100%;
}

.dt-calendar-table-header th {
text-align: center;
padding: 0 0 8px;
width: 14%;
}

.dt-calendar-table-cell {
position: relative;
text-align: center;
outline: none;
cursor: pointer;
}

.dt-calendar-table-cell:not(.dt-calendar-selected):hover
.dt-calendar-table-cell-inner {
background: $gray-200;
}

.dt-calendar-table-cell-inner {
padding: 2px 0;
border: 1px solid white;
border-radius: 3px;
}

.dt-calendar-active .dt-calendar-table-cell-inner {
border-color: $disabledcolor;
}

:host:focus .dt-calendar-active .dt-calendar-table-cell-inner {
border-color: $turquoise-600;
}

.dt-calendar-selected .dt-calendar-table-cell-inner {
background-color: $turquoise-600;
color: white;
}

.dt-calendar-body-header-label {
display: none;
}
Loading

0 comments on commit 9d2101c

Please sign in to comment.