Skip to content

Commit

Permalink
feat(VerticalNavigation): move chevrons to the right
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulo Lagoá committed Jun 6, 2023
1 parent 64ef7a2 commit 6842bcc
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styled from "@emotion/styled";
import { theme } from "@hitachivantara/uikit-styles";
import { HvTypography } from "@core/components";
import { outlineStyles } from "@core/utils";
import { transientOptions } from "@core/utils/transientOptions";
import treeViewItemClasses from "./treeViewItemClasses";

const selected = () => ({
Expand All @@ -21,6 +22,18 @@ export const StyledGroup = styled("ul")({
padding: 0,
});

export const StyledLabel = styled(
"div",
transientOptions
)(({ $expandable }: { $expandable: boolean }) => ({
display: "flex",
flexGrow: 1,
maxWidth: "100%",
...($expandable && {
maxWidth: "calc(100% - 32px)",
}),
}));

export const StyledNode = styled("li")({
listStyle: "none",
minHeight: "32px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import { setId } from "@core/utils";
import treeViewItemClasses, {
HvVerticalNavigationTreeViewItemClasses,
} from "./treeViewItemClasses";
import { StyledContent, StyledGroup, StyledNode } from "./TreeViewItem.styles";
import {
StyledContent,
StyledGroup,
StyledNode,
StyledLabel,
} from "./TreeViewItem.styles";
import { DescendantProvider, useDescendant } from "./descendants";
import {
TreeViewControlContext,
Expand Down Expand Up @@ -431,8 +436,7 @@ export const HvVerticalNavigationTreeViewItem = forwardRef(
onMouseDown={handleMouseDown}
style={{
paddingLeft:
(expandable || useIcons || !isOpen ? 0 : 10) +
level * (collapsible ? 32 : 10),
(useIcons || !isOpen ? 0 : 10) + level * (collapsible ? 16 : 10),
}}
role={href ? undefined : "button"}
{...(treeviewMode
Expand All @@ -455,8 +459,6 @@ export const HvVerticalNavigationTreeViewItem = forwardRef(
"aria-label": payload?.label,
})}
>
{isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}

<IconWrapper
icon={useIcons && icon}
label={payload?.label}
Expand All @@ -466,7 +468,10 @@ export const HvVerticalNavigationTreeViewItem = forwardRef(
disableTooltip={disableTooltip}
/>

{isOpen && label}
{isOpen && (
<StyledLabel $expandable={!!expandable}>{label}</StyledLabel>
)}
{isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}
</StyledContent>
),
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
System
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
System
</div>
</div>
<ul
class="HvVerticalNavigationTreeViewItem-group css-zinev9-StyledGroup er1eqbm2"
class="HvVerticalNavigationTreeViewItem-group css-zinev9-StyledGroup er1eqbm3"
id="hvtreeview2-1-group"
>
<li
Expand All @@ -40,10 +44,14 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
SCPodF
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
SCPodF
</div>
</div>
<ul
class="HvVerticalNavigationTreeViewItem-group css-zinev9-StyledGroup er1eqbm2"
class="HvVerticalNavigationTreeViewItem-group css-zinev9-StyledGroup er1eqbm3"
id="hvtreeview2-2-group"
>
<li
Expand All @@ -60,7 +68,11 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
Compute
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
Compute
</div>
</div>
</li>
<li
Expand All @@ -77,7 +89,11 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
Storage
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
Storage
</div>
</div>
</li>
<li
Expand All @@ -94,7 +110,11 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
Ethernet
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
Ethernet
</div>
</div>
</li>
<li
Expand All @@ -111,7 +131,11 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
Fiber Channel
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
Fiber Channel
</div>
</div>
</li>
</ul>
Expand All @@ -133,10 +157,14 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
Administration
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
Administration
</div>
</div>
<ul
class="HvVerticalNavigationTreeViewItem-group css-zinev9-StyledGroup er1eqbm2"
class="HvVerticalNavigationTreeViewItem-group css-zinev9-StyledGroup er1eqbm3"
id="hvtreeview2-7-group"
>
<li
Expand All @@ -153,7 +181,11 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
Rest API
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
Rest API
</div>
</div>
</li>
<li
Expand All @@ -170,7 +202,11 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
License
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
License
</div>
</div>
</li>
<li
Expand All @@ -187,7 +223,11 @@ exports[`VerticalNavigation - Actions > should render correctly 1`] = `
<div
class="css-n1g5h0-StyledIconsContainer emephz1"
/>
Log Bundle
<div
class="css-1674i57-StyledLabel er1eqbm2"
>
Log Bundle
</div>
</div>
</li>
</ul>
Expand Down
Loading

0 comments on commit 6842bcc

Please sign in to comment.