Skip to content

Commit

Permalink
ci: single run test by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Dec 27, 2021
1 parent 405116e commit e52d57e
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 92 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Lint
on:
pull_request:
branches:
- release
jobs:
build:
name: Lint Codebase
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
cache: 'npm'
node-version: '16'
- run: npm ci
- run: npm run lint
5 changes: 2 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test
on:
push:
branches:
- release
- *
pull_request:
branches:
- release
Expand All @@ -15,8 +15,7 @@ jobs:
node-version: [ 12.x, 14.x, 16.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
- uses: actions/setup-node@v2
with:
cache: 'npm'
node-version: ${{ matrix.node-version }}
Expand Down
171 changes: 92 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# Material Datetimepicker for @angular/material 13.x
Material Datetimepicker for @angular/material
===

## Description

The datetimepicker is taken from [Promact/md2](https://github.com/Promact/md2) and modified to use @angular/material as base and added theming support.

Like the @angular/material datepicker it contains a native-datetime-adapter as well as a moment-datetime-adapter.
> **The example application is on [GitHub Pages](https://kuhnroyal.github.io/mat-datetimepicker/)!**
[![Travis CI](https://travis-ci.org/kuhnroyal/mat-datetimepicker.svg?branch=master)](https://travis-ci.org/kuhnroyal/mat-datetimepicker)
[![Latest Stable Version](https://img.shields.io/npm/v/@mat-datetimepicker/core.svg)](https://www.npmjs.com/package/@mat-datetimepicker/core)
[![License](https://img.shields.io/npm/l/@mat-datetimepicker/core.svg)](https://www.npmjs.com/package/@mat-datetimepicker/core)
[![NPM Downloads](https://img.shields.io/npm/dm/@mat-datetimepicker/core.svg)](https://www.npmjs.com/package/@mat-datetimepicker/core)

---

The datetimepicker was initially taken from [`Promact/md2`](https://github.com/Promact/md2) and modified to
use `@angular/material`. We have also added theming support.

Like the `@angular/material` `datepicker` it contains a native-datetime-adapter as well as a moment-datetime-adapter.

# Contents

* [Usage](#usage)
* [Development](#development)

# Usage

## Installation
Expand All @@ -29,24 +38,25 @@ npm install --save @angular/material-moment-adapter mat-datetimepicker/moment

## Setup

Basically the same way the @angular/material datepicker is configured and imported.
Basically the same way the `@angular/material` datepicker is configured and imported.

```ts
imports: [
...
MatDatepickerModule,
MatDatepickerModule,
// use this if you want to use native javascript dates and INTL API if available
// MatNativeDatetimeModule,
MatMomentDatetimeModule,
MatDatetimepickerModule
]
```

@see [src/app/app.module.ts](src/app/app.module.ts)
@see [`src/app/app.module.ts`](src/app/app.module.ts)

## Using the component

```html

<form [formGroup]="group">
<mat-form-field>
<mat-placeholder>Start DateTime</mat-placeholder>
Expand All @@ -69,8 +79,8 @@ imports: [

## Date formatting

In order to change the default input/output formats,
a custom instance of `MAT_DATETIME_FORMATS` needs to be provided in the global configuration.
In order to change the default input/output formats, a custom instance of `MAT_DATETIME_FORMATS` needs to be provided in
the global configuration.

Input/output formats can be changed separately for the existing datetime picker types
`date`, `month` , `datetime`and `time`.
Expand All @@ -94,86 +104,87 @@ Parsing does not work with the native adapter because the Intl.DateTimeFormat AP

```ts
providers: [
{
provide: MAT_DATETIME_FORMATS,
useValue: {
parse: {},
display: {
dateInput: {
year: "numeric",
month: "2-digit",
day: "2-digit"
},
monthInput: {
month: "long"
},
datetimeInput: {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit"
},
timeInput: {
hour: "2-digit",
minute: "2-digit"
},
monthYearLabel: {
year: "numeric",
month: "short"
},
dateA11yLabel: {
year: "numeric",
month: "long",
day: "numeric"
},
monthYearA11yLabel: {
year: "numeric",
month: "long"
},
popupHeaderDateLabel: {
weekday: "short",
month: "short",
day: "2-digit"
}
{
provide: MAT_DATETIME_FORMATS,
useValue: {
parse: {},
display: {
dateInput: {
year: "numeric",
month: "2-digit",
day: "2-digit"
},
monthInput: {
month: "long"
},
datetimeInput: {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit"
},
timeInput: {
hour: "2-digit",
minute: "2-digit"
},
monthYearLabel: {
year: "numeric",
month: "short"
},
dateA11yLabel: {
year: "numeric",
month: "long",
day: "numeric"
},
monthYearA11yLabel: {
year: "numeric",
month: "long"
},
popupHeaderDateLabel: {
weekday: "short",
month: "short",
day: "2-digit"
}
}
}
]
}
]
```

@see defaults in [native-datetime-formats.ts](projects/core/src/adapter/native-datetime-formats.ts) \
@see Intl.DateTimeFormat API [documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
@see defaults in [`native-datetime-formats.ts`](projects/core/src/adapter/native-datetime-formats.ts) \
@see Intl.DateTimeFormat
API [documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)

### Moment

```ts
providers: [
{
provide: MAT_DATETIME_FORMATS,
useValue: {
parse: {
dateInput: "L",
monthInput: "MMMM",
timeInput: "LT",
datetimeInput: "L LT"
},
display: {
dateInput: "L",
monthInput: "MMMM",
datetimeInput: "L LT",
timeInput: "LT",
monthYearLabel: "MMM YYYY",
dateA11yLabel: "LL",
monthYearA11yLabel: "MMMM YYYY",
popupHeaderDateLabel: "ddd, DD MMM"
}
{
provide: MAT_DATETIME_FORMATS,
useValue: {
parse: {
dateInput: "L",
monthInput: "MMMM",
timeInput: "LT",
datetimeInput: "L LT"
},
display: {
dateInput: "L",
monthInput: "MMMM",
datetimeInput: "L LT",
timeInput: "LT",
monthYearLabel: "MMM YYYY",
dateA11yLabel: "LL",
monthYearA11yLabel: "MMMM YYYY",
popupHeaderDateLabel: "ddd, DD MMM"
}
}
]
}
]
```

@see defaults in [moment-datetime-formats.ts](projects/moment/src/adapter/moment-datetime-formats.ts) \
@see defaults in [`moment-datetime-formats.ts`](projects/moment/src/adapter/moment-datetime-formats.ts) \
@see moment.js [documentation](https://momentjs.com/docs/#/displaying/)

## Theming
Expand Down Expand Up @@ -213,9 +224,11 @@ cd my-project
Add the dependencies to your `package.json`:

```json
"dependencies": {
{
"dependencies": {
"@mat-datetimepicker/core": "8.0.0",
"@mat-datetimepicker/moment": "8.0.0",
"@mat-datetimepicker/moment": "8.0.0"
}
}
```

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lint": "ng lint",
"prepare": "husky install",
"test": "ng test",
"test:watch": "ng test --auto-watch --no-single-run",
"start": "ng serve",
"start:prod": "ng serve --configuration production"
},
Expand Down
6 changes: 3 additions & 3 deletions projects/core/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module.exports = function (config) {
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
autoWatch: false,
browsers: ['ChromeHeadless'],
singleRun: true
});
};
6 changes: 3 additions & 3 deletions projects/moment/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module.exports = function (config) {
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
autoWatch: false,
browsers: ['ChromeHeadless'],
singleRun: true
});
};
8 changes: 4 additions & 4 deletions src/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module.exports = function (config) {
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
autoWatch: false,
browsers: ['ChromeHeadless'],
singleRun: true
});
};
};

0 comments on commit e52d57e

Please sign in to comment.