Skip to content

Commit 2d048f1

Browse files
committed
Added number-background-color-shading
1 parent a613693 commit 2d048f1

File tree

5 files changed

+146
-0
lines changed

5 files changed

+146
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Background color shading by number column value
2+
3+
## Summary
4+
This sample demonstrates how to change the shade of the background color depending on the value of the number column. Also, in this sample, the background color is lightest at `-100` and darkest at `350`.
5+
6+
- `number-background-color-shading-theme-color.json` uses your site's theme color as the background color.
7+
- `number-background-color-shading-custom-color.json` uses the HTML color code as the background color, and in the sample, `#FFBBFF` is set.
8+
9+
![screenshot of the sample](./assets/screenshot.png)
10+
11+
## View requirements
12+
13+
This format can be applied to a Number column.
14+
15+
## Sample
16+
17+
Solution |Author(s)
18+
--------------------------------------------------|------------------------------------------------
19+
number-background-color-shading-theme-color.json |[Tetsuya Kawahara](https://twitter.com/techan_k)
20+
number-background-color-shading-custom-color.json |[Tetsuya Kawahara](https://twitter.com/techan_k)
21+
22+
## Version history
23+
24+
Version |Date |Comments
25+
--------|-----------------|----------------
26+
1.0 |November 16, 2021|Initial release
27+
28+
## Disclaimer
29+
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
30+
31+
<img src="https://telemetry.sharepointpnp.com/sp-dev-list-formatting/column-samples/number-background-color-shading" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[
2+
{
3+
"name": "pnp-list-formatting-number-background-color-shading",
4+
"reponame": "number-background-color-shading",
5+
"source": "pnp",
6+
"title": "Background color shading by number column value",
7+
"shortDescription": "This sample demonstrates how to change the shade of the background color according to the value of the number column.",
8+
"url": "https://github.com/pnp/List-Formatting/tree/master/column-samples/number-background-color-shading",
9+
"longDescription": [
10+
"This sample demonstrates how to change the shade of the background color according to the value of the number column."
11+
],
12+
"creationDateTime": "2021-11-16T00:00:00.000Z",
13+
"updateDateTime": "2021-11-16T00:00:00.000Z",
14+
"products": [
15+
"SharePoint",
16+
"Office"
17+
],
18+
"metadata": [
19+
{
20+
"key": "LIST-SAMPLE-TYPE",
21+
"value": "Column"
22+
},
23+
{
24+
"key": "SHAREPOINT-COMPATIBILITY",
25+
"value": "SharePoint Online"
26+
}
27+
],
28+
"thumbnails": [
29+
{
30+
"type": "image",
31+
"order": 100,
32+
"url": "https://github.com/pnp/List-Formatting/blob/master/column-samples/number-background-color-shading/assets/screenshot.png?raw=true",
33+
"alt": "screenshot"
34+
}
35+
],
36+
"authors": [
37+
{
38+
"gitHubAccount": "tecchan1107",
39+
"pictureUrl": "https://github.com/tecchan1107.png",
40+
"name": "Tetsuya Kawahara"
41+
}
42+
],
43+
"references": [
44+
{
45+
"name": "Use column formatting to customize SharePoint",
46+
"description": "You can use column formatting to customize how fields in SharePoint lists and libraries are displayed. To do this, you construct a JSON object that describes the elements that are displayed when a field is included in a list view, and the styles to be applied to those elements. The column formatting does not change the data in the list item or file; it only changes how it\u2019s displayed to users who browse the list.",
47+
"url": "https://docs.microsoft.com/sharepoint/dev/declarative-customization/column-formatting"
48+
}
49+
]
50+
}
51+
]
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
3+
"elmType": "div",
4+
"style": {
5+
"width": "100%",
6+
"height": "42px",
7+
"position": "relative",
8+
"white-space": "nowrap"
9+
},
10+
"children": [
11+
{
12+
"elmType": "div",
13+
"style": {
14+
"position": "abdolute",
15+
"width": "100%",
16+
"height": "100%",
17+
"opacity": "= ( (@currentField - (-100)) / (350 - (-100)) )",
18+
"background-color": "#FFBBFF"
19+
}
20+
},
21+
{
22+
"elmType": "div",
23+
"txtContent": "@currentField",
24+
"style": {
25+
"position": "absolute",
26+
"margin-left": "10px",
27+
"font-size": "18px"
28+
}
29+
}
30+
]
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
3+
"elmType": "div",
4+
"style": {
5+
"width": "100%",
6+
"height": "42px",
7+
"position": "relative",
8+
"white-space": "nowrap"
9+
},
10+
"children": [
11+
{
12+
"elmType": "div",
13+
"style": {
14+
"position": "abdolute",
15+
"width": "100%",
16+
"height": "100%",
17+
"opacity": "= ( (@currentField - (-100)) / (350 - (-100)) )"
18+
},
19+
"attributes": {
20+
"class": "ms-bgColor-themeTertiary"
21+
}
22+
},
23+
{
24+
"elmType": "div",
25+
"txtContent": "@currentField",
26+
"style": {
27+
"position": "absolute",
28+
"margin-left": "10px",
29+
"font-size": "18px"
30+
}
31+
}
32+
]
33+
}

0 commit comments

Comments
 (0)