Skip to content

Commit

Permalink
Updated Samples
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoo-msft committed May 8, 2020
1 parent a654d4d commit 94d5e35
Show file tree
Hide file tree
Showing 19 changed files with 673 additions and 542 deletions.
37 changes: 37 additions & 0 deletions samples/Templates/Elements/Template.ConditionalLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "If the price in the data is higher than 500, red text will apper, otherwise green text",
"wrap": true
},
{
"type": "Container",
"$data": "${requests}",
"items": [
{
"type": "TextBlock",
"text": "Item Requested Type: ${type}"
},
{
"type": "TextBlock",
"text": "Price:$${string(price)}"
},
{
"type": "TextBlock",
"$when": "${price > 500}",
"text": "This thing is pricy!",
"color": "attention"
},
{
"type": "TextBlock",
"$when": "${price <= 100}",
"text": "Dang, this thing is cheap!",
"color": "good"
}
]
}
]
}
33 changes: 33 additions & 0 deletions samples/Templates/Elements/Template.DataBinding.Inline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "AdaptiveCard",
"version" : "1.2",
"$data": {
"employee": {
"name": "Matt",
"manager": { "name": "Thomas" },
"peers": [{
"name": "Andrew"
}, {
"name": "Lei"
}, {
"name": "Mary Anne"
}, {
"name": "Adam"
}]
}
},
"body": [
{
"type": "TextBlock",
"text": "Hi ${employee.name}! Here's a bit about your org..."
},
{
"type": "TextBlock",
"text": "Your manager is: ${employee.manager.name}"
},
{
"type": "TextBlock",
"text": "3 of your peers are: ${employee.peers[0].name}, ${employee.peers[1].name}, ${employee.peers[2].name}"
}
]
}
18 changes: 18 additions & 0 deletions samples/Templates/Elements/Template.DataBinding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "AdaptiveCard",
"version" : "1.2",
"body": [
{
"type": "TextBlock",
"text": "Hi ${employee.name}! Here's a bit about your org..."
},
{
"type": "TextBlock",
"text": "Your manager is: ${employee.manager.name}"
},
{
"type": "TextBlock",
"text": "3 of your peers are: ${employee.peers[0].name}, ${employee.peers[1].name}, ${employee.peers[2].name}"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "This card created a json instance from commit message in the data and used it to set data context",
"wrap":true,
"color": "good"
},
{
"type": "FactSet",
"$data": "${json(commitMessage)}",
"facts": [
{
"title": "Type",
"value": "${type}"
},
{
"title": "Build ID",
"value": "${buildID}"
},
{
"title": "Release ID",
"value": "${releaseID}"
},
{
"title": "Build Number",
"value": "${buildNumber}"
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
32 changes: 32 additions & 0 deletions samples/Templates/Elements/Template.Functions.DateFunctions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Convert ${date} to 'yyyy-MM-ddTHH:mm:ss' format",
"wrap": true
},
{
"type": "TextBlock",
"text": "**${formatDateTime(date, 'yyyy-MM-ddTHH:mm:ss')}**"
},
{
"type": "TextBlock",
"text": "Expressed in AdaptiveCards DATE Function Short"
},
{
"type": "TextBlock",
"text": "**{{DATE(${formatDateTime(date, 'yyyy-MM-ddTHH:mm:ssZ')}, SHORT)}}**"
},
{
"type": "TextBlock",
"text": "Expressed in AdaptiveCards TIME Function"
},
{
"type": "TextBlock",
"text": "**{{TIME(${formatDateTime(date, 'yyyy-MM-ddTHH:mm:ssZ')})}}**"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "Container",
"$data": "${requests}",
"items": [
{
"$when":"${exists(type)}",
"type": "TextBlock",
"text": "Presence of type text in the data context was checked using **exists** function that returns true if requested entry exists, and this TextBlock is shown with type: '${type}'",
"wrap": true
},
{
"$when":"${!exists(type)}",
"type": "TextBlock",
"text": "If **type** text doesn't appear, this TextBlock will appear",
"color": "attention",
"wrap": true
},
{
"type": "TextBlock",
"text": "${string(price)}",
"color": "${if(price <= 500, 'good', 'attention')}"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
19 changes: 19 additions & 0 deletions samples/Templates/Elements/Template.Functions.Number.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Lowest Price: ${min(select(requests, iter, iter.price))}"
},
{
"type": "TextBlock",
"text": "Highest Price: ${max(select(requests, iter, iter.price))}"
},
{
"type": "TextBlock",
"text": "Sum of Price: ${sum(select(requests, iter, iter.price))}"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
28 changes: 28 additions & 0 deletions samples/Templates/Elements/Template.Functions.String.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Name in lower case: ${toLower(employee.name)}"
},
{
"type": "TextBlock",
"text": "Name in upper case: ${toUpper(employee.name)}"
},
{
"type": "TextBlock",
"text": "Length of name: ${string(length(employee.name))}"
},
{
"type": "TextBlock",
"text": "Retrieved the last name, ${substring(employee.peers[2].name, 5, 4)} using substring() from ${employee.peers[2].name}",
"wrap": true
},
{
"type": "TextBlock",
"text": "Index of 'r' in '${employee.peers[0].name}': ${indexOf(employee.peers[0].name, 'r')}"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
34 changes: 34 additions & 0 deletions samples/Templates/Elements/Template.Keywords.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Data context is set with employee.manager, and the usage of name in template will refer to employee.manager's name",
"wrap": true
},
{
"type": "Container",
"$data": "${employee.manager}",
"items": [
{
"type": "TextBlock",
"text": "name: ${name}"
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Root keyword allows to access root data context "
},
{
"type": "TextBlock",
"text": "name: ${$root.employee.name}"
}
]
}
]
}
]
}
25 changes: 25 additions & 0 deletions samples/Templates/Elements/Template.RepeatingItems.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Setting a data context that is a json array type will cause entire json obj that encloses the array to repeat by the size of the array",
"wrap": true
},
{
"type": "TextBlock",
"text": "List of Peers"
},
{
"$data": "${employee.peers}",
"type": "TextBlock",
"text": "${string($index + 1)}. ${name}"
}
]
}
]
}
38 changes: 38 additions & 0 deletions samples/Templates/Elements/Template.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"employee": {
"name": "Matt",
"manager":
{
"name": "Thomas"
},
"peers": [
{
"name": "Andrew"
},
{
"name": "Lei"
},
{
"name": "Mary Anne"
},
{
"name": "Adam"
}
]
},
"date" : "03/15/2018 12:00:00",
"requests" : [
{
"type": "monitor",
"price": 100
},
{
"type": "laptop",
"price": 2000
},
{
"price": 2000
}
],
"commitMessage": "{\"type\":\"Deployment\",\"buildId\":\"9542982\",\"releaseId\":\"129\",\"buildNumber\":\"20180504.3\",\"releaseName\":\"Release-104\",\"repoProvider\":\"GitHub\"}"
}
15 changes: 4 additions & 11 deletions samples/Templates/Scenarios/CalendarReminder.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"speak": "<s>Your meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at 12:30pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
"speak": "<s>Your meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at ${formatDateTime(start.dateTime, 'HH:mm')}pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
"body": [
{
"type": "TextBlock",
Expand Down Expand Up @@ -33,16 +33,9 @@
"value": "${reminders.overrides[0].minutes}",
"choices": [
{
"title": "${reminders.overrides[0].minutes} minutes",
"value": "${reminders.overrides[0].minutes}"
},
{
"title": "${reminders.overrides[1].minutes} minutes",
"value": "${reminders.overrides[1].minutes}"
},
{
"title": "${reminders.overrides[2].minutes} minutes",
"value": "${reminders.overrides[2].minutes}"
"$data": "${reminders.overrides}",
"title": "${minutes} minutes",
"value": "${minutes}"
}
]
}
Expand Down
Loading

0 comments on commit 94d5e35

Please sign in to comment.