LoginSignup
2
3

More than 3 years have passed since last update.

SharePoint OnlineのモダンUIでシステムリンクをつくる

Last updated at Posted at 2019-12-10

やりたいこと

  • SharePoint Online標準機能をつかって各システムへのアイコンリンクをつくる
  • SharePoint Frameworkは難しいので使わない
  • 外観の設定で色が変わりたい

ゴールのイメージ

キャプチャ.PNG

やりかた

  1. リストをつくる
  2. 列を設定する  キャプチャ.PNG
    • Title列はリンクのタイトルを設定。ex.メール、チャット
    • Icon列はUI Fabricの名前を設定。ex.Mail
    • NewTab列は別タブで開くかを設定。
  3. ビューの書式を設定する

現在のビューの書式設定へ以下のJSONをコピペする

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideColumnHeader": "true",
  "hideSelection": true,
  "tileProps": {
    "hideSelection": true,
    "width": "120",
    "height": "120",
    "formatter": {
      "elmType": "a",
      "attributes": {
        "href": "[$URL]",
        "target": "=if([$NewTab] == true, '_blank', '')"
      },
      "children": [
        {
          "elmType": "div",
          "attributes": {
            "class": "ms-bgColor-themeLighterAlt ms-bgColor-themePrimary--hover ms-fontColor-white--hover"
          },
          "style": {
            "display": "flex",
            "flex-wrap": "wrap",
            "min-width": "120px",
            "min-height": "120px",
            "margin-right": "10px",
            "margin-top": "10px",
            "box-shadow": "2px 2px 4px darkgrey"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "text-align": "center",
                "margin": "auto"
              },
              "children": [
                {
                  "elmType": "div",
                  "attributes": {
                    "iconName": "[$Icon]",
                    "class": "ms-fontSize-su"
                  }
                },
                {
                  "elmType": "div",
                  "attributes": {
                    "class": "sp-row-title ms-fontSize-s"
                  },
                  "txtContent": "[$Title]"
                }
              ]
            }
          ]
        }
      ]
    }
  },
  "rowFormatter": {
    "elmType": "a",
    "attributes": {
      "href": "[$URL]",
      "target": "=if([$NewTab] == true, '_blank', '')"
    },
    "style": {
      "width": "100%"
    },
    "children": [
      {
        "elmType": "div",
        "attributes": {
          "class": "ms-bgColor-themeLighterAlt ms-bgColor-themePrimary--hover ms-fontColor-white--hover"
        },
        "style": {
          "display": "flex",
          "flex-wrap": "wrap",
          "width": "100%",
          "min-height": "150px",
          "margin-right": "10px",
          "margin-top": "10px",
          "box-shadow": "2px 2px 4px darkgrey"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "text-align": "center",
              "margin": "auto"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "iconName": "[$Icon]",
                  "class": "ms-fontSize-su"
                }
              },
              {
                "elmType": "div",
                "attributes": {
                  "class": "sp-row-titleA "
                },
                "txtContent": "[$Title]"
              }
            ]
          }
        ]
      }
    ]
  }
}
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3