-
Notifications
You must be signed in to change notification settings - Fork 8
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
TreeView left margin override support #2338
base: main
Are you sure you want to change the base?
Changes from 9 commits
d55ef87
e4e193f
22a1cfc
139a35f
f79d82d
1f8e120
c93dc09
9d888b6
c9cc5cb
7b0d8ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
fredvisser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"comment": "Update tree item padding from 10px to 8px (mediumPadding) to match standard layout requirements, and expose `treeViewLeftMargin` token to allow override for specific use cases.", | ||
"packageName": "@ni/nimble-components", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { html, repeat, when } from '@microsoft/fast-element'; | ||
import { withActions } from '@storybook/addon-actions/decorator'; | ||
import type { HtmlRenderer, Meta, StoryObj } from '@storybook/html'; | ||
import { treeViewLeftMargin } from '../../../../nimble-components/src/theme-provider/design-tokens'; | ||
import { iconCogTag } from '../../../../nimble-components/src/icons/cog'; | ||
import { iconDatabaseTag } from '../../../../nimble-components/src/icons/database'; | ||
import { treeItemTag } from '../../../../nimble-components/src/tree-item'; | ||
|
@@ -21,6 +22,7 @@ interface TreeArgs { | |
options: ItemArgs[]; | ||
expandedChange: undefined; | ||
selectedChange: undefined; | ||
leftMargin: string; | ||
} | ||
|
||
interface ItemArgs { | ||
|
@@ -199,11 +201,20 @@ export const multipleTreeItems: StoryObj<TreeArgs> = { | |
description: | ||
'Event emitted when an item is selected or deselected.', | ||
table: { category: apiCategory.events } | ||
}, | ||
leftMargin: { | ||
name: 'Left margin', | ||
description: 'Overrides the default left margin of the tree view.', | ||
table: { category: apiCategory.styles }, | ||
control: { type: 'text' } | ||
Comment on lines
+205
to
+209
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think having the token for configuration of this property is the right move but I don't know about broadcasting this so openly in the args table. We could call it out in usage guidance in the mdx for the very specific use case. And we should have a test for the behavior. I'm actually tempted to have it as part of the matrix test to make sure it is interacting well with all the other modes that impact the spacing there (nested menu-items, icons, etc. ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about a compromise where we remove the docs from the args table and rely on the SWIF Chromatic tests to catch any regressions, instead of adding this to the matrix tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like nimble features to have tests in nimble. I wouldn't expect adding a new state to the matrix test to be difficult. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving the PR back to draft until we decide on the testing direction |
||
} | ||
}, | ||
// prettier-ignore | ||
render: createUserSelectedThemeStory(html` | ||
<${treeViewTag} selection-mode="${x => x.selectionMode}"> | ||
<${treeViewTag} | ||
selection-mode="${x => x.selectionMode}" | ||
style="${x => `${treeViewLeftMargin.cssCustomProperty}:${x.leftMargin};`}" | ||
> | ||
${repeat(x => x.options, html<ItemArgs>` | ||
<${treeItemTag} ?expanded="${x => x.expanded}" value="${x => x.value}"> | ||
${when(x => x.icon, html`<${iconDatabaseTag} slot="start"></${iconDatabaseTag}>`)} | ||
|
@@ -263,6 +274,7 @@ export const multipleTreeItems: StoryObj<TreeArgs> = { | |
selected: false, | ||
expanded: false | ||
} | ||
] | ||
], | ||
leftMargin: '8px' | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To summarize the concerns from Friday, the direction I think we should go is that the tree in nimble uses more normal padding values. If we look at a tree view expander aligned above a normal icon button you see the following:
You can see the left-padding on the tree-view is too big (10px). Normally we would expect 8px left spacing-16px icon-8px spacing. So the issue with the nimble tree-view is that padding-left should be 8px and not 10 or 12 px.
The second step is that the systemlink header seems to be using a non-standard icon button with custom sizing. It does not have a square 32px by 32px shape and seems to be a one-off unique button. The tree-view in nimble should not be adjusted to the sizing of that unique button only used in the sl-header.
Instead if we need to override this padding for one unique use-case then it should just be done in the sl-header styles or at most we create a design token that can be configured externally.