Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding icons #23

Open
JithinKS97 opened this issue May 20, 2019 · 4 comments
Open

Adding icons #23

JithinKS97 opened this issue May 20, 2019 · 4 comments

Comments

@JithinKS97
Copy link

How to add different icons for folders and files?

@Hazantip
Copy link

+1

1 similar comment
@ravick4u
Copy link

+1

@Arthur944
Copy link

Arthur944 commented Aug 26, 2020

If you check in the demos folder you'll see an implementation with icons.

generateNodeProps={rowInfo => ({
              icons: rowInfo.node.isDirectory
                ? [
                    <div
                      style={{
                        borderLeft: 'solid 8px gray',
                        borderBottom: 'solid 10px gray',
                        marginRight: 10,
                        boxSizing: 'border-box',
                        width: 16,
                        height: 12,
                        filter: rowInfo.node.expanded
                          ? 'drop-shadow(1px 0 0 gray) drop-shadow(0 1px 0 gray) drop-shadow(0 -1px 0 gray) drop-shadow(-1px 0 0 gray)'
                          : 'none',
                        borderColor: rowInfo.node.expanded ? 'white' : 'gray',
                      }}
                    />,
                  ]
                : [
                    <div
                      style={{
                        border: 'solid 1px black',
                        fontSize: 8,
                        textAlign: 'center',
                        marginRight: 10,
                        width: 12,
                        height: 16,
                      }}
                    >
                      F
                    </div>,
                  ],
              buttons: [
                <button
                  style={{
                    padding: 0,
                    borderRadius: '100%',
                    backgroundColor: 'gray',
                    color: 'white',
                    width: 16,
                    height: 16,
                    border: 0,
                    fontWeight: 100,
                  }}
                  onClick={() => alertNodeInfo(rowInfo)}
                >
                  i
                </button>,
              ],
            })}

I would recommend not having an "isDirectory" attribute, but instead checking whether the node's children's length is over 0. Also, an icon libarary like styled-icons would maybe be a better choice instead of cleverly styled divs.

@kayesn786
Copy link

Hi @Arthur944 , can we show lines between directories? and add some smooth scrolling animations?
tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants