-
Notifications
You must be signed in to change notification settings - Fork 3.1k
docs(datetime): add highlightedDates playgrounds #2769
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
97a2df0
docs(datetime): add highlightedDates playgrounds
f75661e
remove note about stripping time info after adding that directly to f…
14328c0
rename color to textColor
a4385b9
add note about selected date styles taking priority
9eb84c0
add details on why array vs callback
091419e
remove explicit public from Angular examples
0500767
use different formats for colors in examples
97e2726
mention that you can use any color format
7890b6b
var instead of const for JS examples
9de99ae
specify playground versions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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', | ||
averyjohnston marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
{ | ||
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 hidden or 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 hidden or 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,24 @@ | ||
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" | ||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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> |
24 changes: 24 additions & 0 deletions
24
static/usage/v6/datetime/highlightedDates/callback/index.md
This file contains hidden or 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,24 @@ | ||
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" | ||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.