Code Monkey home page Code Monkey logo

Comments (6)

Yachtyyyy avatar Yachtyyyy commented on July 18, 2024 1

Thank you, the code solved my problem.

Thank you for your time and effort.👍

from list-formatting.

tecchan1107 avatar tecchan1107 commented on July 18, 2024

Hi @Yachtyyyy .

I have tried to reduce the margins as much as possible, how about the following code?

Sample Code
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "children": [
      {
        "elmType": "div",
        "style": {
          "height": "90px",
          "display": "=if(@rowIndex%2==0,'','none')"
        }
      },
      {
        "elmType": "div",
        "style": {
          "position": "absolute",
          "left": "=if(@rowIndex%5==0,'50px',if(@rowIndex%5==1,'150px',if(@rowIndex%5==2,'0px',if(@rowIndex%5==3,'100px',if(@rowIndex%5==4,'200px','')))))",
          "margin-bottom": "=if(if(@rowIndex%5==0,'0px',@rowIndex%5==1,'90px',if(@rowIndex%5==2,'-50px',if(@rowIndex%5==3,'40px',if(@rowIndex%5==4,'130px',''))))"
        },
        "children": [
          {
            "elmType": "a",
            "style": {
              "position": "relative",
              "display": "flex",
              "justify-content": "center",
              "align-items": "center",
              "width": "90px",
              "height": "90px"
            },
            "attributes": {
              "href": "[$URL]",
              "target": "_blank",
              "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover"
            },
            "children": [
              {
                "elmType": "svg",
                "style": {
                  "fill": "currentColor",
                  "cursor": "pointer"
                },
                "attributes": {
                  "viewBox": "-150 -150 300 300"
                },
                "children": [
                  {
                    "elmType": "path",
                    "attributes": {
                      "d": "M130 75 L0 150 L-130 75 L-130 -75 L-0 -150 L130 -75 z"
                    }
                  }
                ]
              },
              {
                "elmType": "div",
                "style": {
                  "position": "absolute",
                  "display": "flex",
                  "flex-direction": "column",
                  "align-items": "center",
                  "justify-content": "center",
                  "cursor": "pointer",
                  "width": "100%",
                  "height": "100%"
                },
                "attributes": {
                  "class": "ms-fontColor-white"
                },
                "children": [
                  {
                    "elmType": "div",
                    "style": {
                      "font-size": "32px",
                      "margin-bottom": "5px"
                    },
                    "attributes": {
                      "iconName": "[$Icon]"
                    }
                  },
                  {
                    "elmType": "div",
                    "style": {
                      "font-size": "14px",
                      "width": "75%",
                      "text-align": "center"
                    },
                    "txtContent": "[$Title]"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

image

from list-formatting.

aaclage avatar aaclage commented on July 18, 2024

Hi @Yachtyyyy

On the list webpart can you provide what size are you using? Maybe this is having impact on your height.
image

from list-formatting.

Yachtyyyy avatar Yachtyyyy commented on July 18, 2024

Hello @aaclage

Thanks for trying to help me but I have already selected "autosize". Another option was not possible because otherwise the honeycombs would be cut off and a scroll bar would be created.

from list-formatting.

Yachtyyyy avatar Yachtyyyy commented on July 18, 2024

@tecchan1107

Thanks, the new code solves my problem, but there is still a small bug:

image

With these 3 tiles you can't click anywhere to open a page.

I appreciate your help.

from list-formatting.

tecchan1107 avatar tecchan1107 commented on July 18, 2024

With these 3 tiles you can't click anywhere to open a page.

In my environment, I was able to open the link without any problem. (In the following video, Ctrl is held down while clicking on the link so that the link is not displayed.)

microsoftlists

Hmmm, wonder what would cause... Maybe it is not clickable because of some overlapping elements, how about the following code with the z-index added?

Sample Code
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "children": [
      {
        "elmType": "div",
        "style": {
          "height": "90px",
          "display": "=if(@rowIndex%2==0,'','none')"
        }
      },
      {
        "elmType": "div",
        "style": {
          "position": "absolute",
          "left": "=if(@rowIndex%5==0,'50px',if(@rowIndex%5==1,'150px',if(@rowIndex%5==2,'0px',if(@rowIndex%5==3,'100px',if(@rowIndex%5==4,'200px','')))))",
          "margin-bottom": "=if(if(@rowIndex%5==0,'0px',@rowIndex%5==1,'90px',if(@rowIndex%5==2,'-50px',if(@rowIndex%5==3,'40px',if(@rowIndex%5==4,'130px',''))))"
        },
        "children": [
          {
            "elmType": "a",
            "style": {
              "position": "relative",
              "display": "flex",
              "justify-content": "center",
              "align-items": "center",
              "width": "90px",
              "height": "90px",
              "z-index":"1"
            },
            "attributes": {
              "href": "[$URL]",
              "target": "_blank",
              "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover"
            },
            "children": [
              {
                "elmType": "svg",
                "style": {
                  "fill": "currentColor",
                  "cursor": "pointer"
                },
                "attributes": {
                  "viewBox": "-150 -150 300 300"
                },
                "children": [
                  {
                    "elmType": "path",
                    "attributes": {
                      "d": "M130 75 L0 150 L-130 75 L-130 -75 L-0 -150 L130 -75 z"
                    }
                  }
                ]
              },
              {
                "elmType": "div",
                "style": {
                  "position": "absolute",
                  "display": "flex",
                  "flex-direction": "column",
                  "align-items": "center",
                  "justify-content": "center",
                  "cursor": "pointer",
                  "width": "100%",
                  "height": "100%"
                },
                "attributes": {
                  "class": "ms-fontColor-white"
                },
                "children": [
                  {
                    "elmType": "div",
                    "style": {
                      "font-size": "32px",
                      "margin-bottom": "5px"
                    },
                    "attributes": {
                      "iconName": "[$Icon]"
                    }
                  },
                  {
                    "elmType": "div",
                    "style": {
                      "font-size": "14px",
                      "width": "75%",
                      "text-align": "center"
                    },
                    "txtContent": "[$Title]"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

In addition, please make sure that the URL column is set to a value.

image

from list-formatting.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.