@instructure/ui-tree-browser 11.6.0 → 11.6.1-snapshot-129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -288
- package/es/TreeBrowser/{TreeButton → v1/TreeButton}/index.js +2 -2
- package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.js +1 -1
- package/es/TreeBrowser/{TreeNode → v1/TreeNode}/index.js +2 -2
- package/es/TreeBrowser/{index.js → v1/index.js} +1 -1
- package/es/TreeBrowser/v2/TreeBrowserContext.js +39 -0
- package/es/TreeBrowser/v2/TreeButton/index.js +202 -0
- package/es/TreeBrowser/v2/TreeButton/props.js +26 -0
- package/es/TreeBrowser/v2/TreeButton/styles.js +306 -0
- package/es/TreeBrowser/v2/TreeCollection/index.js +367 -0
- package/es/TreeBrowser/v2/TreeCollection/props.js +26 -0
- package/es/TreeBrowser/v2/TreeCollection/styles.js +143 -0
- package/es/TreeBrowser/v2/TreeNode/index.js +156 -0
- package/es/{index.js → TreeBrowser/v2/TreeNode/props.js} +3 -4
- package/es/TreeBrowser/v2/index.js +347 -0
- package/es/TreeBrowser/v2/props.js +35 -0
- package/es/TreeBrowser/v2/styles.js +71 -0
- package/es/exports/a.js +27 -0
- package/es/exports/b.js +27 -0
- package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/index.js +3 -3
- package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.js +1 -1
- package/lib/TreeBrowser/{TreeNode → v1/TreeNode}/index.js +3 -3
- package/lib/TreeBrowser/{index.js → v1/index.js} +3 -3
- package/lib/TreeBrowser/v2/TreeBrowserContext.js +44 -0
- package/lib/TreeBrowser/v2/TreeButton/index.js +208 -0
- package/lib/TreeBrowser/v2/TreeButton/props.js +31 -0
- package/lib/TreeBrowser/v2/TreeButton/styles.js +312 -0
- package/lib/TreeBrowser/v2/TreeCollection/index.js +372 -0
- package/lib/TreeBrowser/v2/TreeCollection/props.js +31 -0
- package/lib/TreeBrowser/v2/TreeCollection/styles.js +149 -0
- package/lib/TreeBrowser/v2/TreeNode/index.js +162 -0
- package/lib/TreeBrowser/v2/TreeNode/props.js +31 -0
- package/lib/TreeBrowser/v2/index.js +353 -0
- package/lib/TreeBrowser/v2/props.js +40 -0
- package/lib/TreeBrowser/v2/styles.js +77 -0
- package/lib/{index.js → exports/a.js} +5 -5
- package/lib/exports/b.js +33 -0
- package/package.json +40 -18
- package/src/TreeBrowser/{TreeButton → v1/TreeButton}/index.tsx +2 -2
- package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.tsx +1 -1
- package/src/TreeBrowser/{TreeNode → v1/TreeNode}/index.tsx +2 -2
- package/src/TreeBrowser/{index.tsx → v1/index.tsx} +1 -1
- package/src/TreeBrowser/v2/README.md +712 -0
- package/src/TreeBrowser/v2/TreeBrowserContext.ts +53 -0
- package/src/TreeBrowser/v2/TreeButton/index.tsx +210 -0
- package/src/TreeBrowser/v2/TreeButton/props.ts +95 -0
- package/src/TreeBrowser/v2/TreeButton/styles.ts +331 -0
- package/src/TreeBrowser/v2/TreeCollection/index.tsx +416 -0
- package/src/TreeBrowser/v2/TreeCollection/props.ts +88 -0
- package/src/TreeBrowser/v2/TreeCollection/styles.ts +157 -0
- package/src/TreeBrowser/v2/TreeNode/index.tsx +158 -0
- package/src/TreeBrowser/v2/TreeNode/props.ts +84 -0
- package/src/TreeBrowser/v2/index.tsx +438 -0
- package/src/TreeBrowser/v2/props.ts +245 -0
- package/src/TreeBrowser/v2/styles.ts +79 -0
- package/src/exports/a.ts +32 -0
- package/src/exports/b.ts +32 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TreeBrowser/v1/TreeBrowserContext.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/theme.d.ts.map +1 -0
- package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.d.ts +1 -1
- package/types/TreeBrowser/v1/TreeCollection/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeCollection/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeCollection/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeCollection/theme.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeNode/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeNode/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v1/theme.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeBrowserContext.d.ts +24 -0
- package/types/TreeBrowser/v2/TreeBrowserContext.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeButton/index.d.ts +44 -0
- package/types/TreeBrowser/v2/TreeButton/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeButton/props.d.ts +37 -0
- package/types/TreeBrowser/v2/TreeButton/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeButton/styles.d.ts +19 -0
- package/types/TreeBrowser/v2/TreeButton/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeCollection/index.d.ts +66 -0
- package/types/TreeBrowser/v2/TreeCollection/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeCollection/props.d.ts +24 -0
- package/types/TreeBrowser/v2/TreeCollection/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeCollection/styles.d.ts +18 -0
- package/types/TreeBrowser/v2/TreeCollection/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeNode/index.d.ts +41 -0
- package/types/TreeBrowser/v2/TreeNode/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeNode/props.d.ts +25 -0
- package/types/TreeBrowser/v2/TreeNode/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/index.d.ts +70 -0
- package/types/TreeBrowser/v2/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/props.d.ts +163 -0
- package/types/TreeBrowser/v2/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/styles.d.ts +16 -0
- package/types/TreeBrowser/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +9 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +9 -0
- package/types/exports/b.d.ts.map +1 -0
- package/src/index.ts +0 -32
- package/types/TreeBrowser/TreeBrowserContext.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/index.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/props.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/styles.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/theme.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/index.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/props.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/styles.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/theme.d.ts.map +0 -1
- package/types/TreeBrowser/TreeNode/index.d.ts.map +0 -1
- package/types/TreeBrowser/TreeNode/props.d.ts.map +0 -1
- package/types/TreeBrowser/index.d.ts.map +0 -1
- package/types/TreeBrowser/props.d.ts.map +0 -1
- package/types/TreeBrowser/styles.d.ts.map +0 -1
- package/types/TreeBrowser/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -9
- package/types/index.d.ts.map +0 -1
- /package/es/TreeBrowser/{TreeBrowserContext.js → v1/TreeBrowserContext.js} +0 -0
- /package/es/TreeBrowser/{TreeButton → v1/TreeButton}/props.js +0 -0
- /package/es/TreeBrowser/{TreeButton → v1/TreeButton}/styles.js +0 -0
- /package/es/TreeBrowser/{TreeButton → v1/TreeButton}/theme.js +0 -0
- /package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.js +0 -0
- /package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.js +0 -0
- /package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.js +0 -0
- /package/es/TreeBrowser/{TreeNode → v1/TreeNode}/props.js +0 -0
- /package/es/TreeBrowser/{props.js → v1/props.js} +0 -0
- /package/es/TreeBrowser/{styles.js → v1/styles.js} +0 -0
- /package/es/TreeBrowser/{theme.js → v1/theme.js} +0 -0
- /package/lib/TreeBrowser/{TreeBrowserContext.js → v1/TreeBrowserContext.js} +0 -0
- /package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/props.js +0 -0
- /package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/styles.js +0 -0
- /package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/theme.js +0 -0
- /package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.js +0 -0
- /package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.js +0 -0
- /package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.js +0 -0
- /package/lib/TreeBrowser/{TreeNode → v1/TreeNode}/props.js +0 -0
- /package/lib/TreeBrowser/{props.js → v1/props.js} +0 -0
- /package/lib/TreeBrowser/{styles.js → v1/styles.js} +0 -0
- /package/lib/TreeBrowser/{theme.js → v1/theme.js} +0 -0
- /package/src/TreeBrowser/{README.md → v1/README.md} +0 -0
- /package/src/TreeBrowser/{TreeBrowserContext.ts → v1/TreeBrowserContext.ts} +0 -0
- /package/src/TreeBrowser/{TreeButton → v1/TreeButton}/props.ts +0 -0
- /package/src/TreeBrowser/{TreeButton → v1/TreeButton}/styles.ts +0 -0
- /package/src/TreeBrowser/{TreeButton → v1/TreeButton}/theme.ts +0 -0
- /package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.ts +0 -0
- /package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.ts +0 -0
- /package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.ts +0 -0
- /package/src/TreeBrowser/{TreeNode → v1/TreeNode}/props.ts +0 -0
- /package/src/TreeBrowser/{props.ts → v1/props.ts} +0 -0
- /package/src/TreeBrowser/{styles.ts → v1/styles.ts} +0 -0
- /package/src/TreeBrowser/{theme.ts → v1/theme.ts} +0 -0
- /package/types/TreeBrowser/{TreeBrowserContext.d.ts → v1/TreeBrowserContext.d.ts} +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/index.d.ts +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/props.d.ts +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/styles.d.ts +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/theme.d.ts +0 -0
- /package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.d.ts +0 -0
- /package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.d.ts +0 -0
- /package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.d.ts +0 -0
- /package/types/TreeBrowser/{TreeNode → v1/TreeNode}/index.d.ts +0 -0
- /package/types/TreeBrowser/{TreeNode → v1/TreeNode}/props.d.ts +0 -0
- /package/types/TreeBrowser/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/TreeBrowser/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/TreeBrowser/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/TreeBrowser/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { createContext } from 'react'
|
|
26
|
+
|
|
27
|
+
type TreeBrowserContextType = {
|
|
28
|
+
/**
|
|
29
|
+
* Whether to enable animation for the TreeBrowser
|
|
30
|
+
*/
|
|
31
|
+
animation?: boolean
|
|
32
|
+
/**
|
|
33
|
+
* Function to clear the current selection
|
|
34
|
+
*/
|
|
35
|
+
clearSelection?: () => void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* ---
|
|
40
|
+
* category: components/contexts
|
|
41
|
+
* ---
|
|
42
|
+
* React context created by the `TreeBrowser` component to hold its data which are
|
|
43
|
+
* read by its children.
|
|
44
|
+
*
|
|
45
|
+
* @module
|
|
46
|
+
*/
|
|
47
|
+
const TreeBrowserContext = createContext<TreeBrowserContextType>({
|
|
48
|
+
animation: true
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
export default TreeBrowserContext
|
|
52
|
+
export { TreeBrowserContext }
|
|
53
|
+
export type { TreeBrowserContextType }
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { Component, ContextType } from 'react'
|
|
26
|
+
|
|
27
|
+
import { Img } from '@instructure/ui-img/latest'
|
|
28
|
+
import { withStyle } from '@instructure/emotion'
|
|
29
|
+
import { renderIconWithProps } from '@instructure/ui-icons'
|
|
30
|
+
|
|
31
|
+
import generateStyles from './styles'
|
|
32
|
+
import type { TreeBrowserButtonProps } from './props'
|
|
33
|
+
import { allowedProps } from './props'
|
|
34
|
+
import TreeBrowserContext from '../TreeBrowserContext'
|
|
35
|
+
|
|
36
|
+
// Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
|
|
37
|
+
|
|
38
|
+
// Map TreeBrowser size tokens to icon size tokens
|
|
39
|
+
const treeBrowserSizeToIconSize = {
|
|
40
|
+
small: 'md',
|
|
41
|
+
medium: 'lg',
|
|
42
|
+
large: 'xl'
|
|
43
|
+
} as const
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
---
|
|
47
|
+
parent: TreeBrowser
|
|
48
|
+
id: TreeBrowser.Button
|
|
49
|
+
---
|
|
50
|
+
**/
|
|
51
|
+
@withStyle(generateStyles, 'TreeBrowserTreeButton')
|
|
52
|
+
class TreeButton extends Component<
|
|
53
|
+
TreeBrowserButtonProps,
|
|
54
|
+
{ isHovered: boolean }
|
|
55
|
+
> {
|
|
56
|
+
static readonly componentId = 'TreeBrowser.Button'
|
|
57
|
+
|
|
58
|
+
static allowedProps = allowedProps
|
|
59
|
+
|
|
60
|
+
static contextType = TreeBrowserContext
|
|
61
|
+
declare context: ContextType<typeof TreeBrowserContext>
|
|
62
|
+
|
|
63
|
+
static defaultProps = {
|
|
64
|
+
type: 'treeButton',
|
|
65
|
+
size: 'medium',
|
|
66
|
+
variant: 'folderTree',
|
|
67
|
+
selected: false,
|
|
68
|
+
focused: false,
|
|
69
|
+
expanded: false,
|
|
70
|
+
hoverable: true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ref: Element | null = null
|
|
74
|
+
|
|
75
|
+
state = {
|
|
76
|
+
isHovered: false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
componentDidMount() {
|
|
80
|
+
this.props.makeStyles?.({
|
|
81
|
+
animation: this.context?.animation,
|
|
82
|
+
hoverable: this.props.hoverable
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
componentDidUpdate() {
|
|
87
|
+
this.props.makeStyles?.({
|
|
88
|
+
animation: this.context?.animation,
|
|
89
|
+
hoverable: this.props.hoverable
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
defaultContentRenderer(props: TreeBrowserButtonProps) {
|
|
94
|
+
const { name, descriptor, styles } = props
|
|
95
|
+
return (
|
|
96
|
+
<span css={styles!.layout}>
|
|
97
|
+
{this.renderImage()}
|
|
98
|
+
<span css={styles!.text}>
|
|
99
|
+
<span css={styles!.textName}>{name}</span>
|
|
100
|
+
{descriptor ? (
|
|
101
|
+
<span css={styles!.textDescriptor} title={descriptor}>
|
|
102
|
+
{descriptor}
|
|
103
|
+
</span>
|
|
104
|
+
) : null}
|
|
105
|
+
</span>
|
|
106
|
+
</span>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getIconColor(): 'baseColor' | 'onColor' | 'inverseColor' {
|
|
111
|
+
const { selected } = this.props
|
|
112
|
+
const { isHovered } = this.state
|
|
113
|
+
|
|
114
|
+
// Priority: selected > hover > default
|
|
115
|
+
if (selected) return 'onColor'
|
|
116
|
+
if (isHovered) return 'inverseColor'
|
|
117
|
+
return 'baseColor'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
renderImage() {
|
|
121
|
+
const { type } = this.props
|
|
122
|
+
switch (type) {
|
|
123
|
+
case 'collection':
|
|
124
|
+
return this.renderCollectionIcon()
|
|
125
|
+
case 'item':
|
|
126
|
+
return this.renderItemImage()
|
|
127
|
+
default:
|
|
128
|
+
break
|
|
129
|
+
}
|
|
130
|
+
return undefined
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
renderCollectionIcon() {
|
|
134
|
+
const { expanded, collectionIcon, collectionIconExpanded, styles, size } =
|
|
135
|
+
this.props
|
|
136
|
+
|
|
137
|
+
if (collectionIcon || collectionIconExpanded) {
|
|
138
|
+
const icon = (expanded ? collectionIconExpanded : collectionIcon) as any
|
|
139
|
+
const iconSize = treeBrowserSizeToIconSize[size!]
|
|
140
|
+
const iconColor = this.getIconColor()
|
|
141
|
+
const iconElement = renderIconWithProps(icon, iconSize, iconColor)
|
|
142
|
+
|
|
143
|
+
return <div css={styles?.icon}>{iconElement}</div>
|
|
144
|
+
}
|
|
145
|
+
return undefined
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
renderItemImage() {
|
|
149
|
+
const { thumbnail, itemIcon, styles, size } = this.props
|
|
150
|
+
|
|
151
|
+
if (thumbnail) {
|
|
152
|
+
return (
|
|
153
|
+
<div css={styles?.thumbnail}>
|
|
154
|
+
<Img src={thumbnail} constrain="cover" alt="" />
|
|
155
|
+
</div>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
if (itemIcon) {
|
|
159
|
+
const iconSize = treeBrowserSizeToIconSize[size!]
|
|
160
|
+
const iconColor = this.getIconColor()
|
|
161
|
+
const iconElement = renderIconWithProps(itemIcon, iconSize, iconColor)
|
|
162
|
+
|
|
163
|
+
return <div css={styles?.icon}>{iconElement}</div>
|
|
164
|
+
}
|
|
165
|
+
return undefined
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
handleRef = (el: HTMLButtonElement) => {
|
|
169
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
170
|
+
this.props.containerRef(el.parentElement)
|
|
171
|
+
}
|
|
172
|
+
this.ref = el
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
handleMouseEnter = () => {
|
|
176
|
+
if (this.props.hoverable) {
|
|
177
|
+
this.setState({ isHovered: true })
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
handleMouseLeave = () => {
|
|
182
|
+
if (this.props.hoverable) {
|
|
183
|
+
this.setState({ isHovered: false })
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
render() {
|
|
188
|
+
const { styles, renderContent } = this.props
|
|
189
|
+
const buttonContent = renderContent
|
|
190
|
+
? renderContent(this.props)
|
|
191
|
+
: this.defaultContentRenderer(this.props)
|
|
192
|
+
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
193
|
+
return (
|
|
194
|
+
<button
|
|
195
|
+
ref={this.handleRef}
|
|
196
|
+
tabIndex={-1}
|
|
197
|
+
type="button"
|
|
198
|
+
css={styles?.treeButton}
|
|
199
|
+
data-cid="TreeButton"
|
|
200
|
+
onMouseEnter={this.handleMouseEnter}
|
|
201
|
+
onMouseLeave={this.handleMouseLeave}
|
|
202
|
+
>
|
|
203
|
+
{buttonContent}
|
|
204
|
+
</button>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export default TreeButton
|
|
210
|
+
export { TreeButton }
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
27
|
+
import type { TreeBrowserButtonTheme } from '@instructure/shared-types'
|
|
28
|
+
import type { TreeBrowserCommonProps } from '../props'
|
|
29
|
+
|
|
30
|
+
type TreeBrowserButtonOwnProps = {
|
|
31
|
+
id?: string | number
|
|
32
|
+
name?: string
|
|
33
|
+
descriptor?: string
|
|
34
|
+
type?: 'collection' | 'item' | string // | string is for custom type
|
|
35
|
+
thumbnail?: string
|
|
36
|
+
/**
|
|
37
|
+
* Called when this button is clicked
|
|
38
|
+
*/
|
|
39
|
+
onClick?: (e: React.MouseEvent) => void
|
|
40
|
+
expanded?: boolean
|
|
41
|
+
selected?: boolean
|
|
42
|
+
focused?: boolean
|
|
43
|
+
level?: number
|
|
44
|
+
/**
|
|
45
|
+
* A function that returns a reference to the parent li element
|
|
46
|
+
*/
|
|
47
|
+
containerRef?: (el: HTMLElement | null) => void
|
|
48
|
+
/**
|
|
49
|
+
* Whether the button should show hover effects.
|
|
50
|
+
* Set to false to disable hover styling when the button contains custom interactive content.
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
hoverable?: boolean
|
|
54
|
+
} & TreeBrowserCommonProps
|
|
55
|
+
|
|
56
|
+
type PropKeys = keyof TreeBrowserButtonOwnProps
|
|
57
|
+
|
|
58
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
59
|
+
|
|
60
|
+
type TreeBrowserButtonProps = TreeBrowserButtonOwnProps &
|
|
61
|
+
WithStyleProps<TreeBrowserButtonTheme, TreeBrowserButtonStyle>
|
|
62
|
+
|
|
63
|
+
type TreeBrowserButtonStyle = ComponentStyle<
|
|
64
|
+
| 'treeButton'
|
|
65
|
+
| 'layout'
|
|
66
|
+
| 'text'
|
|
67
|
+
| 'textName'
|
|
68
|
+
| 'textDescriptor'
|
|
69
|
+
| 'icon'
|
|
70
|
+
| 'thumbnail'
|
|
71
|
+
| 'node'
|
|
72
|
+
>
|
|
73
|
+
const allowedProps: AllowedPropKeys = [
|
|
74
|
+
'id',
|
|
75
|
+
'name',
|
|
76
|
+
'descriptor',
|
|
77
|
+
'type',
|
|
78
|
+
'size',
|
|
79
|
+
'variant',
|
|
80
|
+
'collectionIcon',
|
|
81
|
+
'collectionIconExpanded',
|
|
82
|
+
'itemIcon',
|
|
83
|
+
'thumbnail',
|
|
84
|
+
'onClick',
|
|
85
|
+
'expanded',
|
|
86
|
+
'selected',
|
|
87
|
+
'focused',
|
|
88
|
+
'level',
|
|
89
|
+
'containerRef',
|
|
90
|
+
'renderContent',
|
|
91
|
+
'hoverable'
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
export type { TreeBrowserButtonProps, TreeBrowserButtonStyle }
|
|
95
|
+
export { allowedProps }
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { keyframes, calcFocusOutlineStyles } from '@instructure/emotion'
|
|
26
|
+
|
|
27
|
+
import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
28
|
+
import type { TreeBrowserButtonProps, TreeBrowserButtonStyle } from './props'
|
|
29
|
+
|
|
30
|
+
const transform = keyframes`
|
|
31
|
+
50% {
|
|
32
|
+
opacity: 0.5;
|
|
33
|
+
transform: translate3d(2%, 0, 0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
100% {
|
|
37
|
+
opacity: 1;
|
|
38
|
+
transform: translate3d(0, 0, 0);
|
|
39
|
+
}`
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* ---
|
|
43
|
+
* private: true
|
|
44
|
+
* ---
|
|
45
|
+
* Generates the style object from the theme and provided additional information
|
|
46
|
+
* @param {Object} componentTheme The theme variable object.
|
|
47
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
48
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
49
|
+
* @return {Object} The final style object, which will be used in the component
|
|
50
|
+
*/
|
|
51
|
+
const generateStyles = (
|
|
52
|
+
componentTheme: NewComponentTypes['TreeBrowserTreeButton'],
|
|
53
|
+
props: TreeBrowserButtonProps,
|
|
54
|
+
sharedTokens: SharedTokens,
|
|
55
|
+
state: { animation?: boolean; hoverable?: boolean }
|
|
56
|
+
): TreeBrowserButtonStyle => {
|
|
57
|
+
const { size, variant, selected, level } = props
|
|
58
|
+
|
|
59
|
+
const isRootButton = level && level === 1
|
|
60
|
+
|
|
61
|
+
const sizeMap = {
|
|
62
|
+
small: {
|
|
63
|
+
folderTree: {
|
|
64
|
+
before: {
|
|
65
|
+
width: componentTheme.baseSpacingSmall
|
|
66
|
+
},
|
|
67
|
+
icon: {
|
|
68
|
+
marginInlineEnd: componentTheme.iconsMarginRightSmall,
|
|
69
|
+
marginInlineStart: '0'
|
|
70
|
+
},
|
|
71
|
+
thumbnail: {
|
|
72
|
+
height: `calc(${componentTheme.baseSpacingSmall} * 2)`,
|
|
73
|
+
width: `calc(${componentTheme.baseSpacingSmall}* 2)`,
|
|
74
|
+
marginInlineEnd: componentTheme.iconsMarginRightSmall,
|
|
75
|
+
marginInlineStart: '0'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
indent: {
|
|
79
|
+
icon: {
|
|
80
|
+
marginInlineEnd: componentTheme.iconsMarginRightSmall,
|
|
81
|
+
marginInlineStart: '0'
|
|
82
|
+
},
|
|
83
|
+
thumbnail: {
|
|
84
|
+
height: `calc(${componentTheme.baseSpacingSmall} * 2)`,
|
|
85
|
+
width: `calc(${componentTheme.baseSpacingSmall} * 2)`,
|
|
86
|
+
marginInlineEnd: componentTheme.iconsMarginRightSmall,
|
|
87
|
+
marginInlineStart: '0'
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
textName: {
|
|
91
|
+
fontSize: componentTheme.nameFontSizeSmall
|
|
92
|
+
},
|
|
93
|
+
textDescriptor: {
|
|
94
|
+
fontSize: componentTheme.descriptorFontSizeSmall
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
medium: {
|
|
98
|
+
folderTree: {
|
|
99
|
+
before: {
|
|
100
|
+
width: componentTheme.baseSpacingMedium
|
|
101
|
+
},
|
|
102
|
+
icon: {
|
|
103
|
+
marginInlineEnd: componentTheme.iconsMarginRightMedium,
|
|
104
|
+
marginInlineStart: '0'
|
|
105
|
+
},
|
|
106
|
+
thumbnail: {
|
|
107
|
+
height: `calc(${componentTheme.baseSpacingMedium} * 2)`,
|
|
108
|
+
width: `calc(${componentTheme.baseSpacingMedium} * 2)`,
|
|
109
|
+
marginInlineEnd: componentTheme.iconsMarginRightMedium,
|
|
110
|
+
marginInlineStart: '0'
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
indent: {
|
|
114
|
+
icon: {
|
|
115
|
+
marginInlineEnd: componentTheme.iconsMarginRightMedium,
|
|
116
|
+
marginInlineStart: '0'
|
|
117
|
+
},
|
|
118
|
+
thumbnail: {
|
|
119
|
+
height: `calc(${componentTheme.baseSpacingMedium} * 2)`,
|
|
120
|
+
width: `calc(${componentTheme.baseSpacingMedium} * 2)`,
|
|
121
|
+
marginInlineEnd: componentTheme.iconsMarginRightMedium,
|
|
122
|
+
marginInlineStart: '0'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
textName: {
|
|
126
|
+
fontSize: componentTheme.nameFontSizeMedium
|
|
127
|
+
},
|
|
128
|
+
textDescriptor: {
|
|
129
|
+
fontSize: componentTheme.descriptorFontSizeMedium
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
large: {
|
|
133
|
+
folderTree: {
|
|
134
|
+
before: {
|
|
135
|
+
width: componentTheme.baseSpacingLarge
|
|
136
|
+
},
|
|
137
|
+
icon: {
|
|
138
|
+
marginInlineEnd: componentTheme.iconsMarginRightLarge,
|
|
139
|
+
marginInlineStart: '0'
|
|
140
|
+
},
|
|
141
|
+
thumbnail: {
|
|
142
|
+
height: `calc(${componentTheme.baseSpacingLarge} * 2)`,
|
|
143
|
+
width: `calc(${componentTheme.baseSpacingLarge} * 2)`,
|
|
144
|
+
marginInlineEnd: componentTheme.iconsMarginRightLarge,
|
|
145
|
+
marginInlineStart: '0'
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
indent: {
|
|
149
|
+
icon: {
|
|
150
|
+
marginInlineEnd: componentTheme.iconsMarginRightLarge,
|
|
151
|
+
marginInlineStart: '0'
|
|
152
|
+
},
|
|
153
|
+
thumbnail: {
|
|
154
|
+
height: `calc(${componentTheme.baseSpacingLarge} * 2)`,
|
|
155
|
+
width: `calc(${componentTheme.baseSpacingLarge}* 2)`,
|
|
156
|
+
marginInlineEnd: componentTheme.iconsMarginRightLarge,
|
|
157
|
+
marginInlineStart: '0'
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
textName: {
|
|
161
|
+
fontSize: componentTheme.nameFontSizeLarge
|
|
162
|
+
},
|
|
163
|
+
textDescriptor: {
|
|
164
|
+
fontSize: componentTheme.descriptorFontSizeLarge
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const textStyle = {
|
|
170
|
+
minWidth: '0.0625rem',
|
|
171
|
+
lineHeight: componentTheme.textLineHeight,
|
|
172
|
+
flex: 1
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const textNameStyle = {
|
|
176
|
+
display: 'block',
|
|
177
|
+
overflow: 'hidden',
|
|
178
|
+
whiteSpace: 'nowrap',
|
|
179
|
+
textOverflow: 'ellipsis',
|
|
180
|
+
...sizeMap[size!].textName
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const layoutPadding = {
|
|
184
|
+
small: {
|
|
185
|
+
folderTree: {
|
|
186
|
+
padding: `calc(${componentTheme.baseSpacingSmall} / 3) ${componentTheme.baseSpacingSmall}`
|
|
187
|
+
},
|
|
188
|
+
indent: {
|
|
189
|
+
padding: `calc(${componentTheme.baseSpacingSmall} / 3) calc(${componentTheme.baseSpacingSmall} / 2)`
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
medium: {
|
|
193
|
+
folderTree: {
|
|
194
|
+
padding: `calc(${componentTheme.baseSpacingMedium} / 3) ${componentTheme.baseSpacingMedium}`
|
|
195
|
+
},
|
|
196
|
+
indent: {
|
|
197
|
+
padding: `calc(${componentTheme.baseSpacingMedium} / 3) calc(${componentTheme.baseSpacingMedium} / 2)`
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
large: {
|
|
201
|
+
folderTree: {
|
|
202
|
+
padding: `calc(${componentTheme.baseSpacingLarge} / 3) ${componentTheme.baseSpacingLarge}`
|
|
203
|
+
},
|
|
204
|
+
indent: {
|
|
205
|
+
padding: `calc(${componentTheme.baseSpacingLarge} / 3) calc(${componentTheme.baseSpacingLarge} / 2)`
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
treeButton: {
|
|
212
|
+
label: 'treeButton',
|
|
213
|
+
boxSizing: 'border-box',
|
|
214
|
+
display: 'block',
|
|
215
|
+
width: '100%',
|
|
216
|
+
margin: '0',
|
|
217
|
+
backgroundColor: 'transparent',
|
|
218
|
+
textAlign: 'start',
|
|
219
|
+
fontFamily: 'inherit',
|
|
220
|
+
userSelect: 'none',
|
|
221
|
+
cursor: 'pointer',
|
|
222
|
+
border: 'none',
|
|
223
|
+
borderRadius: componentTheme.borderRadius,
|
|
224
|
+
position: 'relative',
|
|
225
|
+
zIndex: 1,
|
|
226
|
+
...(state?.animation
|
|
227
|
+
? {
|
|
228
|
+
transform: 'translate3d(-2%, 0, 0)',
|
|
229
|
+
opacity: 0.01,
|
|
230
|
+
transformOrigin: 'left center',
|
|
231
|
+
animationName: transform,
|
|
232
|
+
animationDuration: '0.2s',
|
|
233
|
+
animationFillMode: 'forwards',
|
|
234
|
+
animationTimingFunction: 'ease-out',
|
|
235
|
+
animationDelay: '0.2s'
|
|
236
|
+
}
|
|
237
|
+
: {}),
|
|
238
|
+
outline: '0',
|
|
239
|
+
padding: '0',
|
|
240
|
+
...(sharedTokens?.focusOutline
|
|
241
|
+
? calcFocusOutlineStyles(sharedTokens.focusOutline)
|
|
242
|
+
: {}),
|
|
243
|
+
...(variant === 'folderTree' &&
|
|
244
|
+
!isRootButton && {
|
|
245
|
+
'&::before': {
|
|
246
|
+
content: '""',
|
|
247
|
+
height: componentTheme.borderWidth,
|
|
248
|
+
background: componentTheme.borderColor, // Tree horizontal lines
|
|
249
|
+
position: 'absolute',
|
|
250
|
+
insetInlineStart: '0',
|
|
251
|
+
insetInlineEnd: 'auto',
|
|
252
|
+
top: '50%',
|
|
253
|
+
...(selected && { visibility: 'hidden' }),
|
|
254
|
+
...sizeMap[size!][variant!].before
|
|
255
|
+
},
|
|
256
|
+
'&:hover::before': {
|
|
257
|
+
visibility: state?.hoverable ? 'hidden' : 'visible'
|
|
258
|
+
}
|
|
259
|
+
}),
|
|
260
|
+
...(state?.hoverable !== false && {
|
|
261
|
+
'&:hover': {
|
|
262
|
+
backgroundColor: selected
|
|
263
|
+
? componentTheme.selectedBackgroundColor
|
|
264
|
+
: componentTheme.hoverBackgroundColor,
|
|
265
|
+
|
|
266
|
+
'[class$=-treeButton__textName], [class$=-treeButton__textDescriptor], [class$=-treeButton__node]':
|
|
267
|
+
{
|
|
268
|
+
color: selected
|
|
269
|
+
? componentTheme.selectedTextColor
|
|
270
|
+
: componentTheme.hoverTextColor
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}),
|
|
274
|
+
...(selected && {
|
|
275
|
+
backgroundColor: componentTheme.selectedBackgroundColor
|
|
276
|
+
})
|
|
277
|
+
},
|
|
278
|
+
layout: {
|
|
279
|
+
label: 'treeButton__layout',
|
|
280
|
+
display: 'flex',
|
|
281
|
+
alignItems: 'center',
|
|
282
|
+
lineHeight: 1,
|
|
283
|
+
minHeight: '2rem',
|
|
284
|
+
...layoutPadding[size!][variant!]
|
|
285
|
+
},
|
|
286
|
+
text: {
|
|
287
|
+
label: 'treeButton__text',
|
|
288
|
+
...textStyle
|
|
289
|
+
},
|
|
290
|
+
textName: {
|
|
291
|
+
label: 'treeButton__textName',
|
|
292
|
+
...textNameStyle,
|
|
293
|
+
color: selected
|
|
294
|
+
? componentTheme.selectedTextColor
|
|
295
|
+
: componentTheme.nameTextColor
|
|
296
|
+
},
|
|
297
|
+
textDescriptor: {
|
|
298
|
+
label: 'treeButton__textDescriptor',
|
|
299
|
+
display: 'block',
|
|
300
|
+
overflow: 'hidden',
|
|
301
|
+
whiteSpace: 'nowrap',
|
|
302
|
+
textOverflow: 'ellipsis',
|
|
303
|
+
marginTop: componentTheme.descriptorMarginTop,
|
|
304
|
+
color: selected
|
|
305
|
+
? componentTheme.selectedTextColor
|
|
306
|
+
: componentTheme.descriptorTextColor,
|
|
307
|
+
...sizeMap[size!].textDescriptor
|
|
308
|
+
},
|
|
309
|
+
icon: {
|
|
310
|
+
label: 'treeButton__icon',
|
|
311
|
+
minWidth: '0.0625rem',
|
|
312
|
+
position: 'relative',
|
|
313
|
+
zIndex: 1,
|
|
314
|
+
alignItems: 'center',
|
|
315
|
+
justifyContent: 'center',
|
|
316
|
+
...sizeMap[size!][variant!].icon
|
|
317
|
+
},
|
|
318
|
+
thumbnail: {
|
|
319
|
+
label: 'treeButton__thumbnail',
|
|
320
|
+
...sizeMap[size!][variant!].thumbnail
|
|
321
|
+
},
|
|
322
|
+
node: {
|
|
323
|
+
label: 'treeButton__node',
|
|
324
|
+
...textStyle,
|
|
325
|
+
...textNameStyle,
|
|
326
|
+
color: componentTheme.descriptorTextColor
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export default generateStyles
|