From 3950bdae8d85f72f3da7f5d50422022c1f7f1400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E7=82=B9=E5=8C=85=E5=AD=90?= Date: Sat, 28 Mar 2020 15:50:01 +0800 Subject: [PATCH] feat: update tree icon (#1963) --- antdv-demo | 2 +- components/tree/DirectoryTree.jsx | 8 +- components/tree/Tree.jsx | 22 ++--- .../__tests__/__snapshots__/demo.test.js.snap | 90 +++++++++---------- 4 files changed, 63 insertions(+), 59 deletions(-) diff --git a/antdv-demo b/antdv-demo index e96acb86b..d5d00665e 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit e96acb86be7a62e1a41c2d7b3ca56e40114f1420 +Subproject commit d5d00665ebc2a2393339f6dbfbdab7b30fe385a5 diff --git a/components/tree/DirectoryTree.jsx b/components/tree/DirectoryTree.jsx index 727d13ba1..a6046021c 100644 --- a/components/tree/DirectoryTree.jsx +++ b/components/tree/DirectoryTree.jsx @@ -1,5 +1,8 @@ import omit from 'omit.js'; import debounce from 'lodash/debounce'; +import FolderOpenOutlined from '@ant-design/icons-vue/FolderOpenOutlined'; +import FolderOutLined from '@ant-design/icons-vue/FolderOutLined'; +import FileOutlined from '@ant-design/icons-vue/FileOutlined'; import PropTypes from '../_util/vue-types'; import warning from '../_util/warning'; import { conductExpandParent, convertTreeToEntities } from '../vc-tree/src/util'; @@ -10,7 +13,6 @@ import { convertDirectoryKeysToNodes, getFullKeyListByTreeData, } from './util'; -import Icon from '../icon'; import BaseMixin from '../_util/BaseMixin'; import { initDefaultProps, @@ -28,9 +30,9 @@ import { ConfigConsumerProps } from '../config-provider'; function getIcon(props, h) { const { isLeaf, expanded } = props; if (isLeaf) { - return ; + return ; } - return ; + return expanded ? : ; } export default { diff --git a/components/tree/Tree.jsx b/components/tree/Tree.jsx index 05623c5b9..696f93c32 100644 --- a/components/tree/Tree.jsx +++ b/components/tree/Tree.jsx @@ -1,4 +1,9 @@ import warning from 'warning'; +import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined'; +import FileOutlined from '@ant-design/icons-vue/FileOutlined'; +import CaretDownFilled from '@ant-design/icons-vue/CaretDownFilled'; +import MinusSquareOutlined from '@ant-design/icons-vue/MinusSquareOutlined'; +import PlusSquareOutlined from '@ant-design/icons-vue/PlusSquareOutlined'; import { Tree as VcTree, TreeNode } from '../vc-tree'; import animation from '../_util/openAnimation'; import PropTypes from '../_util/vue-types'; @@ -11,7 +16,6 @@ import { } from '../_util/props-util'; import { cloneElement } from '../_util/vnode'; import { ConfigConsumerProps } from '../config-provider'; -import Icon from '../icon'; function TreeProps() { return { @@ -124,14 +128,14 @@ export default { }, TreeNode, methods: { - renderSwitcherIcon(prefixCls, switcherIcon, { isLeaf, expanded, loading }) { + renderSwitcherIcon(prefixCls, switcherIcon, { isLeaf, loading, expanded }) { const { showLine } = this.$props; if (loading) { - return ; + return ; } if (isLeaf) { - return showLine ? : null; + return showLine ? : null; } const switcherCls = `${prefixCls}-switcher-icon`; if (switcherIcon) { @@ -142,13 +146,11 @@ export default { }); } return showLine ? ( - + expanded ? + : + ) : ( - + ); }, updateTreeData(treeData) { diff --git a/components/tree/__tests__/__snapshots__/demo.test.js.snap b/components/tree/__tests__/__snapshots__/demo.test.js.snap index 00c4e8bdf..15a0042e4 100644 --- a/components/tree/__tests__/__snapshots__/demo.test.js.snap +++ b/components/tree/__tests__/__snapshots__/demo.test.js.snap @@ -2,15 +2,15 @@ exports[`renders ./antdv-demo/docs/tree/demo/basic.md correctly 1`] = `
    -
  • parent 1 +
  • parent 1
      -
    • parent 1-0 +
    • parent 1-0
      • leaf
      • leaf
    • -
    • parent 1-1 +
    • parent 1-1
      • sss
      @@ -22,16 +22,16 @@ exports[`renders ./antdv-demo/docs/tree/demo/basic.md correctly 1`] = ` exports[`renders ./antdv-demo/docs/tree/demo/basic-controlled.md correctly 1`] = `
        -
      • 0-0 +
      • 0-0
          -
        • 0-0-0 +
        • 0-0-0
          • 0-0-0-0
          • 0-0-0-1
          • 0-0-0-2
        • -
        • 0-0-1 +
        • 0-0-1
          • 0-0-1-0
          • 0-0-1-1
          • @@ -41,7 +41,7 @@ exports[`renders ./antdv-demo/docs/tree/demo/basic-controlled.md correctly 1`] =
          • 0-0-2
        • -
        • 0-1 +
        • 0-1
        • 0-2
        • @@ -50,10 +50,10 @@ exports[`renders ./antdv-demo/docs/tree/demo/basic-controlled.md correctly 1`] = exports[`renders ./antdv-demo/docs/tree/demo/customized-icon.md correctly 1`] = `
            -
          • parent 1 +
          • parent 1
              -
            • leaf
            • -
            • leaf
            • +
            • leaf
            • +
            • leaf
          @@ -61,16 +61,16 @@ exports[`renders ./antdv-demo/docs/tree/demo/customized-icon.md correctly 1`] = exports[`renders ./antdv-demo/docs/tree/demo/directory.md correctly 1`] = `
            -
          • parent 0 +
          • parent 0
              -
            • leaf 0-0
            • -
            • leaf 0-1
            • +
            • leaf 0-0
            • +
            • leaf 0-1
          • -
          • parent 1 +
          • parent 1
              -
            • leaf 1-0
            • -
            • leaf 1-1
            • +
            • leaf 1-0
            • +
            • leaf 1-1
          @@ -78,22 +78,22 @@ exports[`renders ./antdv-demo/docs/tree/demo/directory.md correctly 1`] = ` exports[`renders ./antdv-demo/docs/tree/demo/draggable.md correctly 1`] = `
            -
          • 0-0 +
          • 0-0
              -
            • 0-0-0 +
            • 0-0-0
              • 0-0-0-0
              • 0-0-0-1
              • 0-0-0-2
            • -
            • 0-0-1 +
            • 0-0-1
            • 0-0-2
          • -
          • 0-1 +
          • 0-1
          • 0-2
          • @@ -102,8 +102,8 @@ exports[`renders ./antdv-demo/docs/tree/demo/draggable.md correctly 1`] = ` exports[`renders ./antdv-demo/docs/tree/demo/dynamic.md correctly 1`] = `
              -
            • Expand to load
            • -
            • Expand to load
            • +
            • Expand to load
            • +
            • Expand to load
            • Tree Node
            `; @@ -114,24 +114,24 @@ exports[`renders ./antdv-demo/docs/tree/demo/line.md correctly 1`] = ` showLine:

            showIcon:
              -
            • parent 1 +
            • parent 1
                -
              • parent 1-0 +
              • parent 1-0
                  -
                • leaf
                • -
                • leaf
                • -
                • leaf
                • +
                • leaf
                • +
                • leaf
                • +
                • leaf
              • -
              • parent 1-1 +
              • parent 1-1
                  -
                • leaf
                • +
                • leaf
              • -
              • parent 1-2 +
              • parent 1-2
                  -
                • leaf
                • -
                • leaf
                • +
                • leaf
                • +
                • leaf
              @@ -142,15 +142,15 @@ exports[`renders ./antdv-demo/docs/tree/demo/line.md correctly 1`] = ` exports[`renders ./antdv-demo/docs/tree/demo/replaceFields.md correctly 1`] = `
                -
              • parent 1 +
              • parent 1
                  -
                • 张晨成 +
                • 张晨成
                  • leaf
                  • leaf
                • -
                • parent 1-1 +
                • parent 1-1
                  • zcvc
                  @@ -161,16 +161,16 @@ exports[`renders ./antdv-demo/docs/tree/demo/replaceFields.md correctly 1`] = ` `; exports[`renders ./antdv-demo/docs/tree/demo/search.md correctly 1`] = ` -
                  +
                    -
                  • +
                  • 0-0
                  • -
                  • +
                  • 0-1 @@ -188,19 +188,19 @@ exports[`renders ./antdv-demo/docs/tree/demo/search.md correctly 1`] = ` exports[`renders ./antdv-demo/docs/tree/demo/switcher-icon.md correctly 1`] = `
                      -
                    • parent 1 +
                    • parent 1
                        -
                      • parent 1-0 +
                      • parent 1-0
                          -
                        • leaf
                        • -
                        • leaf
                        • -
                        • leaf
                        • +
                        • leaf
                        • +
                        • leaf
                        • +
                        • leaf
                      • -
                      • parent 1-1 +
                      • parent 1-1
                      • -
                      • parent 1-2 +
                      • parent 1-2