-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(datetime): add highlightedDates playgrounds (#2769)
- Loading branch information
1 parent
e369a87
commit 8036f63
Showing
30 changed files
with
924 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
static/usage/v6/datetime/highlightedDates/array/angular/example_component_html.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```html | ||
<ion-datetime | ||
presentation="date" | ||
value="2023-01-01" | ||
[highlightedDates]="highlightedDates" | ||
></ion-datetime> | ||
``` |
32 changes: 32 additions & 0 deletions
32
static/usage/v6/datetime/highlightedDates/array/angular/example_component_ts.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
```ts | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: 'example.component.html', | ||
}) | ||
export class ExampleComponent { | ||
highlightedDates = [ | ||
{ | ||
date: '2023-01-05', | ||
textColor: '#800080', | ||
backgroundColor: '#ffc0cb', | ||
}, | ||
{ | ||
date: '2023-01-10', | ||
textColor: '#09721b', | ||
backgroundColor: '#c8e5d0', | ||
}, | ||
{ | ||
date: '2023-01-20', | ||
textColor: 'var(--ion-color-secondary-contrast)', | ||
backgroundColor: 'var(--ion-color-secondary)', | ||
}, | ||
{ | ||
date: '2023-01-23', | ||
textColor: 'rgb(68, 10, 184)', | ||
backgroundColor: 'rgb(211, 200, 229)' | ||
} | ||
]; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Datetime</title> | ||
<link rel="stylesheet" href="../../../../common.css" /> | ||
<script src="../../../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/css/ionic.bundle.css" /> | ||
<style> | ||
ion-datetime { | ||
width: 350px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-datetime presentation="date" value="2023-01-01"></ion-datetime> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
|
||
<script> | ||
const datetime = document.querySelector('ion-datetime'); | ||
datetime.highlightedDates = [ | ||
{ | ||
date: '2023-01-05', | ||
textColor: '#800080', | ||
backgroundColor: '#ffc0cb', | ||
}, | ||
{ | ||
date: '2023-01-10', | ||
textColor: '#09721b', | ||
backgroundColor: '#c8e5d0', | ||
}, | ||
{ | ||
date: '2023-01-20', | ||
textColor: 'var(--ion-color-secondary-contrast)', | ||
backgroundColor: 'var(--ion-color-secondary)', | ||
}, | ||
{ | ||
date: '2023-01-23', | ||
textColor: 'rgb(68, 10, 184)', | ||
backgroundColor: 'rgb(211, 200, 229)' | ||
} | ||
]; | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react from './react.md'; | ||
import vue from './vue.md'; | ||
|
||
import angular_example_component_html from './angular/example_component_html.md'; | ||
import angular_example_component_ts from './angular/example_component_ts.md'; | ||
|
||
<Playground | ||
size="medium" | ||
version={6} | ||
code={{ | ||
javascript, | ||
react, | ||
vue, | ||
angular: { | ||
files: { | ||
'src/app/example.component.html': angular_example_component_html, | ||
'src/app/example.component.ts': angular_example_component_ts, | ||
}, | ||
}, | ||
}} | ||
src="usage/v6/datetime/highlightedDates/array/demo.html" | ||
/> |
29 changes: 29 additions & 0 deletions
29
static/usage/v6/datetime/highlightedDates/array/javascript.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
```html | ||
<ion-datetime presentation="date" value="2023-01-01"></ion-datetime> | ||
|
||
<script> | ||
var datetime = document.querySelector('ion-datetime'); | ||
datetime.highlightedDates = [ | ||
{ | ||
date: '2023-01-05', | ||
textColor: '#800080', | ||
backgroundColor: '#ffc0cb', | ||
}, | ||
{ | ||
date: '2023-01-10', | ||
textColor: '#09721b', | ||
backgroundColor: '#c8e5d0', | ||
}, | ||
{ | ||
date: '2023-01-20', | ||
textColor: 'var(--ion-color-secondary-contrast)', | ||
backgroundColor: 'var(--ion-color-secondary)', | ||
}, | ||
{ | ||
date: '2023-01-23', | ||
textColor: 'rgb(68, 10, 184)', | ||
backgroundColor: 'rgb(211, 200, 229)' | ||
} | ||
]; | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
```tsx | ||
import React from 'react'; | ||
import { IonDatetime } from '@ionic/react'; | ||
function Example() { | ||
return ( | ||
<IonDatetime | ||
presentation="date" | ||
value="2023-01-01" | ||
highlightedDates={[ | ||
{ | ||
date: '2023-01-05', | ||
textColor: '#800080', | ||
backgroundColor: '#ffc0cb', | ||
}, | ||
{ | ||
date: '2023-01-10', | ||
textColor: '#09721b', | ||
backgroundColor: '#c8e5d0', | ||
}, | ||
{ | ||
date: '2023-01-20', | ||
textColor: 'var(--ion-color-secondary-contrast)', | ||
backgroundColor: 'var(--ion-color-secondary)', | ||
}, | ||
{ | ||
date: '2023-01-23', | ||
textColor: 'rgb(68, 10, 184)', | ||
backgroundColor: 'rgb(211, 200, 229)' | ||
} | ||
]} | ||
></IonDatetime> | ||
); | ||
} | ||
export default Example; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
```html | ||
<template> | ||
<ion-datetime | ||
presentation="date" | ||
value="2023-01-01" | ||
:highlighted-dates="highlightedDates" | ||
></ion-datetime> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { IonDatetime } from '@ionic/vue'; | ||
import { defineComponent } from 'vue'; | ||
export default defineComponent({ | ||
components: { IonDatetime }, | ||
setup() { | ||
const highlightedDates = [ | ||
{ | ||
date: '2023-01-05', | ||
textColor: '#800080', | ||
backgroundColor: '#ffc0cb', | ||
}, | ||
{ | ||
date: '2023-01-10', | ||
textColor: '#09721b', | ||
backgroundColor: '#c8e5d0', | ||
}, | ||
{ | ||
date: '2023-01-20', | ||
textColor: 'var(--ion-color-secondary-contrast)', | ||
backgroundColor: 'var(--ion-color-secondary)', | ||
}, | ||
{ | ||
date: '2023-01-23', | ||
textColor: 'rgb(68, 10, 184)', | ||
backgroundColor: 'rgb(211, 200, 229)' | ||
} | ||
]; | ||
return { highlightedDates } | ||
} | ||
}); | ||
</script> | ||
``` |
3 changes: 3 additions & 0 deletions
3
...c/usage/v6/datetime/highlightedDates/callback/angular/example_component_html.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```html | ||
<ion-datetime presentation="date" [highlightedDates]="highlightedDates"></ion-datetime> | ||
``` |
30 changes: 30 additions & 0 deletions
30
static/usage/v6/datetime/highlightedDates/callback/angular/example_component_ts.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
```ts | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: 'example.component.html', | ||
}) | ||
export class ExampleComponent { | ||
highlightedDates = (isoString) => { | ||
const date = new Date(isoString); | ||
const utcDay = date.getUTCDate(); | ||
|
||
if(utcDay % 5 === 0) { | ||
return { | ||
textColor: '#800080', | ||
backgroundColor: '#ffc0cb', | ||
}; | ||
} | ||
|
||
if(utcDay % 3 === 0) { | ||
return { | ||
textColor: 'var(--ion-color-secondary-contrast)', | ||
backgroundColor: 'var(--ion-color-secondary)', | ||
}; | ||
} | ||
|
||
return undefined; | ||
}; | ||
} | ||
``` |
53 changes: 53 additions & 0 deletions
53
static/usage/v6/datetime/highlightedDates/callback/demo.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Datetime</title> | ||
<link rel="stylesheet" href="../../../../common.css" /> | ||
<script src="../../../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/css/ionic.bundle.css" /> | ||
<style> | ||
ion-datetime { | ||
width: 350px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-datetime presentation="date"></ion-datetime> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
|
||
<script> | ||
const datetime = document.querySelector('ion-datetime'); | ||
datetime.highlightedDates = (isoString) => { | ||
const date = new Date(isoString); | ||
const utcDay = date.getUTCDate(); | ||
|
||
if(utcDay % 5 === 0) { | ||
return { | ||
textColor: '#800080', | ||
backgroundColor: '#ffc0cb', | ||
}; | ||
} | ||
|
||
if(utcDay % 3 === 0) { | ||
return { | ||
textColor: 'var(--ion-color-secondary-contrast)', | ||
backgroundColor: 'var(--ion-color-secondary)', | ||
}; | ||
} | ||
|
||
return undefined; | ||
}; | ||
</script> | ||
</body> | ||
|
||
</html> |
25 changes: 25 additions & 0 deletions
25
static/usage/v6/datetime/highlightedDates/callback/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react from './react.md'; | ||
import vue from './vue.md'; | ||
|
||
import angular_example_component_html from './angular/example_component_html.md'; | ||
import angular_example_component_ts from './angular/example_component_ts.md'; | ||
|
||
<Playground | ||
size="medium" | ||
version={6} | ||
code={{ | ||
javascript, | ||
react, | ||
vue, | ||
angular: { | ||
files: { | ||
'src/app/example.component.html': angular_example_component_html, | ||
'src/app/example.component.ts': angular_example_component_ts, | ||
}, | ||
}, | ||
}} | ||
src="usage/v6/datetime/highlightedDates/callback/demo.html" | ||
/> |
Oops, something went wrong.