Skip to content

Commit 69ba85e

Browse files
niketjain2020Niket Jain
andauthored
Hover and Default cards example on formatting docs (SharePoint#5500)
* <hover card changes> * <hover card changes> * <hover card changes> * <hover card changes> * hovercardupdate * hovercardupdate * hovercardupdate * hovercardupdate * hovercardupdate * hovercardupdate * hovercardupdate Co-authored-by: Niket Jain <[email protected]>
1 parent 28ae5dc commit 69ba85e

File tree

5 files changed

+117
-2
lines changed

5 files changed

+117
-2
lines changed

docs/declarative-customization/column-formatting.md

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,97 @@ This examples uses operator `loopIndex` to control the margins all rows but the
720720
}
721721
```
722722

723+
### Custom cards on hover
724+
725+
The following image shows a list with a custom hover added to a List:
726+
727+
On hover - Metadata on the column "Status" is made available in view formatting
728+
729+
![](../images/HoverImage-1.png)
730+
731+
On hover - Metadata on the column "Status" is made available in column formatting
732+
733+
![](../images/HoverImage-2.png)
734+
735+
736+
737+
You can use column and view formatting to define custom call out that can be commissioned basis user defined actions like click or hover
738+
739+
This example uses customCardProps, openOnEvent, directionalHint and isBeakVisible
740+
741+
```JSON
742+
743+
{
744+
"elmType": "div",
745+
"style": {
746+
"font-size": "12px"
747+
},
748+
"txtContent": "[$Status]",
749+
"customCardProps": {
750+
"formatter": {
751+
"elmType": "div",
752+
"txtContent": "Define your formatter options inside the customCarProps/formatter property"
753+
},
754+
"openOnEvent": "hover",
755+
"directionalHint": "bottomCenter",
756+
"isBeakVisible": true
757+
}
758+
}
759+
```
760+
## Default cards on hover via formatting
761+
762+
Users can now have profile card or file hover card on formatters too, some of the things users can now do -
763+
1) Profile card or File Hover card on any column
764+
2) Profile card or Hover card with view formatting
765+
766+
Hover on a filename with formatting with default file card
767+
768+
![](../images/HoverImage-3.png)
769+
770+
771+
Hover on a person column with formatting with default Profile card
772+
773+
![](../images/HoverImage-4.png)
774+
775+
Both the example uses defaultHoverField
776+
777+
```JSON
778+
779+
{
780+
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
781+
"elmType": "div",
782+
"children": [
783+
{
784+
"elmType": "img",
785+
"style": {
786+
"width": "32px",
787+
"height": "32px",
788+
"overflow": "hidden",
789+
"border-radius": "50%",
790+
"margin": "2px"
791+
},
792+
"attributes": {
793+
"src": "='/_layouts/15/userphoto.aspx?size=S&accountname=' + [$Editor.email]",
794+
"title": "[$Editor.title]"
795+
}
796+
},
797+
{
798+
"elmType": "span",
799+
"style": {
800+
"vertical-align": "middle",
801+
"margin-left": "2px"
802+
},
803+
"txtContent": "[$Editor.title]"
804+
}
805+
],
806+
"defaultHoverField": "[$Editor]"
807+
}
808+
809+
```
810+
811+
812+
813+
723814
## Supported column types
724815

725816
The following column types support column formatting:
@@ -1378,7 +1469,15 @@ The people field object has the following properties (with example values):
13781469
"jobTitle":"HR Manager"
13791470
}
13801471
```
1472+
People field can have profile hover cards along with formatting
13811473

1474+
```json
1475+
{
1476+
"elmType": "div",
1477+
"txtContent": "[$Editor.title]",
1478+
"defaultHoverField": "[$Editor]"
1479+
}
1480+
```
13821481
**Date/Time fields**
13831482

13841483
The value of Date/Time fields can be retrieved a few different ways, depending on the date format you'd like to display. The following methods for converting date values to specific formats are supported:
@@ -1426,7 +1525,7 @@ The ___location field object has the following properties (with example values):
14261525
"Longitude": "-83.92420959472656"
14271526
},
14281527
"DisplayName": "World's Fair Park",
1429-
"LocationUri: "https://www.bingapis.com/api/v6/localentities/8346bf26-6da4-104c-6ba5-2334b83f6ac8?setLang=en"
1528+
"LocationUri": "https://www.bingapis.com/api/v6/localentities/8346bf26-6da4-104c-6ba5-2334b83f6ac8?setLang=en"
14301529
}
14311530
```
14321531

@@ -1629,7 +1728,7 @@ These tokens will yield no value on non-file items including folders.
16291728
> [!TIP]
16301729
> Thumbnails are only available for a list of supported file formats. It means that sometimes the URL generated is not accessible due to lack of support on certain formats. However, if a valid thumbnail token is set as the _only_ `src` attribute of an `img` tag, we will take care of it and hide the image when it is not available.
16311730
1632-
```json
1731+
```JSON
16331732
{
16341733
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
16351734
"elmType": "img",
@@ -1643,7 +1742,23 @@ These tokens will yield no value on non-file items including folders.
16431742
}
16441743
}
16451744
```
1745+
Default file hover card using FileLeafRef
16461746

1747+
```JSON
1748+
{
1749+
"elmType": "img",
1750+
"style": {
1751+
"width": "100%",
1752+
"height": "100%",
1753+
"display": "=if([$File_x0020_Type] == '', 'none', '')"
1754+
},
1755+
"attributes": {
1756+
"src": "@thumbnail.300x300"
1757+
},
1758+
"defaultHoverField": "[$FileLeafRef]"
1759+
}
1760+
```
1761+
16471762
## See also
16481763

16491764
- [Column formatting](https://support.office.com/article/Column-formatting-1f927342-2bed-4745-b727-ff8b7ff96b22?ui=en-US&rs=en-US&ad=US)

docs/images/HoverImage-1.png

757 KB
Loading

docs/images/HoverImage-2.png

83 KB
Loading

docs/images/HoverImage-3.png

459 KB
Loading

docs/images/HoverImage-4.png

149 KB
Loading

0 commit comments

Comments
 (0)