-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bump-eslint
- Loading branch information
Showing
17 changed files
with
223 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
Update NavList to use the new ActionList.GroupHeading API and Add an "as" prop to specify the heading level as default h3. (No changes expected in the rendered HTML) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": minor | ||
--- | ||
|
||
TreeView: Add support for `TreeView.LeadingAction` |
Binary file added
BIN
+9.27 KB
...ts/TreeView.test.ts-snapshots/TreeView-Leading-Action-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.37 KB
...onents/TreeView.test.ts-snapshots/TreeView-Leading-Action-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.25 KB
...TreeView.test.ts-snapshots/TreeView-Leading-Action-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.24 KB
...ts/components/TreeView.test.ts-snapshots/TreeView-Leading-Action-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.25 KB
...ts/TreeView.test.ts-snapshots/TreeView-Leading-Action-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.27 KB
...s/TreeView.test.ts-snapshots/TreeView-Leading-Action-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.3 KB
...reeView.test.ts-snapshots/TreeView-Leading-Action-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.29 KB
...s/components/TreeView.test.ts-snapshots/TreeView-Leading-Action-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.25 KB
...s/TreeView.test.ts-snapshots/TreeView-Leading-Action-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import {GrabberIcon} from '@primer/octicons-react' | ||
import type {Meta, Story} from '@storybook/react' | ||
import React from 'react' | ||
import Box from '../Box' | ||
import {TreeView} from './TreeView' | ||
import {IconButton} from '../Button' | ||
|
||
const meta: Meta = { | ||
title: 'Components/TreeView/Examples', | ||
component: TreeView, | ||
decorators: [ | ||
Story => { | ||
return ( | ||
// Prevent TreeView from expanding to the full width of the screen | ||
<Box sx={{maxWidth: 400}}> | ||
<Story /> | ||
</Box> | ||
) | ||
}, | ||
], | ||
} | ||
|
||
export const DraggableListItem: Story = () => { | ||
return ( | ||
<Box | ||
sx={{ | ||
// using Box for css, this could be in a css file as well | ||
'.treeview-item': { | ||
'.treeview-leading-action': {visibility: 'hidden'}, | ||
'&:hover, &:focus': { | ||
'.treeview-leading-action': {visibility: 'visible'}, | ||
}, | ||
}, | ||
}} | ||
> | ||
<TreeView aria-label="Issues"> | ||
<ControlledDraggableItem id="item-1">Item 1</ControlledDraggableItem> | ||
<ControlledDraggableItem id="item-2"> | ||
Item 2 | ||
<TreeView.SubTree> | ||
<TreeView.Item id="item-2-sub-task-1">sub task 1</TreeView.Item> | ||
<TreeView.Item id="item-2-sub-task-2">sub task 2</TreeView.Item> | ||
</TreeView.SubTree> | ||
</ControlledDraggableItem> | ||
<ControlledDraggableItem id="item-3">Item 3</ControlledDraggableItem> | ||
</TreeView> | ||
</Box> | ||
) | ||
} | ||
|
||
const ControlledDraggableItem: React.FC<{id: string; children: React.ReactNode}> = ({id, children}) => { | ||
const [expanded, setExpanded] = React.useState(false) | ||
|
||
return ( | ||
<> | ||
<TreeView.Item id={id} className="treeview-item" expanded={expanded} onExpandedChange={setExpanded}> | ||
<TreeView.LeadingAction> | ||
<IconButton | ||
icon={GrabberIcon} | ||
variant="invisible" | ||
aria-label="Reorder item" | ||
className="treeview-leading-action" | ||
draggable="true" | ||
onDragStart={() => { | ||
setExpanded(false) | ||
// other drag logic to follow | ||
}} | ||
/> | ||
</TreeView.LeadingAction> | ||
{children} | ||
</TreeView.Item> | ||
</> | ||
) | ||
} | ||
|
||
export default meta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters