【SharePoint】タイムラインを表示する(横バージョン)

f:id:tecchan365:20201110194457p:plain

次の記事で、 ビューの書式設定でリストの一覧画面をカスタマイズし、タイムライン(縦バージョン)を表示する方法を記載しました。

mynote365.hatenadiary.com

今回は、次の Twitter の動画のような横バージョンのタイムラインを表示する方法を記載します。

リスト作成

次のリストを作成します。

f:id:tecchan365:20201110200601p:plain

ビューの書式設定

作成したリストのビューの書式設定に、次の JSON を入力します。

f:id:tecchan365:20201110195430p:plain

{
  "hideColumnHeader": true,
  "hideSelection": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "position": "absolute",
      "left": "= @rowIndex * 300 + 'px'",
      "display": "flex",
      "flex-direction": "column",
      "width": "300px",
      "height": "200px",
      "float": "left"
    },
    "children": [
      {
        "elmType": "div",
        "txtContent": "[$Title]",
        "style": {
          "display": "flex",
          "width": "90%",
          "height": "60%",
          "align-items": "center",
          "justify-content": "center",
          "font-size": "20px"
        }
      },
      {
        "elmType": "div",
        "style": {
          "display": "flex",
          "flex-direction": "row",
          "width": "105%",
          "height": "40%",
          "align-items": "center"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "border-width": "2px",
              "border-style": "solid",
              "height": "2px",
              "width": "45%"
            },
            "attributes": {
              "class": "ms-bgColor-neutralSecondary ms-borderColor-neutralSecondary"
            }
          },
          {
            "elmType": "div",
            "style": {
              "height": "30px",
              "width": "30px",
              "border-radius": "50%",
              "cursor": "pointer",
              "outline": "none"
            },
            "attributes": {
              "class": "ms-bgColor-themePrimary"
            },
            "customCardProps": {
              "directionalHint": "bottomCenter",
              "isBeakVisible": true,
              "openOnEvent": "click",
              "formatter": {
                "elmType": "div",
                "style": {
                  "display": "flex",
                  "flex-direction": "column",
                  "height": "200px",
                  "width": "450px"
                },
                "children": [
                  {
                    "elmType": "div",
                    "txtContent": "[$Title]",
                    "style": {
                      "height": "20%",
                      "width": "100%",
                      "color": "white",
                      "font-size": "20px",
                      "display": "flex",
                      "align-items": "center",
                      "padding-left": "40px"
                    },
                    "attributes": {
                      "class": "ms-bgColor-themePrimary"
                    }
                  },
                  {
                    "elmType": "div",
                    "txtContent": "[$Description]",
                    "style": {
                      "height": "80%",
                      "width": "90%",
                      "padding-top": "10px"
                    }
                  }
                ]
              }
            }
          },
          {
            "elmType": "div",
            "style": {
              "border-width": "2px",
              "border-style": "solid",
              "height": "2px",
              "width": "45%"
            },
            "attributes": {
              "class": "ms-bgColor-neutralSecondary ms-borderColor-neutralSecondary"
            }
          }
        ]
      }
    ]
  }
}

[保存] ボタンをクリックすると設定完了です。

f:id:tecchan365:20201110200330p:plain

別バージョンのビューの書式設定

上記のビューの書式設定では、画面の幅に関わらず、横に永遠とタイムラインが表示されます。

f:id:tecchan365:20201110201010p:plain

もし、次の画像のように画面の幅にあわせてタイムラインが折り返されて欲しい場合は、次の JSON をビューの書式設定に入力してください。

f:id:tecchan365:20201110202132p:plain

{
  "hideColumnHeader": true,
  "hideSelection": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "display": "flex",
      "flex-direction": "column",
      "width": "300px",
      "height": "200px",
      "float": "left"
    },
    "children": [
      {
        "elmType": "div",
        "txtContent": "[$Title]",
        "style": {
          "display": "flex",
          "width": "90%",
          "height": "60%",
          "align-items": "center",
          "justify-content": "center",
          "font-size": "20px"
        }
      },
      {
        "elmType": "div",
        "style": {
          "display": "flex",
          "flex-direction": "row",
          "width": "105%",
          "height": "40%",
          "align-items": "center"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "border-width": "2px",
              "border-style": "solid",
              "height": "2px",
              "width": "45%"
            },
            "attributes": {
              "class": "ms-bgColor-neutralSecondary ms-borderColor-neutralSecondary"
            }
          },
          {
            "elmType": "div",
            "style": {
              "height": "30px",
              "width": "30px",
              "border-radius": "50%",
              "cursor": "pointer",
              "outline": "none"
            },
            "attributes": {
              "class": "ms-bgColor-themePrimary"
            },
            "customCardProps": {
              "directionalHint": "bottomCenter",
              "isBeakVisible": true,
              "openOnEvent": "click",
              "formatter": {
                "elmType": "div",
                "style": {
                  "display": "flex",
                  "flex-direction": "column",
                  "height": "200px",
                  "width": "450px"
                },
                "children": [
                  {
                    "elmType": "div",
                    "txtContent": "[$Title]",
                    "style": {
                      "height": "20%",
                      "width": "100%",
                      "color": "white",
                      "font-size": "20px",
                      "display": "flex",
                      "align-items": "center",
                      "padding-left": "40px"
                    },
                    "attributes": {
                      "class": "ms-bgColor-themePrimary"
                    }
                  },
                  {
                    "elmType": "div",
                    "txtContent": "[$Description]",
                    "style": {
                      "height": "80%",
                      "width": "90%",
                      "padding-top": "10px"
                    }
                  }
                ]
              }
            }
          },
          {
            "elmType": "div",
            "style": {
              "border-width": "2px",
              "border-style": "solid",
              "height": "2px",
              "width": "45%"
            },
            "attributes": {
              "class": "ms-bgColor-neutralSecondary ms-borderColor-neutralSecondary"
            }
          }
        ]
      }
    ]
  }
}